Presentation is loading. Please wait.

Presentation is loading. Please wait.

Benjamin Casey C S 329 E Spring 2009.  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and.

Similar presentations


Presentation on theme: "Benjamin Casey C S 329 E Spring 2009.  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and."— Presentation transcript:

1 Benjamin Casey C S 329 E Spring 2009

2  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and theory developed by C. Bouton of Harvard in 1901; name taken from German nimm meaning “take”  Fundamental to Sprague-Grundy thm., combinatorial game theory

3  Consists of a number of “nim-heaps”, each containing one or more objects  2 Players alternate taking 1 or more objects from any nim-heap  Normal play: Player who takes the last object wins  Misère play: player who takes the last object loses  Other variants

4 http://www.youtube.com/watch?v=oxBghtQ8McA

5 http://en.wikipedia.org/wiki/Nimrod_(computing)

6  Player 1 takes 1 from heap 2 Player 2 takes 1 from heap 2 Player 1 takes 1 from heap 1  Player 2 loses 

7  Theory completely solved for any number of heaps/objects by C. Bouton  Based upon binary digital sum of heap sizes  also known as “nim-sum” ▪ write the size of each heap in binary ▪ add the sizes without carrying ▪ simple rule of thumb:  column w/ even # of 1’s = 0  column w/ odd # of 1’s = 1

8 1 0 1 = 0 1 1 0 = 0 0

9  Nim-sum obeys commutative and associative laws of addition  Also obeys another property:  x + x = 0

10  Winning strategy: finish each move such that the nim-sum is zero  if the nim-sum is non-zero upon your move, it is always possible to move such that the resulting nim-sum is zero (but also possible to have a non- zero result)  if the nim-sum is zero upon your move, it is impossible to move such that the resulting nim- sum is zero

11  Nim-sum = 01 + 10 = 11 Nim-sum = 01 + 01 = 00 Nim-sum = 01  Nim-sum = 00

12  Let {x 1, …, x n } = sizes of nim-heaps before move  Let {y 1, …, y n } = sizes of nim-heaps after move  Let S = nim-sum of x 1, …, x n  Let T = nim-sum of y 1, …, y n  If move was made in heap k:  x i = y i for all i ≠ k  x k > y k

13  To determine which nim-heap k to play in:  Calculate x i + S for i  n; call this X i  The heap with X i < x i is the heap you want to play in  To determine how many items to remove from heap k  Move such that y i = X i

14 S = 10 + 11 + 100 = 101 X 1 = x 1 + S = 10 + 101 = 111 X 2 = x 2 + S = 11 + 101 = 110 X 3 = x 3 + S = 100 + 101 = 001 Thus k = x 3 and you want to remove items such that y 3 = X 3 = 001 T = 10 + 11 + 01 = 00 

15  T = 0 + T  T = (S + S) + T  T = S + (x 1 + … + x n ) + (y 1 + … + y n )  T = S + (x 1 + y 1 ) + … + (x n + y n )  T = S + 0 + … + (x k + y k ) + … + 0  T = S + x k + y k

16  If S = 0  T = 0 + x k + y k ≠ 0, regardless of move  If S ≠ 0  Let d be the position of the most significant non- zero bit in S  Choose k such that the value of x k in position d is also non-zero (such a k must exist)  Move such that y k = S + x k

17 S = 101 x 1 = 010 x 2 = 011 x 3 = 100 101 100 001 = S + x k y 3 = 001 

18  T = S + x k + y k  T = S + x k + (S + x k )  T = (S + S) + (x k + x k )  T = 0

19  When the next move will result in no remaining heaps of size ≥ 2  Normal play:Move such that an even number of heaps of size 1 remain  Misère play:Move such that an odd number of heaps of size 1 remain

20  Player 1 can move so that an even number of heaps of size 1 remain (Note that this still follows the strategy that T = 0. )  Player 2 loses again.

21  Player 1 can move so that an odd number of heaps of size 1 remain Now T = 1. This is the only point where misère strategy differs from normal strategy.  Player 2 is forced to take the last object, losing the misère game. 

22


Download ppt "Benjamin Casey C S 329 E Spring 2009.  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and."

Similar presentations


Ads by Google