

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Game Theory in describes combinatorial games, sybstraction games, games of nim, graph games, green hackenbush and exercies will be given.
Typology: Lecture notes
1 / 33
This page cannot be seen from the preview
Don't miss anything!


























Class notes for Math 167, Fall 2000
Thomas S. Ferguson
1.1 A Simple Take-Away Game. 1.2 What is a Combinatorial Game? 1.3 P-positions, N-positions. 1.4Subtraction Games. 1.5 Exercises.
2.1 Preliminary Analysis. 2.2 Nim-Sum. 2.3 Nim With a Larger Number of Piles. 2.4Proof of Bouton’s Theorem. 2.5 Mis`ere Nim. 2.6 Exercises.
3.1 Games Played on Directed Graphs. 3.2 The Sprague-Grundy Function. 3.3 Examples. 3.4The Use of the Sprague-Grundy Function. 3.5 Exercises.
4.1 The Sum of n Graph Games. 4.2 The Sprague Grundy Theorem. 4.3 Applications. 4.4 Take-and-Break Games. 4.5 Exercises.
5.1 Bamboo Stalks. 5.2 Green Hackenbush on Trees. 5.3 Green Hackenbush on General Rooted Graphs. 5.4Exercises.
References.
If there are just one, two, or three chips left, the player who moves next wins simply by taking all the chips. Suppose there are four chips left. Then the player who moves next must leave either one, two or three chips in the pile and his opponent will be able to win. So four chips left is a loss for the next player to move and a win for the previous player, i.e. the one who just moved. With 5, 6, or 7 chips left, the player who moves next can win by moving to the position with four chips left. With 8 chips left, the next player to move must leave 5, 6, or 7 chips, and so the previous player can win. We see that positions with 0, 4 , 8 , 12 , 16 ,... chips are target positions; we would like to move into them. We may now analyze the game with 21 chips. Since 21 is not divisible by 4, the first player to move can win. The unique optimal move is to take one chip and leave 20 chips which is a target position.
1.2 What is a Combinatorial Game? We now define the notion of a combinatorial game more precisely. It is a game that satisfies the following conditions.
(1) There are two players. (2) There is a set, usually finite, of possible positions of the game. (3) The rules of the game specify for both players and each position which moves to other positions are legal moves. If the rules make no distinction between the players, that is if both players have the same options of moving from each position, the game is called impartial; otherwise, the game is called partizan.
(4) The players alternate moving. (5) The game ends when a position is reached from which no moves are possible for the player whose turn it is to move. Under the normal play rule, the last player to move wins. Under the mis`ere play rule the last player to move loses.
If the game never ends, it is declared a draw. However, we shall nearly always add the following condition, called the ending condition. This eliminates the possibility of a draw.
(6) The game ends in a finite number of moves no matter how it is played. It is important to note what is omitted in this definition. No random moves such as the rolling of dice or the dealing of cards are allowed. This rules out games like backgammon and poker. A combinatorial game is a game of perfect information: simultaneous moves and hidden moves are not allowed. This rules out battleship and scissors-paper-rock. No draws in a finite number of moves are possible. This rules out tic-tac-toe. In these notes, we restrict attention to impartial games, generally under the normal play rule.
1.3 P-positions, N-positions. Returning to the take-away game of Section 1.1, we see that 0, 4 , 8 , 12 , 16 ,... are positions that are winning for the Previous player (the player who just moved) and that 1, 2 , 3 , 5 , 6 , 7 , 9 , 10 , 11 ,... are winning for the Next player to move. The former are called P-positions, and the latter are called N-positions. The
P-positions are just those with a number of chips divisible by 4, called target positions in Section 1.1.
In impartial combinatorial games, one can find in principle which positions are P- positions and which are N-positions by (possibly transfinite) induction using the following labeling procedure starting at the terminal positions. We say a position in a game is a terminal position, if no moves from it are possible. This algorithm is just the method we used to solve the take-away game of Section 1.1.
Step 1: Label every terminal position as a P-position. Step 2: Label every position that can reach a labelled P-position in one move as an N-position.
Step 3: Find those positions whose only moves are to labelled N-positions; label such positions as P-positions.
Step 4: If no new P-positions were found in step 3, stop; otherwise return to step 2. It is easy to see that the strategy of moving to P-positions wins. From a P-position, your opponent can move only to an N-position (3). Then you may move back to a P- position (2). Eventually the game ends at a terminal position and since this is a P-position, you win (1).
Here is a characterization of P-positions and N-positions that is valid for impartial combinatorial games satisfying the ending condition, under the normal play rule.
P-positions and N-positions are defined recursively by the following three statements. (1) All terminal positions are P-positions. (2) From every N-position, there is at least one move to a P-position. (3) From every P-position, every move is to an N-position.
For games using the mis´ere play rule, condition (1) should be replaced by the condition that all terminal positions are N-positions.
1.4 Subtraction Games. Let us now consider a class of combinatorial games that contains the take-away game of Section 1.1 as a special case. Let S be a set of positive integers. The subtraction game with subtraction set S is played as follows. From a pile with a large number, say n, of chips, two players alternate moves. A move consists of removing s chips from the pile where s ∈ S. Last player to move wins.
The take-away game of Section 1.1 is the subtraction game with subtraction set S = { 1 , 2 , 3 }. In Exercise 1.2, you are asked to analyze the subtraction game with subtraction set S = { 1 , 2 , 3 , 4 , 5 , 6 }.
For illustration, let us analyze the subtraction game with subtraction set S = { 1 , 3 , 4 } by finding its P-positions. There is exactly one terminal position, namely 0. Then 1, 3, and 4are N-positions, since they can be moved to 0. But 2 then must be a P-position since the only legal move from 2 is to 1, which is an N-position. Then 5 and 6 must be N-positions since they can be moved to 2. Now we see that 7 must be a P-position since the only moves from 7 are to 6, 4, or 3, all of which are N-positions.
Now we continue similarly: we see that 8, 10 and 11 are N-positions, 9 is a P-position, 12 and 13 are N-positions and 14is a P-position. This extends by induction. We find
board. A move consists in taking a square and removing it and all squares to the right and above. Players alternate moves, and the person to take square (1, 1) loses. The name “Chomp” comes from imagining the board as a chocolate bar, and moves involving breaking off some corner squares to eat. The square (1, 1) is poisoned though; the player who chomps it loses. You can play this game on the web at http://207.106.82.89/puzzles/chomp/chomp.htm.
For example, starting with an 8 by 3 board, suppose the first player chomps at (6, 2) gobbling 6 pieces, and then second player chomps at (2, 3) gobbling 4pieces, leaving the following board, where
denotes the poisoned piece.
(a) Show that this position is a N-position, by finding a winning move for the first player. (It is unique.)
(b) It is known that the first player can win all rectangular starting positions. The proof, though ingenious, is not hard. However, it is an “existence” proof. It shows that there is a winning strategy for the first player, but gives no hint on how to find the first move! See if you can find the proof. Here is a hint: Does removing the upper right corner constitute a winning move?
Zeckendorf ’s Theorem. Every positive integer can be written uniquely as a sum of distinct non-neighboring Fibonacci numbers.
There may be many ways of writing a number as a sum of Fibonacci numbers, but there is only one way of writing it as a sum of non-neighboring Fibonacci numbers. Thus, 43=34+8+1 is the unique way of writing 43, since although 43=34+5+3+1, 5 and 3 are
neighbors. What is an optimal move for the first player if n = 43? For what values of n does the second player have a win?
For example, (10110) 2 ⊕ (110011) 2 = (100101) 2. This says that 22 ⊕ 51 = 37. This is easier to see if the numbers are written vertically (we also omit the parentheses for clarity):
22 = (^101102) 51 = 110011 2 nim-sum = 100101 2 = 37
Nim-sum is associative (i.e. x ⊕ (y ⊕ z) = (x ⊕ y) ⊕ z) and commutative (i.e. x ⊕ y = y ⊕ x), since addition modulo 2 is. Thus we may write x ⊕ y ⊕ z without specifying the order of addition. Furthermore, 0 is an identity for addition (0⊕ x = x), and every number is its own inverse (x ⊕ x = 0), so that the cancellation law holds: x ⊕ y = x ⊕ z implies y = z. (If x ⊕ y = x ⊕ z, then x ⊕ x ⊕ y = x ⊕ x ⊕ z, and so y = z.)
Thus, nim-sum has a lot in common with ordinary addition, but what does it have to do with playing the game of Nim? The answer is contained in the following theorem of C. L. Bouton (1902).
Theorem 1. A position, (x 1 , x 2 , x 3 ), in Nim is a P-position if and only if the nim-sum of its components is zero, x 1 ⊕ x 2 ⊕ x 3 = 0.
As an example, take the position (x 1 , x 2 , x 3 ) = (13, 12 , 8). Is this a P-position? If not, what is a winning move? We compute the nim-sum of 13, 12 and 8:
13 = (^11012) 12 = (^11002) 8 = (^10002) nim-sum = 10012 = 9
Since the nim-sum is not zero, this is an N-position according to Theorem 1. Can you find a winning move? You must find a move to a P-position, that is, to a position with an even number of 1’s in each column. One such move is to take away 9 chips from the pile of 13, leaving 4there. The resulting position has nim-sum zero:
4= (^100 ) 12 = (^11002) 8 = (^10002) nim-sum = 00002 = 0
Another winning move is to subtract 7 chips from the pile of 12, leaving 5. Check it out. There is also a third winning move. Can you find it?
2.3 Nim with a Larger Number of Piles. We saw that 1-pile nim is trivial, and that 2-pile nim is easy. Since 3-pile nim is much more complex, we might expect 4-pile nim to be much harder still. But that is not the case. Theorem 1 also holds for a larger number of piles! A nim position with four piles, (x 1 , x 2 , x 3 , x 4 ), is a P-position if and only if x 1 ⊕ x 2 ⊕ x 3 ⊕ x 4 = 0. The proof below works for an arbitrary finite number of piles.
2.4 Proof of Bouton’s Theorem. Let P denote the set of Nim positions with nim- sum zero, and let N denote the complement set, the set of positions of positive nim-sum. We check the three conditions of the definition in Section 1.3.
(1) All terminal positions are in P. That’s easy. The only terminal position is the position with no chips in any pile, and 0 ⊕ 0 ⊕ · · · = 0.
(2) From each position in N , there is a move to a position in P. Here’s how we construct such a move. Form the nim-sum as a column addition, and look at the leftmost (most significant) column with an odd number of 1’s. Change any of the numbers that have a 1 in that column to a number such that there are an even number of 1’s in each column. This makes that number smaller because the 1 in the most significant position changes to a 0. Thus this is a legal move to a position in P.
(3) Every move from a position in P is to a position in N. If (x 1 , x 2 ,.. .) is in P and x 1 is changed to x′ 1 < x 1 , then we cannot have x 1 ⊕ x 2 ⊕ · · · = 0 = x′ 1 ⊕ x 2 ⊕ · · ·, because the cancellation law would imply that x 1 = x′ 1. So x′ 1 ⊕ x 2 ⊕ · · · = 0, implying that (x′ 1 , x 2 ,.. .) is in N.
These three properties show that P is the set of P-positions.
It is interesting to note from (2) that in the game of nim the number of winning moves from an N-position is equal to the number of 1’s in the leftmost column with an odd number of 1’s. In particular, there is always an odd number of winning moves.
2.5 Misere Nim. What happens when we play nim under the misere play rule? Can we still find who wins from an arbitrary position, and give a simple winning strategy? This is one of those questions that at first looks hard, but after a little thought turns out to be easy.
Here is Bouton’s method for playing mis`ere nim optimally. Play it as you would play nim under the normal play rule as long as there are at least two heaps of size greater than one. When your opponent finally moves so that there is exactly one pile of size greater than one, reduce that pile to zero or one, whichever leaves an odd number of piles of size one remaining.
This works because your optimal play in nim never requires you to leave exactly one pile of size greater than one (the nim sum must be zero), and your opponent cannot move from two piles of size greater than one to no piles greater than one. So eventually the game drops into a position with exactly one pile greater than one and it must be your turn to move.
A similar analysis works in many other games. But in general the misere play theory is much more difficult than the normal play theory. Some games have a fairly simple normal play theory but an extraordinarily difficult misere theory, such as the games of Kayles and Dawson’s chess, presented in Section 1.4.
2.6 Exercises.
Show that (x 1 , x 2 ,... , xn) is a P-position if and only if the numbers of coins on the odd numbered steps, (x 1 , x 3 ,... , xk ) where k = n if n is odd and k = n − 1 if n is even, forms a P-position in ordinary nim.
Moore’s Theorem states that a position (x 1 , x 2 ,... , xn), is a P-position in Nimk if and only if when x 1 to xn are expanded in base 2 and added in base k + 1 without carry, the result is zero. (In other words, the number of 1’s in each column must be divisible by k + 1.)
(a) Consider the game of Nimble of Exercise 3 but suppose that at each turn a player may move one or two coins to the left as many spaces as desired. Note that this is really Moore’s Nimk with k = 2. Using Moore’s Theorem, show that the Nimble position of Exercise 3 is an N-position, and find a move to a P-position.
(b) Prove Moore’s Theorem.
We now give an equivalent description of a combinatorial game as a game played on a directed graph. This will contain the games described in Sections 1 and 2. This is done by identifying positions in the game with vertices of the graph and moves of the game with edges of the graph. Then we will define a function known as the Sprague-Grundy function that contains more information than just knowing whether a position is a P-position or an N-position.
3.1 Games Played on Directed Graphs. We first give the mathematical definition of a directed graph.
Definition. A directed graph, G, is a pair (X, F ) where X is a nonempty set of vertices (positions) and F is a function that gives for each x ∈ X a subset of X, F (x) ⊂ X. For a given x ∈ X, F (x) represents the positions to which a player may move from x (called the followers of x). If F (x) is empty, x is called a terminal position.
A two-person win-lose game may be played on such a graph G = (X, F ) by stipulating a starting position x 0 ∈ X and using the following rules: (1) Player I moves first, starting at x 0. (2) Players alternate moves. (3) At position x, the player whose turn it is to move chooses a position y ∈ F (x). (4) The player who is confronted with a terminal position at his turn, and thus cannot move, loses. As defined, graph games could continue for an infinite number of moves. To avoid this possibility and other problems, we restrict attention to graphs that have the property that no matter what starting point x 0 is used, there is a number n, possibly depending on x 0 , such that every path from x 0 has length less than or equal to n. (A path is a sequence x 0 , x 1 , x 2 ,... , xm such that xi ∈ F (xi− 1 ) for all i = 1,... , m, where m is the length of the path.) Such graphs are called progressively bounded. (If X itself is finite, this merely means that there are no circuits. A circuit is a path, x 0 , x 1 ,... , xm, with x 0 = xm and distinct vertices x 0 , x 1 ,... , xm− 1 , m ≥ 1.) As an example, the subtraction game with subtraction set S = { 1 , 2 , 3 }, analyzed in Section 1.1, that starts with a pile of n chips has a representation as a graph game. Here X = { 0 , 1 ,... , n} is the set of vertices. The empty pile is terminal, so F (0) = ∅, the empty set. We also have F (1) = { 0 }, F (2) = { 0 , 1 }, and for 2 ≤ k ≤ n, F (k) = {k− 3 , k− 2 , k− 1 }. This completely defines the game.
Fig. 3.1 The Subtraction Game with S = { 1 , 2 , 3 }. It is useful to draw a representation of the graph. This is done using dots to represent vertices and lines to represent the possible moves. An arrow is placed on each line to
x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14... g(x) 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2...
In general g(x) = x (mod 4), i.e. g(x) is the remainder when x is divided by 4.
x 0 1 2 3 4 5 6 7 8 9 10 11 12... g(x) 0 1 2 2 3 3 3 3 4 4 4 4 4...
We see that g(x) may be expressed as the exponent in the smallest power of 2 greater than x: g(x) = min{k : 2k^ > x}.
3.4 The Use of the Sprague-Grundy Function. Given the Sprague-Grundy function g of a graph, it is easy to analyze the corresponding graph game. Positions x for which g(x) = 0 are P-positions and all other positions are N-positions. The winning procedure is to choose at each move to move to a vertex with Sprague-Grundy value zero. This is easily seen by checking the conditions of Section 1.3:
(1) If x is a terminal position, g(x) = 0. (2) At positions x for which g(x) = 0, every follower y of x is such that g(y) = 0, and (3) At positions x for which g(x) = 0, there is at least one follower y such that g(y) = 0.
The Sprague-Grundy function thus contains a lot more information about a game than just the P- and N-positions. What is this extra information used for? As we will see in the Section 4, the Sprague-Grundy function allows us to analyze sums of graph games.
We may generalize the theory by replacing the hypothesis that the graph be progres- sively bounded by the hypothesis that the graph be progressively finite: every path has a finite length. This is essentially equivalent to the ending condition (6) of Section 1.2. Circuits would still be ruled out if we made such a change.
As an example of a graph that is progressively finite but not progressively bounded, consider the graph of the game in Figure 3.3 in which the first move is to choose the number of chips in a pile, and from then on to treat the pile as a nim pile. From the initial position each path has a finite length so the graph is progressively finite. But the graph is not progressively bounded since there is no upper limit to the length of a path from the initial position. The Sprague-Grundy theory can be extended to progressively finite graphs, but transfinite induction must be used. The SG-value of the initial position above
would be the smallest ordinal greater than all integers, usually denoted by ω. We may also define nim positions with SG-values ω + 1, ω + 2,... , 2 ω,... , ω^2 ,... , ωω^ , etc., etc., etc. Except for Exercise 7, we do not pursue this topic further.
ω
Fig 3.3 A progressively finite graph that is not progressively bounded.
3.5 Exercises.
Fig 3.4Find the Sprague-Grundy function.
(b) Suppose the above rules are in force with the exception that it is not allowed to remove the whole pile. This is called the Aliquot game by Silverman, (1971). (See http://www.cut-the-knot.com/SimpleGames/Aliquot.html .) Thus, if there are 12 chips, you may remove 1, 2, 3, 4, or 6 chips. The only terminal position is 1. Find the Sprague- Grundy function.
Given several combinatorial games, one can form a new game played according to the following rules. A given initial position is set up in each of the games. Players alternate moves. A move for a player consists in selecting any one of the games and making a legal move in that game, leaving all other games untouched. Play continues until all of the games have reached a terminal position, when no more moves are possible. The player who made the last move is the winner.
The game formed by combining games in this manner is called the (disjunctive) sum of the given games. We first give the formal definition of a sum of games and then show how the Sprague-Grundy functions for the component games may be used to find the Sprague-Grundy function of the sum. This theory is due independently to R. P. Sprague (1935-6) and P. M. Grundy (1939).
4.1 The Sum of n Graph Games. Suppose we are given n progressively bounded graphs, G 1 = (X 1 , F 1 ), G 2 = (X 2 , F 2 ),... , Gn = (Xn, Fn). One can combine them into a new graph, G = (X, F ), called the sum of G 1 , G 2 ,... , Gn and denoted by G = G 1 +· · ·+Gn as follows. The set X of vertices is the Cartesian product, X = X 1 ×· · ·×Xn. This is the set of all n-tuples (x 1 ,... , xn) such that xi ∈ Xi for all i. For a vertex x = (x 1 ,... , xn) ∈ X, the set of followers of x is defined as
F (x) = F (x 1 ,... , xn) = F 1 (x 1 ) × {x 2 } × · · · × {xn} ∪ {x 1 } × F 2 (x 2 ) × · · · × {xn} ∪ · · · ∪ {x 1 } × {x 2 } × · · · × Fn(xn).
Thus, a move from x = (x 1 ,... , xn) consists in moving exactly one of the xi to one of its followers (i.e. a point in Fi(xi)). The graph game played on G is called the sum of the graph games G 1 ,... , Gn.
If each of the graphs Gi is progressively bounded, then the sum G is progressively bounded as well. The maximum number of moves from a vertex x = (x 1 ,... , xn) is the sum of the maximum numbers of moves in each of the component graphs.
As an example, the 3-pile game of nim may be considered as the sum of three one-pile games of nim. This shows that even if each component game is trivial, the sum may be complex.
4.2 The Sprague-Grundy Theorem. The following theorem gives a method for obtaining the Sprague-Grundy function for a sum of graph games when the Sprague- Grundy functions are known for the component games. This involves the notion of nim-sum defined earlier. The basic theorem for sums of graph games says that the Sprague-Grundy function of a sum of graph games is the nim-sum of the Sprague-Grundy functions of its component games. It may be considered a rather dramatic generalization of Theorem 1 of Bouton.
The proof is similar to the proof of Theorem 1.