Combinatorial game theory is the study of two-player games where players alternate moves, every move is visible, and nothing is left to chance, such as Nim, Go endgames, or Dots and Boxes. Its goal is to work out who wins with perfect play, and how, by giving each position an algebraic value.
A combinatorial game is a two-player game of perfect information with no chance moves. Players, called Left and Right, alternate turns, and every play ends after finitely many moves. Under the normal play convention, the player who cannot move loses. A game is impartial if both players always have the same moves available; otherwise it is partizan. In general, every position falls into one of four outcome classes: N (the next player to move wins), P (the previous player wins), L (Left wins no matter who starts), or R (Right wins no matter who starts). In an impartial game under normal play, classes L and R cannot occur, so every position is either N or P. The Sprague–Grundy theorem says each such impartial position is equivalent to a single Nim heap whose size is its Grundy value.
Worked Example
Problem: Two piles hold 4 and 7 counters. On your turn, you remove 1 or 2 counters from one pile. The player who cannot move loses. Should you move first or second?
Step 1: Find the Grundy value of a single pile of n counters. A pile of 0 has no options, so its value is 0. Each larger pile has options n − 1 and n − 2, so take the mex of their values. The values repeat 0, 1, 2, which matches n mod 3.
nG(n)0011223041526071 Step 2: The two piles form a disjunctive sum, so combine their values with the nim-sum.
G(4)⊕G(7)=1⊕1=0 Step 3: A value of 0 means a P-position, so the second player wins. The strategy is to always move back to nim-sum 0. For example, if your opponent takes 1 from the 7-pile, the piles are 4 and 6. You then take 1 from the 4-pile, which leaves 3 and 6.
G(3)⊕G(6)=0⊕0=0 Answer: Move second. The position (4, 7) has Grundy value 0, so whoever moves first loses against perfect play.
Why It Matters
Combinatorial game theory gives exact winning strategies for games that would take a computer far too long to search move by move. Berlekamp used it to solve late-stage Go endgames, and its sums of games led Conway to the surreal numbers. It also shows up in algorithm design courses and programming contests, where Grundy values solve many game problems quickly.
Common Mistakes
Mistake: Adding Grundy values with ordinary addition. In the example, 1 + 1 = 2 would wrongly suggest the first player wins.
Correction: Combine game components with the nim-sum (binary addition without carrying), so 1 ⊕ 1 = 0. Also note that mex and the nim-sum apply only to impartial games under normal play. Partizan games need Conway's more general values.