The nim-value of a position of a finite normal-play impartial game makes it equivalent to a nim-heap. To find the nim-value (also called the Sprague-Grundy number), take the mex of the nim-values of the possible moves. In the game of nim, the nim-value can also be found by writing the number of counters in each heap in binary, adding corresponding binary digits (mod 2), and interpreting the resulting binary string as a decimal number.
Under normal play, a position of nim-value 0 is safe for the player who has just moved, since the player next to move loses against correct
play. A position of nonzero nim-value is unsafe for the
player who has just moved, since the next player can force a win. With two heaps
in the game of nim, the only safe positions are .
With three heaps (assuming nim-heaps of maximum size 7), the safe positions are (1,
2, 3), (1, 4, 5), (1, 6, 7), (2, 4, 6), (2, 5, 7), (3, 4, 7), and (3, 5, 6). For
four nim-heaps of maximum size 7, the safe positions are
,
, and (1, 2, 4, 7), (1, 2, 5, 6), (1, 3, 4,
6), (1, 3, 5, 7), (2, 3, 4, 5), (2, 3, 6, 7), and (4, 5, 6, 7). The position (1,
3, 5, 7) corresponds to the beginning state for the game Marienbad,
which is therefore an unfair game.