How to Play Nim
Nim is a two-player strategy game played with a small collection of objects, typically matchsticks, coins, or stones, arranged in rows. On each turn a player removes one or more objects from a single row of their choice. The simplicity of the rules belies the depth underneath: every game state is either a winning or a losing position, and working out which is which is the whole challenge.
People love Nim because it rewards thinking over chance. There is nothing hidden, no dice to roll, and no luck to blame. It works perfectly on any flat surface with whatever small objects are to hand, making it one of the most accessible abstract games in existence.
A little history
The name Nim appears in print as early as 1901, when the mathematician Charles L. Bouton published a complete mathematical analysis of the game in the journal Annals of Mathematics, also coining the name. Its origins before that are unclear: similar take-away games are documented across several cultures and centuries, but no single country of invention has been firmly established. Bouton's analysis remains the foundation for all modern study of combinatorial game theory.
Setting up
- Agree on the number of rows and how many objects each row will contain before play begins. The classic starting arrangement is four rows of 1, 3, 5, and 7 objects.
- Place the objects on the table in clearly separated rows so both players can see all rows and all counts at a glance.
- Agree on the winning condition: 'normal' play (the player who takes the last object loses) or 'misere' play (the player who takes the last object wins). Normal play is standard.
- Decide who takes the first turn. A coin flip or simple agreement works fine.
How to play
- Players alternate turns throughout the game. There are no passes.
- On your turn, choose any one row that still contains at least one object.
- Remove one or more objects from that row only. You may take as many as you like, up to and including the entire row, but you must take at least one object.
- You may not take objects from more than one row in a single turn.
- The game continues until every object has been removed from the table.
- The player who is forced to take the final object loses the game (standard normal-play rules). Under misere rules, that player wins instead.
Winning and scoring
Under standard (normal) rules, the player who removes the very last object from the table loses. Under misere rules the opposite applies and taking the last object wins. Both conventions are widely played, so agreeing the rule before starting is essential. There is no scoring across multiple rounds unless players choose to play a set number of games and tally wins, which is a reasonable way to run a longer session.
The fine points
The most common dispute is whether a player must take at least one object on their turn. The answer is yes: a turn cannot be skipped, and a player cannot declare a turn without removing something. If only one object remains in a row and a player does not want to take it, they still must take something from that row or from another row that still has objects.
A second frequent question arises when players use tokens of different sizes by accident or lose count in a row. Always agree on the starting counts and keep rows visually distinct. If a disagreement about the count occurs mid-game, both players should reconstruct the count from the objects remaining, not from memory. Any objects removed from a row that were taken in error in a previous turn cannot be reinstated: the position as it stands is the position that is played.
How to win more often
- Learn the concept of nim-sum: calculate the binary XOR of all row sizes. If the nim-sum is zero at the start of your opponent's turn, you are in a losing position with perfect play on both sides; if it is non-zero, you can always move to make it zero and take control.
- In the classic 1-3-5-7 setup, the first player wins with correct play. The key opening move is to reduce the row of 7 to 4, giving row totals of 1, 3, 5, 4 with a nim-sum of zero for your opponent.
- When only two rows remain, the winning move is almost always to equalise them, leaving your opponent two equal piles and putting them in a mirror-image losing position.
- Under misere rules the strategy is identical to normal play until only rows of one object remain. At that point, you want to leave an odd number of single-object rows rather than an even number, which is the reverse of normal play's endgame.
- Against a beginner, watch for the tendency to always take the maximum number from the largest row. Respond by consistently reducing the nim-sum to zero and the pattern will become clear.
Variations
Misere Nim
The rules are identical to standard Nim except that the player who takes the last object wins rather than loses. The optimal strategy tracks normal Nim exactly until the endgame, when the player should aim to leave an odd number of rows containing exactly one object each, rather than an even number. This single difference flips the outcome for the otherwise losing player in standard play.
Single-Row Nim (The 21 Game)
Start with 21 objects in one row. Players alternate taking one, two, or three objects per turn. The player forced to take the last object loses. The winning strategy hinges on leaving multiples of four for your opponent: 20, 16, 12, 8, 4. A quick version can be played by calling numbers aloud rather than using physical objects, making it a reliable pen-free game for any setting.
Moore's Nim (Nim-k)
Proposed by mathematician Eliakim Hastings Moore in 1910, this variant allows a player to remove objects from up to k rows per turn rather than just one. With k set to 2, players may take from one or two rows each turn. The winning strategy changes significantly: the nim-sum calculation is replaced by a modular arithmetic check base k plus 1. It plays as a noticeably different game and suits players who have already mastered standard Nim.
Turning Turtles (Coin Nim)
Replace objects with coins laid heads-up in a row. On each turn a player flips one coin to tails and may also flip any single coin to its left to either face. The game ends when all coins show tails. This version has a direct connection to standard Nim through binary representation and is a useful teaching tool for anyone exploring combinatorial game theory beyond the basics.
Nim: frequently asked questions
Can I take objects from more than one row in a single turn?
No. Standard Nim rules restrict each turn to a single row. You choose one row and remove at least one object from it. Taking from multiple rows in one turn is not permitted under any standard ruleset.
What happens if a player refuses to take any objects?
A player must take at least one object on every turn. Passing is not allowed. If a player refuses, they forfeit the game.
Does it matter who goes first?
Yes, significantly. In the classic 1-3-5-7 setup the first player wins with perfect play. In any setup where the starting nim-sum is zero, the second player holds the advantage. Knowing the theory lets you choose whether to go first or second once you have seen the starting arrangement.
What is the nim-sum and do I need to know it to play?
The nim-sum is the binary XOR of all row sizes and it identifies whether a position is winning or losing with perfect play. You do not need to know it to enjoy the game, but learning it will make you very difficult to beat.
What age is Nim suitable for?
The basic rules can be grasped by children from around age 6 upwards, especially in the simple single-row version. The deeper mathematical strategy will engage older children and adults. It is a genuinely good cross-age game because the gap in understanding creates a real and interesting skill gap.
How many players can play Nim?
Nim is a two-player game. With three or more players the mathematical theory breaks down and the game loses much of its strategic clarity. If you want a group activity, run a knockout tournament with paired matches.
Is there a difference between normal and misere Nim?
Yes. In normal Nim the player who takes the last object loses; in misere Nim that player wins. The optimal strategies are almost identical except in the very final stage of the game, where the correct move flips. Always agree on which version you are playing before the game starts.
Can Nim end in a draw?
No. Every game of Nim ends with one player taking the last object, so there is always a winner and a loser. A draw is not possible under any standard ruleset.