Definition 1 (Game). For us, a game will be any series of alternating moves between two players where one player must win.

Similar documents
Jim and Nim. Japheth Wood New York Math Circle. August 6, 2011

Crossing Game Strategies

Grade 7/8 Math Circles Game Theory October 27/28, 2015

Game 0: One Pile, Last Chip Loses

Tangent: Boromean Rings. The Beer Can Game. Plan. A Take-Away Game. Mathematical Games I. Introduction to Impartial Combinatorial Games

Senior Math Circles February 10, 2010 Game Theory II

Grade 6 Math Circles Combinatorial Games - Solutions November 3/4, 2015

Plan. Related courses. A Take-Away Game. Mathematical Games , (21-801) - Mathematical Games Look for it in Spring 11

Obliged Sums of Games

Game Theory and Algorithms Lecture 19: Nim & Impartial Combinatorial Games

Grade 6 Math Circles Combinatorial Games November 3/4, 2015

Contents. MA 327/ECO 327 Introduction to Game Theory Fall 2017 Notes. 1 Wednesday, August Friday, August Monday, August 28 6

NIM Games: Handout 1

GAMES AND STRATEGY BEGINNERS 12/03/2017

Circular Nim Games. S. Heubach 1 M. Dufour 2. May 7, 2010 Math Colloquium, Cal Poly San Luis Obispo

Take one! Rules: Two players take turns taking away 1 chip at a time from a pile of chips. The player who takes the last chip wins.

Figure 1: The Game of Fifteen

Sept. 26, 2012

Sequential games. We may play the dating game as a sequential game. In this case, one player, say Connie, makes a choice before the other.

EXPLORING TIC-TAC-TOE VARIANTS

STAJSIC, DAVORIN, M.A. Combinatorial Game Theory (2010) Directed by Dr. Clifford Smyth. pp.40

Surreal Numbers and Games. February 2010

SOME MORE DECREASE AND CONQUER ALGORITHMS

PRIMES STEP Plays Games

QUIZ: Fill in the blank. Necessity is the Mother of.

Three Pile Nim with Move Blocking. Arthur Holshouser. Harold Reiter.

o o o o o o o o o o o o

Solutions to Part I of Game Theory

New Values for Top Entails

Analyzing ELLIE - the Story of a Combinatorial Game

Tutorial 1. (ii) There are finite many possible positions. (iii) The players take turns to make moves.

(b) In the position given in the figure below, find a winning move, if any. (b) In the position given in Figure 4.2, find a winning move, if any.

CS103 Handout 25 Spring 2017 May 5, 2017 Problem Set 5

Checkpoint Questions Due Monday, October 7 at 2:15 PM Remaining Questions Due Friday, October 11 at 2:15 PM

Impartial Combinatorial Games Berkeley Math Circle Intermediate II Ted Alper Evans Hall, room 740 Sept 1, 2015

of Nebraska - Lincoln

Math 152: Applicable Mathematics and Computing

CHECKMATE! A Brief Introduction to Game Theory. Dan Garcia UC Berkeley. The World. Kasparov

Binary Games. Keep this tetrahedron handy, we will use it when we play the game of Nim.

CS 491 CAP Intro to Combinatorial Games. Jingbo Shang University of Illinois at Urbana-Champaign Nov 4, 2016

CMPUT 396 Tic-Tac-Toe Game

Subtraction games with expandable subtraction sets

Background. Game Theory and Nim. The Game of Nim. Game is Finite 1/27/2011

Math Circle: Logic Puzzles

Problem F. Chessboard Coloring

12. 6 jokes are minimal.

Monday, February 2, Is assigned today. Answers due by noon on Monday, February 9, 2015.

Grade 7 & 8 Math Circles. Mathematical Games

The game of Reversi was invented around 1880 by two. Englishmen, Lewis Waterman and John W. Mollett. It later became

Make Math Meaningful!

The first player, Fred, turns on the calculator, presses a digit key and then presses the

The Pigeonhole Principle

GAME THEORY. Thomas S. Ferguson

Open Problems at the 2002 Dagstuhl Seminar on Algorithmic Combinatorial Game Theory

Ovals and Diamonds and Squiggles, Oh My! (The Game of SET)

Games, Triangulations, Theory

Contest 1. October 20, 2009

BALTIMORE COUNTY PUBLIC SCHOOLS. Rock n Roll

Use the following games to help students practice the following [and many other] grade-level appropriate math skills.

Whole Numbers. Predecessor and successor Given any natural number, you can add 1 to that number and get the next number i.e. you

ON SPLITTING UP PILES OF STONES

Final Exam, Math 6105

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

Situations Involving Multiplication and Division with Products to 50

Positive Triangle Game

Game, Set, and Match Carl W. Lee September 2016

Game Playing Part 1 Minimax Search

Wednesday, February 1, 2017

Math Football. Using Models to Understand Integers. Learning Goals. Common Core State Standards for Mathematics. Essential Ideas

Game Simulation and Analysis

Combine Like Terms

Mathematical Investigation of Games of "Take-Away"

saying the 5 times, 10 times or 2 times table Time your child doing various tasks, e.g.

Stat 155: solutions to midterm exam

JUSTIN. 2. Go play the following game with Justin. This is a two player game with piles of coins. On her turn, a player does one of the following:

THE GAME CREATION OPERATOR

ARTIFICIAL INTELLIGENCE (CS 370D)

1, 2,, 10. Example game. Pieces and Board: This game is played on a 1 by 10 board. The initial position is an empty board.

ABOUT THE GAME GOAL OF THE GAME SETUP. Jungle Speed is a game for 2 to 10 players. The initiating experience can start at the age of 8 years old.

Descúbrelo! COLORS / COLORES EDITION FREE GRATIS FREE GRATIS FREE GRATIS

BOOM! subtract 15. add 3. multiply by 10% round to. nearest integer. START: multiply by 2. multiply by 4. subtract 35. divide by 2

IMOK Maclaurin Paper 2014

Final Project (Choose 1 of the following) Max Score: A

On Variations of Nim and Chomp

Targets - Year 3. By the end of this year most children should be able to

V. Adamchik Data Structures. Game Trees. Lecture 1. Apr. 05, Plan: 1. Introduction. 2. Game of NIM. 3. Minimax

Games of Skill ANSWERS Lesson 1 of 9, work in pairs

Problem Solving By Cynthia Northrup

Game-playing AIs: Games and Adversarial Search I AIMA

Lecture 33: How can computation Win games against you? Chess: Mechanical Turk

Problem Set 1: It s a New Year for Problem Solving!...

Playing Games. Henry Z. Lo. June 23, We consider writing AI to play games with the following properties:

Table of Contents. Table of Contents 1

Graph Nim. PURE Insights. Breeann Flesch Western Oregon University,

Making Middle School Math Come Alive with Games and Activities

CS 4700: Artificial Intelligence

Probability and Statistics

Problem 4.R1: Best Range

Mathematical Talk. Fun and Games! COUNT ON US MATHS CLUB ACTIVITIES SESSION. Key Stage 2. Resources. Hints and Tips

A Combinatorial Game Mathematical Strategy Planning Procedure for a Class of Chess Endgames

Transcription:

Abstract In this Circles, we play and describe the game of Nim and some of its friends. In German, the word nimm! is an excited form of the verb to take. For example to tell someone to take it all you would say Nimm alles! and to tell someone to keep themselves together you would say Nimm dich zusammen!. As you can guess, in this Circles we will talk about games where you take things. Hopefully when we are done, you will be able to beat all of your friends at these games whenever you want, thus taking the title Gamemaster or Nimm den Titel Meister der Spiele!. 1 Definitions Definition 1 (Game). For us, a game will be any series of alternating moves between two players where one player must win. Definition 2 (States). Any particular position that the board will can be in will be called a state. The first position will be called the initial state and the last position will be called the final state. Definition 3 (Impartial Game). A game is called impartial if the possible moves that a player can take only depends on the current state of the game and not on which player they are. All of the games that we will look at are impartial. There are many games which are not impartial (called partisan), like chess and checkers. In chess, only player 1 can move the white pieces, and so the game is not impartial. Definition 4 (Normal Play). A game is finished when it has reached one of the final positions (we will always only have one final position). In normal play, the player that puts the game into the final position is the winner. Definition 5 (Misére Play). In misére play, the player that puts the game into the final position is the loser. 1

2 Game of 21 The first friend of Nim that we will play is called the Game of 21. In this game there is a pile of 21 stones and players take 1,2, or 3 stones in turns. The winner is the player who takes the last stone. This kind of play is called normal play. You can also play misére where the person to take the last stone loses. Our job will be to take this simple game and determine if we can always determine who will win from the beginning of the game. Try playing the game a few times to see what it is like. Try both normal play and misére play. 2.1 Smaller Games Play the Game of 21 with fewer stones. Start with 1, then with 2, then 3, and so on. Play each game 5 times and record who wins (the first player or the second player) for both normal and misére play. Here is a table for recording the winners What positions do you want to put your opponent in if you can? Is there a pattern to who wins and who loses? Can you make any statements about beginning positions that give a winner? What would you do if it were instead the Game of 22 and you went first? 2

Table 1: Game of N Table Normal Play Winner Misére Play Winner N Player 1 Player 2 Player 1 Player 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3

3 Subtract a Square The second friend of Nim that we will play is called Subtract a Square. In this game there is a pile of stones and players remove a number of stones in turns. The number of stones taken has to be a square, so 1, 4, 9, 16, 25, etc. The game can be played both normal and misére and with any number of stones. Try playing the game with 51 stones under both playing styles. 3.1 Smaller Games Play Subtract a square with fewer stones. Play each game 5 times and record who wins (the first player or the second player) for both normal and misére play. Here is a table for recording the winners What positions do you want to put your opponent in if you can? Is there a pattern to who wins and who loses? Can you make any statements about beginning positions that give a winner? What would you do if the beginning number was 446? 4

Table 2: Subtract a Square Table Normal Play Winner Misére Play Winner N Player 1 Player 2 Player 1 Player 2 1 2 3 4 5 6 7 8 9 10 11 15 19 27 31 35 41 43 45 48 50 5

4 Game of Nim Now for the more complicated game, the Game of Nim. Nim is played with multiple piles of stones. Each pile has a number of stones. One a given turn a player has to take at least one stone and can take a many stones from any one pile as they like. Try playing the game with beginning piles of 6,10, and 15 stones under both normal and misére play. 4.1 Smaller Games of Nim Play Subtract a square with fewer stones. Play each game 5 times and record who wins (the first player or the second player) for both normal and misére play. Here is a table for recording the winners Is there a pattern to who wins and who loses? Is there a way to always win if the game begins as (n, n, k) for any numbers n and k? If the game began as (1, 2, 3, 4), who do you think wins? Play this game a few times and see what conclusions you can make? 6

Table 3: Game of Nim Table Normal Play Winner Misére Play Winner N Player 1 Player 2 Player 1 Player 2 (1, 1, 1) (1, 1, 2) (1, 1, 3) (1, 2, 2) (1, 1, 4) (1, 2, 3) (2, 2, 2) (1, 1, 5) (1, 2, 4) (1, 3, 3) (2, 2, 3) (1, 1, 6) (1, 2, 5) (1, 3, 4) (2, 2, 4) (2, 3, 3) (1, 1, 7) (1, 2, 6) (1, 3, 5) (1, 4, 4) (2, 2, 5) (2, 3, 4) 7

5 Theory of Impartial Games We want to characterize the states of the game as either winning of losing. For a given state, we will call it a winning position (W) if you can always win from it and we will call the state a losing position (L) if you cannot win from it. To start characterizing the states of the game, think about starting with simple states and moving to more complicated states. For N = 1, 2,..., 21, can you characterize each state as winning or losing in the Game of N? For N = 1, 2,..., 21, can you characterize each state as winning or losing in Subtract a Square? Do you think that there is a way to characterize winning and losing states for the Game of Nim? 5.1 How to Win at Games The general strategy for winning a game is like this: If you can always force your opponent into a losing position, then you will always win! A winning position is one where you can always put your opponent into a losing position. And so a losing position has to be a state where you cannot put your opponent into a losing position (you can only put your opponent into a winning position). If we can characterize all of the losing positions of a game, then the rest of the positions have to be winning positions (someone has to win). It turns out that this can always be done for normal play and for misére games that are not too crazy (these are called tame). So, we will focus on normal play in our games. This is sometimes very hard to think about, but can be made very easy for the games that we have seen and some memory will help you to always win at these games under normal play. 8

5.2 Game of N with Normal Play In order to determine who will win at the Game of N, we can analyze all of the games that are simpler than N because after the first move in the game of N, we are left with a game with less that N stones and that leads to a game that we have already analyzed. Let s start analyzing the states. You always go first and I always go second. N = 1, W You take the stone and win! N = 2, W You take both stones and win! N = 3, W You take all three stones and win! N = 4, L You have to take 1,2, or 3 stones. This leaves me with 3,2, or 1 stones (respectively) and I win! So, you lose, sorry. N = 5, W You have to take 1,2, or 3 stones. This leaves me with 4,3, or 2 stones (respectively). If I have 4, then I am in a losing state, otherwise you put me in a winning state (3 or 2 stones). So, you leave me with 4 stones and win! N = 6, W You have to take 1,2, or 3 stones. This leaves me with 5,4, or 3 stones (respectively). If I have 4, then I am in a losing state, otherwise you put me in a winning state (5 or 3 stones). So, you leave me with 4 stones and win! N = 7, W You have to take 1,2, or 3 stones. This leaves me with 6,5, or 4 stones (respectively). If I have 4, then I am in a losing state, otherwise you put me in a winning state (6 or 5 stones). So, you leave me with 4 stones and win! N = 8, L You have to take 1,2, or 3 stones. This leaves me with 7,6, or 5 stones (respectively). All of these are winning positions, but now I am in them, and so you have to lose, sorry. Do you see a pattern to the Game of N? If so, who will win the Game of 21? Who would win if the game had 44 stones? What about 105? Can you make up a game that is like the game of N, but where you take away 7 stones instead of 4? What would determine the winner of that game? Can you make a rule for always winning under misére play? 9

5.3 Subtract a Square with Normal Play In order to determine who will win at Subtract a Square starting at the number N, we can analyze all of the games that are simpler than N because after the first move in the, we are left with a game with less that N stones and that leads to a game that we have already analyzed. Let s start analyzing the positions. You always go first and I always go second. N = 1, W You take the stone and win! N = 2, L You can only take 1 stone, and this leaves me with a win. Sorry, you lose. N = 3, W You can only take 1 stone and this leave me with 2, a losing position. You win! N = 4, W You take all of the stones and win! N = 5, L You can take 1 or 4 stones. Unfortunately this leave me with 4 or 1 stones and I win. N = 6, W You can take 1 or 4 stones. This leaves me with 5 or 2 stones, both losing positions. You win! N = 7, L You can take 1 or 4 stones. Unfortunately this leave me with 6 or 3 stones and I win. N = 8, W You can take 1 or 4 stones. This leaves me with 7 or 4 stones. If you leave me with 7, then I lose and you win! N = 9, W You take all 9 stones and win. We can keep going forever. The important thing to characterize is the losing positions, as any other position is a winner. I will list the first few losing positions 2, 5, 7, 10, 12, 15. Can you name the next 5 losing positions? Is there any emergent pattern? Can you make a similar rule for states in misére play? 10

5.4 Game of Nim We have already seen a game with a simple rule and a game for which you would have to memorize the sequence of losing states. Both games are fairly easy to describe and the rules for winning are quite different. Though Nim seems like a much more complicated game, it will have a very simple rule for determining who will win. What if the game begins as (0, n, n)? In order to characterize Nim, we need some more mathematical machinery. Before that is introduced, see if you can characterize the states in the Nim table. 11

5.4.1 Base 2 Representation Take any integer greater than 0. It can be represented uniquely as sequence of 0s and 1s that capture whether a given power of 2 divides the number. The number n is written as n = n 0 2 0 + n 2 2 1 + n 3 2 3 + n 4 2 4 + where n i is 0 or 1 If n K is the largest such n k, then the number is written as n = n K n K 1 n 3 n 2 n 1 n 0. Here are the first few integers written in binary What is 12 represented in base 2? What is 16 represented in base 2? What is 28 represented in base 2? 1 = 1 2 = 10 3 = 11 4 = 100 5 = 101 6 = 110 7 = 111 8 = 1000 9 = 1001 5.4.2 The Operation When we add numbers in binary, we can add them like normal numbers OR treat the binary representation as a sequence of switches. Each place holder (power of 2) represents a switch and the sum of two base 2 numbers is number in base 2 that represents which switches remain turned on. For example, 3 = 11 and so the number 3 turns on the first two switches. If we add 3 and 1 using, we get 3 1 = 11 01 = 10 = 2. In each place, if we see 2 ones, the switch is turned on and then back off. In each place where we see a 0 and a 1, the switch remains turned on. Essentially, each one represents flipping the switch to the position it is not in. 12

Here are some additions What is 12 16? What is 12 28? What is 16 28? Is commutative? associative? 1 1 = 1 1 = 0 = 0 1 2 = 01 10 = 11 = 3 1 3 = 01 11 = 10 = 2 1 4 = 01 100 = 101 = 5 2 3 = 10 11 = 01 = 1 5 9 = 0101 1001 = 1100 = 12 5.4.3 Strategy for Nim Now we come to the grand strategy. In Nim, represent each pile in base 2 and then add the numbers using. The losing states for normal play are the states where the sum (using ) is 0. This is quite remarkable. It works for any number of piles and any sizes. Using this, we can determine if the player going first or second will win any given game of Nim. Use this stategy to classigy the Nim games in the table. Is the game (3, 4, 5) in a winning or losing position? Is the game (3, 4, 12) in a winning or losing position? Is the game (1, 2, 3, 4, 5) in a winning or losing position? Important things to prove: From a 0 state, you can only go to a non-zero state. From any non-zero state, you can go to the 0 state. Can you prove these? 13

5.5 Graph of the Game You can think of the states of the game as points in space, call them nodes. For each of our games under normal play, there is only one final state, the empty postion. Label this position with an L. Begin connecting the other states to this state by drawing lines between the final postion and the nodes that can lead to it in one move. Make the line an arrow pointing to the final state, representing that the final state can be reached in one turn. The node that lead to the final state are all winning nodes. Label them with a W. Keep doing this, connecting the nodes together. Any node that only leads to W nodes is an L node. Any node leading to at least one L node is a W node. Here are some examples of graphs for the games we have seen. All of the losing nodes are boxes and the winning nodes are circles. 5.5.1 Game of N 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

5.5.2 Subtract a Square 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5.5.3 Game of Nim For this graph, we label a state by the piles in the state. So, a state with piles of size 1, 2, and 3 is labeled (1, 2, 3). We treat the state (1, 2, 3) as though it is the same as the state (2, 1, 3) so that re-ordering of the piles does not matter. Can you draw a graph for the game of Nim with less than 5 total stones? less than 7 total stones? less than 9 total stones? Note that for the game of nim with 9 stones that there are 53 nodes! 15

6 Game of Grundy This game is simlar to Nim, but begins with one pile of stones. On each turn, the players can split any pile into two unequal piles. The game ends when no pile can be split, so all of the remaining piles have 1 or 2 stones. This game can be played in both the normal and the misére style. Normal play can be analyzed in a similar manner to Nim. Can you draw the graph of the game? Can you find the way to analyze it? 16