GamesNovatory/Competition/Tokens/Nim

Origin of the Game
This seems to be an old Chinese game which has remained quite popular in France. It is more difficult than Fan-Tam, and capable of confusing adults for quite a while.

Description
The game is played with 16 tokens disposed in 4 rows,
     of, respectively, 7, 5, 3, and 1.

The Rules
1. Each player, in turn, takes any number of tokens from only one row,
     (including the possibility of the complete row).
2. The player who picks up the last token loses.

Mathematics
There are really no mathematics here, it is more a question of learning all the losing positions
          which we will analyse later.
     However when one examines all these losing positions,
          one realizes that the second rule should logically be changed, and that
               the player who picks up the last token should win.

Strategy
1. The first player, being from the start in a losing position, is at a disadvantage,
      and will always lose if both are good players.
2. The second player should always lead the first from one losing position to another.

Teaching children to play the game
Let's find an efficient way of learning all the losing positions.
1. THE QUIET OPENING
The opponent starts with the losing opening position 7531 and takes only 1 token,
the answer being to also take only 1 token from another row,
(producing one of the losing positions 752 / 743 / 7421 / 653 / 6521 / 6431).
The opponent again takes only 1 token from an untouched row,
the answer being to also take only 1 token from the last untouched row.
(inevitably producing the losing position 642 with 1 token removed from each row).
2. TWO DOUBLES
When 2 tokens are removed from the same row,
the next losing positions are often one of 5511 / 4411 / 3311 / 2211.
3. THE 3-ROW "SPECIALS"
(which all end in "1") 541 / 321 / 111.
4. ONE DOUBLE
At the end of the game, the simpler losing positions required will often be
55 / 44 / 33 / 22 (careful after the 22 position !).

At first, one of the best tactics is to distribute these 4 categories between 4 children
(or groups of children)
and then play against them, letting them act as a team, constantly consulting each other.
When players have learned the four categories of losing positions,
they can individually play against each other, the second player always winning.
They are now ready to tackle adults and show off !
If the adult wants to start, pounce on his first mistake !

Older children can evidently discover the losing positions by themselves.

The losing positions
The only way to find a formula for these losing positions
          is by the visual, geometric, examination of their binary code.
     The addition of each individual column must be binary (0).

1 0 1
1 0 1

1 0 0
1 0 0

1 1
1 1

1 0
1 0

1
1



          All the Doubles will evidently produce this result -
                    each column having either two "0"s or two "1"s,
               5-5, 4-4, 3-3, 2-2, 1-1.

1 0 1
1 0 1
1
1

1 0 0
1 0 0
1
1

1 1
1 1
1
1

1 0
1 0
1
1

1
1
1
1



          And the double Doubles as well -
                    each column having either two or four "1"s,
               5-5-1-1, 4-4-1-1, 3-3-1-1, 2-2-1-1, 1-1-1-1.
It becomes increasingly evident that the winner should pick up the last token.

1 1
1 0
1




1 0 0
1 1
1

1 0 1
1 1
1 0






It seems that one (or even both) of the elements of a double,
          can be broken down and spread over 2 lines,
               only on condition that the addition of this break-down
                    does not produce any carry-over.
     If the double 3-3 is broken down into 3-2-1
          the addition of the 2 and the 1 does not produce a carry-over
               because there is a 0 in the 2 in which the 1 can place itself.
     However, a 4-4 could NOT break down intor 4-3-1, or a 5-5 into 5-3-2,
               because the 3-1 and the 3-2 will each produce a carry-over when they are added.
          This carry-over is exactly what must be removed from the large (first) row
                    to produce the next losing position -
               2 in the 4-3-1, and 4 in the 5-3-2.

1 0 1
1 0 0
1

1 1 0
1 0 0
1 0

1 1 1
1 0 0
1 1

1 1 1
1 0 0
1 0
1






5-4-1, 6-4-2, 7-4-3, and even 7-4-2-1,
          with the 3 broken down into 2 and 1,
     work out perfectly with no carry-overs.

1 1 1
1 0 1
1 0

1 1 0
1 0 0
1 1
1

1 1 0
1 0 1
1 0
1

1 1 0
1 0 1
1 1

1 1 1
1 0 1
1 1
1



7-5-2,
6-4-3-1, making a 7-7 with 6 and 1 together and 4 and 3 together,
6-5-2-1, another 7-7 with 6 and 1 together and 5 and 2 together,
          and even 6-5-3, with the 2 and 1 merged into a 3,
     also work out perfectly with no carry-overs.
The opening 7-5-3-1 is, as expected, a special case, a combination of -.
     1-1-1-1 in the right column, and
     6-4-2 in the first 2 columns.