🔍

首页Home › 小游戏Games

🪨 取石子Nim

在线取石子(尼姆游戏):桌上有几堆石子,你和电脑轮流从任意一堆里拿走任意多个(至少 1 个)。普通模式拿到最后一个石子的人赢,反常模式拿到最后一个的人输。可选 3~5 堆、谁先手和电脑难度,困难模式的电脑会用异或必胜策略,看看你能不能找到破解方法。Nim online: there are several rows of stones and you and the computer take turns removing any number (at least one) from a single row. In normal play whoever takes the last stone wins; in misère play the last stone loses. Choose 3 to 5 rows, who goes first and the difficulty — the hard computer plays the perfect XOR strategy, so can you beat it?

· 胜/负W/L 0 / 0

点一个石子,会选中它和它右边的所有石子,再点“拿走”(或再点一次同一个石子、按回车)确认。Tap a stone to select it and every stone to its right, then press Take (or tap the same stone again, or press Enter).

玩法说明与常见问题How to play & FAQ

「取石子」怎么玩?How do I play Nim?

每回合只能从一堆里拿,至少拿 1 个,最多可以把整堆拿完。取胜的秘诀是“异或”:把每堆石子数写成二进制,按位异或,如果结果为 0,当前要走的一方就处在必败局面。所以你每次都要设法拿完后让各堆的异或值变成 0。反常模式几乎一样,只是在只剩一些 1 个石子的堆时要反过来考虑。Each turn you take from one row only — at least one stone, up to the whole row. The secret is XOR: write each row's count in binary and XOR them together; if the result is 0, the player about to move is losing. So always leave the XOR at 0 after your move. Misère play works the same way until only rows of one stone remain, when you flip the goal.

先手一定能赢吗?Does the first player always win?

不一定。如果开局各堆的异或值是 0,先手方在对手不失误的情况下必输;否则先手方有必胜走法。No. If the rows XOR to 0 at the start, the first player loses against perfect play; otherwise the first player has a winning move.

取石子靠运气吗?Is Nim a game of luck?

完全不靠运气。取石子是经典的数学策略游戏,除了开局堆数随机,每一步都由双方自己决定,纯属锻炼思维的娱乐。Not at all. Nim is a classic mathematical strategy game — apart from the random starting rows, every move is a choice, and it's purely a brain teaser.

「取石子」免费吗?需要下载吗?Is Nim free? Do I need to download anything?

完全免费,无需注册、下载或安装,打开网页就能玩,手机、平板和电脑都支持;游戏完全在你的浏览器本地运行,不会上传任何数据。It is completely free with no sign-up, download or install — just open the page on a phone, tablet or computer. The game runs entirely in your browser and nothing is uploaded.

相关工具Related tools

💣 数字炸弹Number Bomb🫘 播棋(曼卡拉)Mancala🔲 点格棋Dots and Boxes⭕ 井字棋(人机对战)Tic-Tac-Toe vs Computer🧮 24点24 Game🔐 猜颜色密码Code Breaker🔴 四子棋Four in a Row📍 孔明棋Peg Solitaire

← 全部工具All tools