Nim
Take as many stones as you like from one pile each turn, and read the rule before you play: does the last stone win or lose? Free · no download · works on phone & desktop
tap a piece to move.
Tap a stone to remove it along with every stone above it in that pile, and check the rule line to see whether taking the last stone wins or loses.
About Nim
Nim is a classic two-player strategy game played with a few piles of stones. On each turn you remove stones from a single pile, and the game ends when the last stone is taken. Games of this kind have been played for centuries. In 1901 the mathematician Charles L. Bouton gave Nim its name and published a complete winning strategy based on binary numbers, which made it one of the founding puzzles of combinatorial game theory. Nim was also one of the first games ever played by a machine: the Nimatron was shown at the 1940 New York World's Fair.
How to play
- The board shows several piles of stones. Check the rule line first: under normal rules, whoever takes the last stone wins, and under misère rules, whoever takes the last stone loses.
- On your turn, pick exactly one pile and remove at least one stone from it. You can take as many stones as you like from that pile, including the whole pile.
- To move, tap a stone. That stone and every stone above it in the same pile are removed.
- Players take turns until no stones are left. The rule line decides who wins.
- Play against the computer on Easy, Medium or Hard, or play with a friend on one device. Use Undo to take back a move and Hint when you get stuck.
Tips & strategy
- Write each pile size as a sum of 1, 2, 4 and 8. After your move, each of these values should appear an even number of times across all piles. This is called leaving a nim-sum (XOR) of zero.
- Two equal piles are a winning position for the player who just moved. If you leave your opponent two equal piles, copy every move they make on the other pile.
- In misère games, play exactly as in normal Nim until only piles of a single stone are left. At that point, leave an ODD number of one-stone piles for your opponent.
Frequently asked questions
How do you play the Nim game?
Players take turns removing stones. Each turn you must take at least one stone, and all of them must come from the same pile. On this board, you tap a stone to remove it along with every stone above it in that pile.
What are the rules of Nim?
There are two common versions. In normal Nim, the player who takes the last stone wins. In misère Nim, the player who takes the last stone loses. The board always shows which rule applies to the current game.
Is there a winning strategy for Nim?
Yes. Find the nim-sum by combining the pile sizes with binary XOR. If the nim-sum is not zero, a move exists that makes it zero, and the player who keeps it at zero wins. In misère Nim, the only change comes at the end, when you should leave an odd number of one-stone piles.
Can I play Nim against the computer?
Yes. Choose Easy, Medium or Hard. On Hard, the computer punishes every mistake, so check the nim-sum before each move.
Can two people play Nim on one device?
Yes. Pick the two-player mode and take turns on the same screen. Undo and hints work in this mode too.
Do I need to download anything to play Nim online?
No. The game runs free in your browser on desktop, tablet and phone.