Players alternate removing stones; last stone taken wins. The mover loses iff the Nim-sum (XOR of pile sizes) is 0. Watch the winning move zero the Nim-sum and play a full game.
step 0
Piles (stones) — move A to play
Nim-sum decides everything. A move targets the pile sharing the Nim-sum's top set bit.
stone being removed target pile
Nim-sum in binary (XOR of pile sizes)
When Nim-sum X ≠ 0, set some pile p to p XOR X (legal because p XOR X < p), making the new Nim-sum 0.
Press Step to begin. We compute the Nim-sum, decide the winner, and play optimal moves until the last stone is taken.
Self-contained visualization. Normal-play Nim (last stone wins); counting is exact (no modulus needed).
The optimal player always re-zeroes the Nim-sum; the losing player is forced to un-zero it.
See junior.md and professional.md for the proof of Bouton's theorem.