如何赢得这场比赛?
支持我们有一个 n * m 的桌子,两个玩家玩这个游戏。他们依次排除细胞。玩家可以选择一个单元格 (i, j) 并排除从 (i,j) 到 (n, m) 的所有单元格,排除最后一个单元格的人输游戏。
例如,在3*5的棋盘上,玩家1排除了(3,3)到(3,5)的单元格,玩家2排除了(2,5)到(3,5)的棋盘,当前棋盘是这样的: (O 表示该单元格未被排除,而 x 表示该单元格已被排除)
3 O O x x x
2 O O O O x
1 O O O O O
1 2 3 4 5
并且在玩家 1 排除了从 (2,1) 到 (3,5) 的单元格后,棋盘变为
3 x x x x x
2 x x x x x
1 O O O O O
1 2 3 4 5
现在玩家 2 排除了来自 (1, 2) 到 (3,5),只留下 (1,1) 干净:
3 x x x x x
2 x x x x x
1 O x x x x
1 2 3 4 5
因此玩家 1 必须排除唯一的 (1,1) 单元格,因为一名玩家必须在一轮中排除至少一个单元格,他输了比赛。
显然,在 n*n、1*n 和 2*n(n >= 2)种情况下,先玩的人获胜。
我的问题是,玩家是否有任何策略可以在所有情况下赢得比赛?他应该先上场吗?
PS
我认为这与动态规划或分而治之等策略有关,但尚未得出结论。所以我把它贴在这里。
答案
感谢sdcwc's link。对于大于 1*1 的桌子,第一个玩家将获胜。证明如下:(借自wiki页面)
事实证明,对于任何矩形 起始位置大于 1 × 1 第一个玩家可以获胜。这可以是 使用策略窃取显示 论证:假设第二个玩家 对任何人都有制胜策略 最初的第一个玩家移动。那么假设, 第一个玩家只拿走 右下角的正方形。由我们的 假设,第二个玩家有 对此的回应将迫使 胜利。但如果这样的胜利 响应存在,第一个玩家可以 已将其作为他的第一步并且 从而强行取得胜利。第二位玩家 因此无法获胜 策略。
并且 Zermelo 定理 确保了这样的存在制胜策略。
Support we have an n * m table, and two players play this game. They rule out cells in turn. A player can choose a cell (i, j) and rule out all the cells from (i,j) to (n, m), and who rules out the last cell loses the game.
For example, on a 3*5 board, player 1 rules out cell (3,3) to (3,5), and player 2 rules out (2,5) to (3,5), current board is like this: (O means the cell is not ruled out while x mean it is ruled out)
3 O O x x x
2 O O O O x
1 O O O O O
1 2 3 4 5
and after player 1 rules out cells from (2,1) to (3,5), the board becomes
3 x x x x x
2 x x x x x
1 O O O O O
1 2 3 4 5
Now player 2 rules out cells from (1,2) to (3,5), which leaves only (1,1) clean:
3 x x x x x
2 x x x x x
1 O x x x x
1 2 3 4 5
So player 1 has to rules out the only (1,1) cell, since one player has to rule out at least one cell in a turn, and he loses the game.
It is clearly that in n*n, 1*n, and 2*n (n >= 2) cases, the one who plays the first wins.
My problem is that, is there any strategy for a player to win the game in all cases? Should he plays first?
P.S
I think it is related to strategies like dynamic programming or divide-and-conquer, but has not come to an idea yet. So I post it here.
The answer
Thanks to sdcwc's link. For tables bigger than 1*1, the first player will win. The proof is follow: (borrowed from the wiki page)
It turns out that for any rectangular
starting position bigger than 1 × 1
the 1st player can win. This can be
shown using a strategy-stealing
argument: assume that the 2nd player
has a winning strategy against any
initial 1st player move. Suppose then,
that the 1st player takes only the
bottom right hand square. By our
assumption, the 2nd player has a
response to this which will force
victory. But if such a winning
response exists, the 1st player could
have played it as his first move and
thus forced victory. The 2nd player
therefore cannot have a winning
strategy.
And Zermelo's theorem ensures the existence of such a winning strategy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该游戏称为 Chomp。第一个玩家获胜,请参阅他的策略链接(非建设性)。
This game is known as Chomp. The first player wins, see the link for his strategy (nonconstructive).
这是一个 Python 程序,如果允许先运行,它将在大于 1x1 的主板上获胜(但对于大于 10x10 的主板来说速度相当慢):
示例运行的输出:
Here's a Python program that will win for boards larger than 1x1 if allowed to go first (but it's pretty slow for boards larger than 10x10):
And the output from a sample run:
我想到的一件事是:如果棋盘是 2x2,则第一个玩家输了:事实上,从这个棋盘来看:
有两种变化(a 和 b):
a.1)
a.2)第一个玩家输了
,或者,b。 1)
b.2) 第一个玩家输了,
此时该策略归结为迫使棋盘变成 2x2 的平方;那么,第一个进入该棋盘的人将失去它。这将引导您进入策略的第二步,主要是:
如何确保您不是进入此类配置的人?
或者,
有多少配置可以引导我获得这样的配置配置,从更大的开始?例如,从3x3棋盘开始:
有多种策略,取决于谁先开始以及有多少个无效;我建议,此时,使用遗传算法来探索最佳解决方案(这很有趣!相信我):)
A thing that comes to mind: if the board is 2x2, the first player loses: in fact, from this board:
there are two variations (a and b):
a.1)
a.2) first player loses
or, b.1)
b.2) first player loses
at this point the strategy boils down to forcing the board to become 2x2 squared; then, the first that enters that board will lose it. This will lead you to the second step of your strategy, mainly:
how to make sure you're not the one entering such configuration?
or,
how many configurations are there that will lead me to obtain such a configuration, starting from a larger one? For example, starting from a 3x3 board:
there are several strategies, depending on who starts first and how many are nullified; I suggest, at this point, using a genetic algorithm to explore the best solution (it's fun! believe me) :)
这类似于经常玩的比赛游戏(不记得名字了)
无论如何,我认为这取决于棋盘的形状谁会获胜。 2*2 对于第二个玩家来说是微不足道的失败,而 2 * N 对于第一个玩家来说是微不足道的失败,因为通过将棋盘减少到 2*2 并迫使另一个玩家玩。我认为所有方形板都是第二个玩家获胜,而矩形是第一个玩家获胜,但尚未证明这一点
编辑:
好的我认为这是对于方形板 p1 总是选择 2,2 然后平衡行和列
确保 p2 输掉,
就像 sdcwc 的评论一样,矩形板也是第一个玩家获胜。只有退化棋盘 1 * 1 才是第二位玩家获胜
This is similar to a game often played with matches (can't recall the name)
Anyway I think it depends on the shape of the board who wins. 2*2 is trivially a lose for the second player and 2 * N is trivially a lose for the first by reducing the board to 2*2 and forcing the other player to play. I think all square boards are second player wins while rectangular are first player wins, but not proved it yet
Edit:
Ok I think it is for a square board p1 always chooses 2,2 then balances the row and column
ensuring p2 loses
as with sdcwc's comment rectangluar boards are also a first player win. only the degenerate board 1 * 1 is a 2nd player win