Notes on Impartial Game Theory
Total Page:16
File Type:pdf, Size:1020Kb
IMPARTIAL GAMES KENNETH MAPLES In the theory of zero-sum and general-sum games, we studied games where each player made their moves simultaneously. Equivalently, we can think of the moves of the alternate player as hidden until both have made their decision. In this part of the course, we will instead consider games that have complete information; that is, both players know the entire state of the game. This means that players move sequentially and there are no unknown or random factors in the game. We will first consider the theory of impartial games. An impartial game is one where two players move alternately according to a set of rules. If either player has no available moves when it is her turn, that player loses. We also require that both players have the same set of moves from a position. The theory of game of complete information where the players have different sets of moves available is called the theory of partizan games, which we will cover in the next week of the course. For our analysis the following definition is very convenient. Definition. An impartial game is a set. We will call the elements of a game A the options of the game, where they represent the resulting game after the move. Thus the game fg, denoting the empty set, is a game where the player-to-move loses, and the game ffgg, denoting a set containing the empty set, is a game where the player-to-move wins (as after her move, teh opponent is given a losing game). We will call any element A1 3 ⋅ ⋅ ⋅ 3 A of a finite sequence of options to be a position of the game. Equivalently, positions are games that are reachable in a finite number of moves from the given game. We will use the notion of set from the Zermelo-Fraenkel (ZF) theory. In particular, our games will obey the axiom of regularity which says that for every non-empty game A, there is an option B of A that is disjoint from A. This in particular implies that no option of a game is the game itself; i.e. there is no passing, and that there is not an infinite sequence of options A1 3 A2 3 A3 3 ⋅ ⋅ ⋅ that does not terminate. We would like our games to end! 1. Subtraction games and N/P positions The first type of game we will consider is the subtraction game. In this game, we have a pile of n stones where players alternate removing stones Date: 6/28/11. 1 2 KENNETH MAPLES from the pile. A legal move removes a number of stones that lies in the set S, where S is some (possibly infinite) set of allowed moves. For example, we could have the game where n = 4 and S = f1; 2; 3g. Then the first player has the option of removing one, two, or three stones from the pile, leaving three, two, and one, respectively. Then the second player could eliminate the pile (as in all three cases, the number of remaining stones lies in S), which would leave the first player with the game fg, a losing game. Thus the second player wins in each case. To make later analysis easier, we define a P-position to be one where the previous player has a winning strategy (or, if it is the first move of the game, the second player), and we define an N-position to be one where the next player has a winning strategy. Our theory of impartial games lets us cleanly split games into P-positions and N-positions. We first observe that we can deduce whether a game is an N-position or a P-position if we know whether all of its options are N-positions or P-positions. Proposition. A game G is an N-position if one of its options is a P- positions. A game G is a P-position if all of its (possibly empty) options are N-positions. Proof. If a game has a P-position, a winning strategy for the first player is to choose the option that makes the game a P-position. Likewise, if all options available to the current player are N-positions, the second player has a winning strategy regardless of the current player's choice. □ Note that fg is a P-position. Proposition. There is a unique labeling of the positions of a game into N-positions and P-positions. Proof. We know that fg is a P-position. For any game G, we can assume by induction and the axiom of regularity that it is known whether each of its options is an N-position or a P-position. But then Proposition 1 shows that the game must be either an N- or P-position. □ This is typical of the proofs we will employ: because we have an explicit hierarchy of games, we can prove statements for all games using induction. Now lets return to subtraction games. If we let (n) denote the subtrac- tion game on n stones with S = f2; 3; 4g (notice that S has changed!). Thus we have, for example, (7) = f(3); (4); (5)g. We can quickly compute which of (n) is N or P depending on the smaller values; see Table 1. Table 1 has a clear pattern: if n ≡ 0 or 1 mod 6 then (n) is a P-position, and otherwise it is an N-position. (Can you prove this?) 2. Nim, nimbers, and sums of games We will now consider the classic game of nim. Nim is a game played with several heaps of stones. On any turn, a player may choose one heap IMPARTIAL GAMES 3 Table 1. Some N and P values in the subtraction game with S = f2; 3; 4g (0) : P (6) : P (12) : P (1) : P (7) : P (13) : P (2) : N (8) : N (14) : N (3) : N (9) : N (15) : N (4) : N (10) : N (16) : N (5) : N (11) : N (17) : N and remove any number of stones from that heap, as long as she removes at least one. For example, if we have two heaps of size (3; 4), then the first player may remove 4 stones from the second heap and be left with one heap of size 3. This is not an advisable move: the opponent can immediately take all of the stones from the heap of size 3, and since there are no more stones remaining, the first player loses! In this section we will write (n1; :::; nk) to indicate a game of nim with k piles, where there are nj stones in the jth pile. We will have a much better notation by the end. In general, we define the sum of games G1 and G2 to be the game with options defined recursively by G1 + G2 = fA1 + G2;G1 + A2gA12G1;A22G2 Equivalently, each player chooses one of the games G1 and G2 and makes a single move on that game. Thus we can think of the general nim game (n1; :::; nk) as the sum of subtraction games, where the jth game has nj stones and S = f0; 1; 2; :::g = N. Before we can effectively analyze nim, we need to introduce new tools. We define the mex of a set of natural numbers to be the least natural number not contained in that set, i.e. mex(A) := min a ≥ 0 : a2 = A: For example, mex(1; 2; 3) = 0 and mex(0; 1; 3) = 2. We can then define the Grundy value G to be a function on games that assigns to any game A the value G(A) := mex(G(B) j B 2 A) i.e. the mex of the options of A. This function is well-defined: we can assume that G is defined for all options of A by induction, whence the mex is well-defined. We can find the Grundy value of a nim game (n) (i.e. a single pile with n stones) quickly enough: we have (n) = f(0); (1); :::; (n − 1)g, since the first player may remove any number of stones from the pile, so by induction we have G((n)) = n. At this point is is convenient to define new notation: we will define a finite nimber to be the Grundy value of a finite nim pile, and write ∗n for the value of the pile with n stones. We will also abbreviate 4 KENNETH MAPLES ∗0 = 0 and ∗1 = ∗. Thus we think of the Grundy value as being a nim pile and will henceforth always write Grundy values in the form ∗n. This is to prevent confusion when we introduce partizan games. Grundy values tell us whether a game is a win for the first or second player. Proposition. If A is a game with Grundy value G(A) = 0 then A is a P-position. If G(A) = ∗n for n 6= 0 then A is a N-position. Proof. We proceed by induction. For the empty game we have G(fg) = mex(fg) = 0 which verifies the Proposition. For a general game, if A is an N-position then A has an option B which is a P-position. By induction, G(B) = 0 so G(A) = mex(∗0; :::) 6= ∗0. Likewise, if A is a P-position then all of the options of A are N-positions, so by induction G(A) = mex(∗n1; n2; :::) where each nj 6= 0, hence G(A) = ∗0. □ Nimbers have an addition operation, which we will denote by + but some- times by +∗.