| |||||||||
For information on NIMH, see National Institute of Mental Health
Nim is a two-player game in which players take turns removing objects from heaps, one or more objects at a time but only from a single heap. The players are forced to take at least one object, and are allowed to take the whole heap. In the normal version, the player to take the last object wins; in the misère version of the game, the player to take the last object loses. It is this version that is most commonly played in practice. The name was invented by C. L. Bouton of Harvard University, who also developed the complete theory of the game about 100 years ago, but the origins of the name were never explained. The name is probably derived from German nimm! meaning "take!". Some people have noted that turning the word NIM results in WIN, but this is probably just a coincidence.
Nim is now used as a simple illustration of the Sprague-Grundy theorem.
A version of this game is played in Alain Resnais' movie L'année dernière à Marienbad.
A typical normal game starts with heaps of 3, 4 and 5 objects:
Nim has been mathematically solved for any number of initial heaps and objects; that is, there is a defined and guaranteed way to win for one of the players, be it the normal or misère game. In a typical misère game that starts with heaps of 3, 4, and 5, player 1 will win with optimal play.
The key to the theory of the game is the binary digital sum of the heap sizes, that is, the sum (in binary) neglecting all carry overs.
An equivalent procedure, which can be performed mentally, is to express the heap sizes as a sum of powers of 2, cancel pairs of equal powers, and then add what's left:
In the normal game, the strategy is finishing every move with a digital sum of 0, which is always possible if it is different from 0 (in the example above, it suffices taking 2 objects from heap A). If the digital sum is 0 and you must make a move, there is no way you can win the game (assuming the other player is a perfect player). The strategy in the misère game is just like playing normally, except you subtract one from a heap of your choice in the analysis.
So if we have stacks of 3,4,5 like before, we lie to ourselves and pretend that it's 3,3,5, taking one away from B.
Now here, C was the one we artificially subtracted from, so we have to pick another one. You can think of it as that we pretend you took one from another stack, say A.
But you see, since A was our artificial stack, it still looks like 1,0,0, and they have to make the last move.