Introduction to Combinatorial Game Acm Honored Class Weitao Sprouts Rules The game is played by two players, starting with a few spots drawn on a sheet of paper. Players take turns, where each turn consists of drawing a line between two spots (or from a spot to itself) and adding a new spot somewhere along the line. The players are constrained by the following rules. Rules The line may be straight or curved, but must not touch or cross itself or any other line. The new spot cannot be placed on top of one of the endpoints of the new line. Thus the new spot splits the line into two shorter lines. No spot may have more than three lines attached to it. For the purposes of this rule, a line from the spot to itself counts as two attached lines and new spots are counted as having two lines already attached to them. In so-called normal play, the player who makes the last move wins. In misère play, the player who makes the last move loses. Combinatorial Game There are two players. There is a set, usually finite, of possible positions of the game. 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. The players alternate moving. The game ends when a postion is reached from which no moves are possible for the player whose turn is to move. The game ends in a finite number of moves no matter how it is played. The Game of Nim The most famous take-away game is the game of Nim, played as follows. There are three piles of chips containing x1, x2, and x3 chips respectively. Two players take turns moving. Each move consists of selecting one of the piles and removing chips from it. You may not remove chips from more than one pile in one turn, but from the pile you selected you may remove as many chips as desired, from one chip to the whole pile. The winner is the player who removes the last chip. P-positions and N-positions Winning for the Previous player Winning for the Next player to move Characteristic Property: (1)All terminal positions are P-positions. (2) From every N-position, there is at least one move to a Pposition (3) From every P-position, every move is to an N-position. Algorithm Recursion Step 1: Label every terminal position as a P-position. Step 2: Label every position that can reach a labelled Pposition 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. Nim-Sum a1,a2,a3,……an Nim-Sum=a1^a2^...^an Theorem of C.L. Bouton A position, (x1, x2, x3,...,xn), in Nim is a P-position if and only if the nim-sum of its components is zero, x1^x2^x3^...^xn=0. Proof All terminal positions are in P. From each position in N, there is a move to a position in P Every move from a position in P is to a position in N Graph Games A two-person game played on a directed graph with no cycles a starting position x0 ∈ X and using the following rules: (1) Player I moves first, starting at x0. (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 Minimal Excludant the smallest non-negative integer not in the set mex{0,1,2,4}=3; mex{}=0; The Sprague-Grundy Function g(x) = mex{g(y) : y ∈ F(x)} Character If x is a terminal position, g(x) = 0. At postions x for which g(x)=0, every follower y of x is such that g(y)!=0 At postions x for which g(x)!=0,there is at least one follower y such that g(y)=0 The Sprague-Grundy Theorem A position, (x1, x2, x3,...,xn), is a P-position if and only if G(x1)^G(x2)^G(x3)^...^G(xn)=0 Examples poj1704,2425,2311 Reference • 《GAME THEORY》 Thomas S. Ferguson • 《超高端桌游:一点一线烧糊你的大脑》 junglerubik • Wikipedia Thanks!