No finished games in this game yet
← All games
🔒 Trainer: find the winning moveopens after your first finished game

A position where the side to move — you — is winning. Take stones so that the XOR of the heaps becomes zero. Click the stone you want to take down to.

solved in a row: 0

Nim against the computer

Play Nim online against the computer. Solved in 1901: the machine does not search, it knows the winning move. Can you find it too? Free, no sign-up.

What this game is

Nim is the one game on this site where the computer does not search at all. It knows the answer as a formula.

Charles Bouton published the solution in 1901, half a century before the first game program. Write the heap sizes in binary, add them column by column without carrying — that is a bitwise XOR. If the result is zero, the player about to move loses against correct play. If it is not zero, there is a move that makes it zero, and whoever finds it wins.

Rules

Why the levels differ so much

On the middle level the computer plays the formula perfectly — but the starting position is random, and a random position usually has a non-zero XOR. That means the winning side is you, if you find the right move every single turn.

On the top level the start is rigged: the XOR is zero before your first move. From there nothing can be done — every move you make breaks the balance, and the computer restores it. This is the whole point of a solved game: the machine is not thinking faster, it is holding a theorem you do not have. Which is why the trainer above matters more than the score.

Where to go from here