Nim
Select stones from one row, then press Take
- Category
- Board
- Players
- 1
- Controls
- Tap
- Type
- Solved game
- Loads
- Instant
Controls
| Tap stones | Select any number from a single row. |
| Take | Confirm your move. |
| New game | Reset the rows. |
Select stones from one row, then press Take
| Tap stones | Select any number from a single row. |
| Take | Confirm your move. |
| New game | Reset the rows. |
Nim gives you several rows of stones. On your turn you take as many as you like from a single row, and the player who takes the last stone wins. It looks like a game of instinct and is in fact completely solved mathematics, which is exactly what makes it interesting.
The solution involves a piece of arithmetic almost nobody would guess: write each row's count in binary and combine them with exclusive-or. If the result is zero, the position is losing for whoever moves next. Nim is the foundation of an entire branch of game theory, and every other similar game reduces to it.
Look for symmetry. If you can leave two rows with equal counts and nothing else, you win: whatever your opponent takes from one row, you take the same from the other, and you will inevitably take the last stone.
Learn the losing positions. Two equal rows, or the classic one-two-three arrangement, are traps for whoever must move. Steering the game into one of those shapes and handing it over is how strong play works.
The real rule is the binary one. Convert each row count to binary, exclusive-or them together, and aim to leave a total of zero. It sounds abstract but with three or four small rows you can do it in your head with practice.
Take a whole row when it helps. Beginners take one stone at a time out of caution, but clearing an entire row is often exactly the move that produces a balanced, losing position for your opponent.
Yes, in this version taking the final stone wins. Some variants reverse that, which changes the strategy entirely.
Yes. Nim is completely solved, and whoever is in a winning position can always force the win with correct play.
Write each row count in binary and combine them with exclusive-or. Aim to leave the total at zero after your move.
No, only from a single row per turn, but you can take as many from it as you like.
No. Nim runs entirely inside this page, so it starts the moment the page opens. There is nothing to download, no plugin, and no account to create.