Nim
Three piles of stones. Tap stones to take them from one pile. Whoever takes the last stone wins.
Moves so far
How it works
You and the computer take turns. On your turn you choose one pile and take one or more stones from it, never from two piles. Whoever takes the last stone wins.
The computer is a short fixed rule, not a guess. Write each pile size in binary and add the columns without carrying (this is called the nim-sum). If the total is zero, the player about to move is losing against perfect play. If it is not zero, there is always one move that makes it zero, and that move wins.
The computer always plays that move when it has one. So if you start from a position where the nim-sum is not zero and you make the right first move, the computer is the one in trouble, and a perfect player would win from there. If you make a wrong move, or the start is already lost for you, the computer cannot be beaten. When the computer has no winning move, it takes one stone from the biggest pile and keeps playing.
The line under the board tells you after every move who holds the win. Starting piles are 3, 4 and 5, and the first player can win with the right move: take 2 from the first pile.
| Piles | Nim-sum | Mover |
|---|---|---|
| 1, 0, 0 | 1 | wins |
| 1, 1, 0 | 0 | loses |
| 1, 2, 3 | 0 | loses |
| 1, 4, 5 | 0 | loses |
| 3, 4, 5 | 2 | wins |
Your moves are never saved or sent. A reload starts a fresh game.