Department of Mathematics, Statistics
and Computer Science
Wim Ruitenburg's Fall 2003 MATH025.1001, 0827
The Games of Nim and Hex
We are familiar with all kinds of board games and the like.
Chess, checkers, go, and similar games are examples of two-player games with
`full information.'
Both players can see the full game situation, contrary to many card games
where we may not know the hand of cards held by the other player(s).
Below are two examples of two-player games with
`full information' where one of the players must win.
This must be so because both games are finite, and because each outcome is
either a winning situation for player one, or a winning situation for player
two.
- The game of Nim.
Two players face a finite number of piles of finitely many matches.
The players alternatingly must take one or more matches from one of the piles.
The game ends when the last match(es) have been taken.
The player who takes the last match(es) wins.
In other words, the player who can take no matches loses.
Question: Is there a winning strategy for one of the players?
- Consider the special case when we start with just one pile of matches.
Then player one has a winning strategy: Simply take all matches.
- Consider the special case when we start with two piles of matches.
Now it depends on the situation which player has a winning startegy:
If the two piles are of unequal size, then the player whose turn it is, takes
enough matches from the larger pile until both are of equal size.
This will lead to winning the game.
If both piles are of equal size, then a player is forced to take matches from
just one pile, and make their sizes different.
If the opponent uses the winning strategy of evening the sizes, then the
opponent will win the game.
- In class we discussed the strategy for the general situation.
Here we give a very brief sketch.
Each player thinks of the pile as a collection of different powers of 2.
For example, if we have piles of sizes 1, 3, 6, and 11 matches, then think of
them as composed of (1), (2+1), (4+2), and (8+2+1) matches.
The winning strategy consists of taking matches from one of the piles such
that the composition has an even number of 1s, an even number of 2s, an even
number of 4s, an even number of 8s, and so on.
In the example above with 1, 3, 6, and 11 matches: The player whose turn it
is should take 7 matches from the last pile, leaving piles of sizes 1, 3, 6,
and 4 for the other player. Note that the piles are now composed of (1), (2+1),
(4+2), and (4) matches.
- The game of Hex.
Games like chess and checkers use square boards consisting of smaller squares.
In Hex we have a diamond shaped board consisting of hexagons.
Hexagons have 6 edges and 6 vertices.
In our version of Hex, the diamond shaped board may have size 2 by 2, or 3 by
3, or 4 by 4, and so on.
`Realistic' boards have larger sizes, like 12 by 12 or so.
Two opposite sides are designated white sides, and the other two opposite sides
are designated black sides.
So the corner fields are designated to be on both a white and on a black side.
Instead of drawing a Hex board, one can also use a chess board, but then one
must imagine that the squares are not only horizontally and vertically
connected, but are also connected diagonally by their bottom left and top right
vertices.
The game is played as follows.
Player one puts down a white stone on an empty field.
Then player two puts a black stone on an empty field.
Then player one puts a white stone on an empty field.
Then player two puts a black stone on an empty field.
And so on.
Player one wins when there is a path of fields with white stones connecting the
white sides.
Player two wins when there is a path of fields with black stones connecting the
black sides.
When all fields have a white or a black stone, then there will always be either
a white path connecting the white sides, or a black path connecting the black
sides.
Question: Is there a winning strategy for one of the players?
- In class we showed that there is a winning strategy for one of the
players.
The argument we used applies to all games that are finite, and where all
outcomes are either won for player one, or for player two.
- In class we showed that there is a winning strategy for player one.
The argument we used was by contradiction.
We know there is a winning strategy for one of the players.
If the winning strategy exists for player one, then there is nothing further
to show.
Otherwise, assume there is a winning strategy for player two.
Then we showed in class that we can convert this strategy into a winning
strategy for player one.
But the players can not both have a winning strategy: Contradiction.
So our assumption that there is a winning strategy for player two, is false.
- What is the winning strategy for player one?
We don't know (yet).
Last updated: September 2003
Comments & suggestions:
wimr@mscs.mu.edu