Game rules
Nim Rules
Nim is the rare table game that has been completely solved and published, which means a player who learns one piece of arithmetic can win every single game they are mathematically entitled to win — and can tell, before touching anything, whether they are entitled to win at all. That fact makes it unusual company for the rest of the pencil-and-paper shelf: most folk games survive because nobody has cracked them, and Nim survives despite having been cracked in 1901.
What You Need and How to Lay It Out
Nim needs objects that can be removed and rows to arrange them in. Coins, matchsticks, poker chips, bottle caps, or pencil marks that get crossed off all work identically. Arrange them into several rows of differing sizes — three rows is the usual minimum for a game with any depth, and the row sizes matter far more than the total count.
The most recognisable arrangement is four rows of one, three, five and seven, which is the layout the 1961 film Last Year at Marienbad put in front of a general audience and which is still sometimes called the Marienbad arrangement because of it. It is worth knowing that this specific layout is a trap for whoever moves first: under standard rules, a player who moves second and plays correctly wins it every time. If you want the opening player to have the advantage, change the row sizes.
Taking a Turn
On your turn you choose one row and remove any number of objects from it, from a single object up to the entire row. You may not take from two rows in the same turn, and you may not pass — every turn removes at least one object. Play alternates until the objects run out.
That is the whole rulebook. Nim's difficulty lives entirely in the win condition and the arithmetic underneath it, not in the moves themselves.
The Two Win Conditions, and Which One You Are Playing
This is the single thing to settle before the first move, because both versions are legitimate and they reward opposite instincts:
- Normal play — the player who takes the last object wins.
- Misère play — the player who takes the last object loses.
Neither is more official than the other. They are two named variants of equal standing, and the strategy for one will lose you the other, so "we never said which" is not a recoverable position halfway through a game.
The Nim-Sum: the Arithmetic That Solves It
Charles L. Bouton, then at Harvard, published the complete theory in the Annals of Mathematics in 1901 under the title "Nim, A Game with a Complete Mathematical Theory," and in doing so effectively opened the field now called combinatorial game theory. His result is short enough to use at a table.
Write each row's count in binary and add the columns without carrying — a column with an even number of ones scores zero, a column with an odd number scores one. The result is the nim-sum.
- If the nim-sum is zero, the player about to move is losing against correct play.
- If it is anything other than zero, the player about to move is winning, and can force it.
The winning move is always the one that hands your opponent a nim-sum of zero. Take rows of three, four and five: in binary that is 011, 100 and 101, which combine to 010 — that is, two. Non-zero, so whoever moves first wins. The move that does it is taking two from the row of three, leaving one, four and five: 001, 100 and 101, which cancel to zero. From there, every move your opponent makes breaks the zero, and every reply you make restores it, until they run out.
The misère version follows the same arithmetic almost the whole way, and diverges only at the very end: once the position contains no row with two or more objects left, you switch to leaving your opponent an odd number of single-object rows instead of an even one. That one late adjustment is the entire difference.
The Arguments Nim Actually Produces
Because the rules are so short, disputes here are never about legality of a move — they are about what was agreed beforehand and what counts as a row.
Far and away the most frequent is discovering mid-game that the two players assumed different win conditions, which typically surfaces when the position is down to its last few objects and one player suddenly plays to avoid taking rather than to take. There is no ruling that resolves this after the fact; the honest fix is to replay the game.
The second recurring friction is physical rather than procedural: with loose objects like coins or matchsticks, players nudge rows together or apart and then disagree about whether two clusters were ever one row. Crossed-off pencil marks in ruled lines avoid this entirely, which is a real argument for playing it on paper rather than with objects.
A third, milder one is whether taking an entire row in a single turn is allowed. It is, explicitly — "any number" includes all of them, and forbidding it produces a different game with a different solution.
Where the Game Came From
Bouton named it and solved it, but he did not invent it. Games of this shape are considerably older than his paper, with European references reaching back to the 16th century and a widely repeated attribution of its origins to China that is genuinely uncertain rather than established — it is repeated far more confidently than the evidence supports, and the honest position is that its prehistory is not settled.
Its modern life is better documented. In 1940 Westinghouse exhibited the Nimatron at the New York World's Fair, a relay-based machine built to play Nim against visitors — one of the earliest purpose-built game-playing machines put in front of the public, and a direct consequence of the game having a known perfect strategy that a machine could be wired to follow.
Questions That Come Up Once People Realise It's Solved
If it's solved, is there any point playing it? Between two players who both know the nim-sum, no — the winner is determined by the opening position. It stays interesting when only one player knows the method, or as a way of teaching binary arithmetic that has a visible payoff.
Can a game be set up so the first player cannot possibly win? Yes, and it is easy: any arrangement whose nim-sum is already zero. Two equal rows is the smallest example, and the one-three-five-seven layout above is the famous one.
What happens with only one row? It collapses into a non-game — the first player takes everything and wins under normal play. Single-row games only work as the "take 1 to 3 objects" variant, which caps how much you may remove per turn and is a genuinely different puzzle.
Does the player who moves first choose the win condition? No convention gives them that right. Agree it before setup, the same way you would agree the row sizes.
Nim sits alongside Tic-Tac-Toe among the games that reward being told the answer once, and next to Sprouts among the pencil games with real mathematics behind them. Both live on the pen-and-paper hub, and it works well as a two-player filler when you want something that fits on the back of a receipt.