What the Game of Nim Can Teach You About Endgame Counting
Nim is the simplest game where counting alone determines the winner. Learning to think in Nim terms — piles, parity, forced moves — builds the exact counting intuition that decides dots and boxes endgames.
Nim is embarrassingly simple to explain and famously hard to play well against someone who knows the trick. A few piles of stones sit on the table. Two players alternate turns, and on each turn a player removes any number of stones — one or all of them — from a single pile. Whoever takes the last stone wins. That is the entire rule set. No board, no capturing, no spatial reasoning at all.
And yet Nim is one of the most important teaching tools in combinatorial game theory, because it strips a very specific skill down to its purest possible form: counting your way to a forced win, with zero tactical distraction to hide behind. Dots and boxes has that same skill buried inside its endgame — parity counting, chain-length arithmetic, forced sacrifices — but it is buried under grid geometry, chain shapes, and dozens of other simultaneous considerations. Nim lets you practice the counting instinct in isolation, the same way a batting cage lets you practice a swing without the pressure of a real pitch.
This is not a general tour of combinatorial game theory — that ground is covered in the mathematics of dots and boxes and graph theory and dots and boxes. This post has one narrow job: use Nim specifically to build the counting intuition that wins dots and boxes endgames.
The single-pile case: the seed of all endgame counting
Start with the simplest possible version of Nim: one pile, and a rule that each player must remove between one and three stones per turn. Whoever takes the last stone wins.
Play this out and the pattern jumps out immediately. If the pile has 4 stones and it is your turn, you lose with correct play from your opponent — whatever you take (1, 2, or 3), your opponent takes the rest and wins. If the pile has any other number from 1 to 3, you win immediately by taking it all. If the pile has 5, 6, or 7, you can always reduce it to exactly 4 and hand your opponent the losing position.
The pattern is: positions where the pile count is a multiple of 4 are losing for the player to move; every other count is winning. This is the whole game, solved, with one sentence. There is no tactics, no cleverness, no reading ahead multiple branches — just counting the pile and checking it against a fixed rule.
This is exactly the kind of clean, countable structure that shows up inside a dots and boxes endgame once you strip away the visual complexity of the grid. The number of remaining safe moves on the board, discussed at length in parity counting during live games, behaves like a single Nim pile: what matters is not the specific lines still available, but the count of them, and whether that count is even or odd relative to whose turn it is.
Why "who takes the last one" maps onto "who is forced to open"
In single-pile Nim, the loser is whoever is forced to take the last stone and leave nothing — no wait, more precisely, the loser is whoever cannot make a move that avoids leaving their opponent in a winning spot; the exact framing depends on the variant, but the structurally important idea is this: the number of remaining "neutral" actions determines, by pure parity, who is forced into the bad position first.
In dots and boxes, the neutral actions are safe moves — lines that do not open a chain. Once safe moves run out, whoever is on move is forced to open a chain (the equivalent of being forced into the losing Nim position). The number of safe moves available on a given grid is a fixed, countable quantity determined by the board's dimensions, exactly like a Nim pile's starting size is a fixed quantity chosen before play begins.
Nim teaches you to ask "how many neutral moves are left, and whose turn will it be when they run out?" That is precisely the question that decides who opens the first chain in dots and boxes.
Practicing this question in Nim, where there is nothing else to think about, trains the specific mental habit of counting remaining moves rather than evaluating them one at a time — a habit that transfers directly to reading a dots-and-boxes board and asking the same question about its safe-move count.
Multi-pile Nim and the idea of combining separate counts
Standard Nim uses several piles at once, and the winning strategy involves a more advanced tool — the XOR-based "Nim-value" of the combined piles — that is genuinely more mathematically involved than anything a casual player needs. But the idea underneath multi-pile Nim, even without the full XOR machinery, is directly useful: a position made of several independent regions can be analyzed by combining a count for each region separately, rather than by re-evaluating the whole position from scratch.
This is exactly how a strong dots and boxes player reads an endgame with multiple chains and loops on the board simultaneously. Rather than trying to visualize the entire remaining board as one blob, they count each chain's length separately — this one is 3, that one is 5, that loop is 4 — and reason about the combination: how many long chains are there, is that count even or odd, and does that favor me or my opponent given who is on move? This chain-counting approach is the practical, non-XOR version of multi-pile Nim thinking, and it is formalized for dots and boxes specifically as the chain rule, which gives a target parity for the total count of long chains plus loops that favors one player over the other.
Nim will not teach you the chain rule's exact formula — that is specific to dots and boxes' structure. What Nim teaches, more valuably, is the habit of decomposing a complex position into separately countable pieces before trying to evaluate it as a whole. That habit, once built, makes the chain rule feel like an obvious application of something you already know how to do, rather than an arbitrary formula to memorize.
The forced-move feeling, isolated
Anyone who has played a losing endgame in dots and boxes knows the specific, uncomfortable feeling of realizing, several moves before it happens, that there is no way to avoid opening the next chain. Every safe move has been used, every alternative has been counted, and the forced move is simply coming, whether you like it or not.
Nim produces this exact feeling in its purest form, because there is nothing to distract from it. When you are looking at a pile of 4 stones (in the take-1-to-3 variant) on your turn, you know with total certainty that you are going to lose, and you know it several moves before the game physically ends. There is no tactic to save you, no clever alternative line — the count has already decided the outcome, and all that remains is playing it out.
Sitting with that feeling in Nim, where it cannot be argued with or wished away, builds a valuable emotional calibration for dots and boxes: recognizing early that a chain-count parity has gone against you, and adjusting your plan (perhaps sacrificing early to try to shift the parity, a technique covered in the art of sacrifice) rather than continuing to play as though the position were still contested. This connects closely to zugzwang and forced moves in the dots-and-boxes endgame — Nim is, in effect, zugzwang with every irrelevant detail removed.
A concrete Nim drill for dots and boxes players
Here is a specific exercise that transfers the Nim counting habit directly into dots and boxes practice.
- Play ten games of single-pile Nim (take 1-3 stones, last stone wins) against a friend or solo, starting from different pile sizes each time. Before each turn, state out loud whether the current pile count is a winning or losing position for the player to move, before making your move. Do this until it is instant.
- Move to two-pile Nim with small piles (under 10 stones each). Before each turn, try to state whether the combined position favors you, without formally computing the XOR — just reason about it as best you can. This builds the habit of holding two counts in mind simultaneously.
- Return to a dots and boxes endgame position — set one up by hand with two or three regions left. Before making a move, count the safe moves remaining in each region separately, sum them, and state whether the parity favors you as the player to move.
- Check your read against actual play. Play the position out and see whether your parity call predicted the correct outcome.
Players who run this drill report that step 3 gets noticeably faster and more reliable after doing steps 1 and 2 first — the Nim practice appears to build a transferable counting reflex, not just Nim-specific skill.
Where the analogy breaks down
It is worth being honest about the limits here. Dots and boxes chain counting is not literally isomorphic to Nim — the chain rule's parity target depends on which player moved first, on whether the regions in question are chains or loops (loops cost twice as much to double-cross, as covered in the double-cross technique), and on the specific value of each region rather than just its count. Nim's take-any-number rule is also more flexible than the constrained moves available inside a dots and boxes chain. If you want the precise, dots-and-boxes-specific version of this analysis, the chain rule and parity-counting posts referenced above are where the actual formulas live.
Nim's value here is not that it directly computes anything for you — it is that it trains, cheaply and with total clarity, the underlying cognitive habit that dots and boxes counting depends on: reducing a complicated position to a small number of counts, and reasoning about parity rather than trying to visualize every future move.
Summary
Nim strips away everything a real game usually has — geometry, tactics, bluffing, tempo tricks — and leaves only the one skill that decides so many dots and boxes endgames: counting correctly and knowing what the parity of that count means for who is forced to move badly first.
Learn to solve Nim instantly, and you are training the exact muscle that reads a dots-and-boxes endgame — not the specific formula, but the habit of reducing a messy board to a small set of counts before deciding anything.
Play it enough that the counting becomes reflexive, then bring that reflex back to the grid. The chain rule and parity counting will stop feeling like memorized formulas and start feeling like the obvious next step.