## Nim Games

9-12
Standards:
Math Content:
Number and Operations

Nim is any type of "take‑away game" in which players alternately remove counters, and the player who takes the last counter wins. However, there are infinitely many versions of Nim. This applet allows players to challenge the computer in the games of Static Nim, Identity Nim, and Doubling and Tripling Nim.

To select a different game or to use different parameters, indicate the Game, Strategy, and Initial Pile Size (and, for Static Nim, the Maximum Move). The options are as follows:

1. Game Type
• Identity Nim: On each turn after the first, a player can only take up to as many coins as were taken by the other player on the previous turn.
• Doubling and Tripling Nim: Similar to Identity Nim, a player can only take up to twice (or three times) as many as were taken by the other player on the previous turn.
• Static Nim: On each turn, a player can only take up to the number of counters designated by the Maximum Move.

2. Strategy
• Random: The computer randomly selects how many counters to take on a turn.
• Optimal: The computer uses the best possible strategy to determine how many counters to take on a turn.

3. Initial Pile Size: Can be any value from 3 to 50.
4. Maximum Move (for Static Nim only): Can be any value from 1 up to one fewer than the Initial Pile Size.
 A record of the game will be kept along the right side. The blue number at the top of the record indicates the initial pile size. The green numbers indicate how many counters remain after each of your turns; the red numbers indicate how many counters remain after each of the computer's turns. The +/- signs indicate whether you (+) or the computer (-) has the advantage after each move.This record can be used to analyze the game. For what numbers do you have the advantage? For what numbers does the computer have the advantage?

Select Static Nim as the game type, choose Random strategy, set the Initial Pile Size to 21, and set the Maximum Move to 4. Play the game once or twice. Then, change to Optimal strategy, and play the game several times.

• What do you notice about the moves that the computer makes?
• What is the pattern in the numbers on which the computer lands at each turn? How do the numbers in that pattern relate to the Initial Pile Size or to the Maximum Move?
• If you are having difficulty seeing any patterns, reduce the Initial Pile Size and consider a shorter game. What do you notice now?
• What strategy can you use to guarantee that you will win?

Conduct a similar investigation for Identity, Doubling, and Tripling Nim.

• Can you determine the optimal strategy that the computer uses to win?