Nim from 1, 2, 3 — and who wins
A Nim position with the outcome stated before anybody moves. The reply to every move a reader can make was computed in advance from the nim-sum, so the machine is not searching or guessing — it is following the theorem, and there is no line of play in which it loses.
6 essays call
play-nim. The drawing above is what it returns with no arguments at all; every
call below passes it something, because a placement that passes nothing draws whichever
member of the family the generator happens to default to rather than the one its essay argues
about.
The positions it draws
4 distinct positions, harvested by running this generator again at the options each essay passed it.
It plays back
The winner is named before a move is made, and every reply was worked out in advance.
-
A row of coins is already a sum — Nim from 3, 5, 6 — and who wins,
worth
0, P, 70 positions solved before the page was served. -
Nim, and the nim-sum — Nim from 1, 2, 3 — and who wins,
worth
0, P, 14 positions solved before the page was served. -
Taking from several heaps at once — Nim from 3, 5, 6 — and who wins,
worth
0, P, 70 positions solved before the page was served. -
The move that gives counters back — Nim from 1, 2, 3 — and who wins,
worth
0, P, 14 positions solved before the page was served. -
The theorem that needed none of the theory — Nim from 3, 5, 7 — and who wins,
worth
∗1, N, 88 positions solved before the page was served. -
Who moves last — Nim from 2, 2 — and who wins,
worth
0, P, 6 positions solved before the page was served.
Where it is called
Changing this generator changes every one of these figures.
Nim, and the nim-sum
Three heaps of counters, take as many as you like from one of them, and the player who takes the last counter wins. The winning condition is not a search, not a table, and not a heuristic — it is the bitwise exclusive-or of the heap sizes, and it was found in 1901.
Who moves last
The player who cannot move loses. That single convention generates the whole theory — and it produces four outcomes rather than three, because a position can be confused with zero rather than greater, smaller or equal to it.
The theorem that needed none of the theory
Bouton solved Nim completely in 1901, with an argument that mentions no value, no sum of games and no Grundy number, because none of the three existed. The argument is two closure properties and it is airtight — and run on any other game it fails at the step that does the work.
The move that gives counters back
Poker Nim adds one rule to Nim — a player may put counters back onto a heap from a private reserve. It looks as though a losing player could stall for ever. The winner is decided by exactly the same nim-sum, and the reason is the single most useful idea in the whole reduction apparatus.
A row of coins is already a sum
Everywhere else on this site a sum is several positions side by side. In a coin-turning game it is one row — each coin showing heads is a game in its own right, and the row is worth the exclusive or of them. The decomposition is inside a single picture.
Taking from several heaps at once
Moore's Nim lets a move take from as many as k heaps at a time, and the losing positions are still read off the binary columns — divisible by k + 1 rather than by two. The rule agrees with exhaustive search over 54,264 positions and never disagrees, and it decides every outcome while supplying no value at all: reading the same columns as a base-3 number gets the Grundy value right on 42 of 330 positions.
The whole library · The position index · The figures that play back