the game of nim n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Game Of Nim PowerPoint Presentation
Download Presentation
The Game Of Nim

Loading in 2 Seconds...

play fullscreen
1 / 28

The Game Of Nim - PowerPoint PPT Presentation


  • 172 Views
  • Uploaded on

The Game Of Nim. And its Winning Strategy By Jason Jebbia. The Game of Nim. In this presentation I will: Introduce the game play and rules of the game of Nim Demonstrate the winning strategy of Nim Discuss other variations of Nim including their winning strategies.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The Game Of Nim' - barney


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
the game of nim

The Game Of Nim

And its Winning Strategy

By Jason Jebbia

the game of nim1
The Game of Nim
  • In this presentation I will:
    • Introduce the game play and rules of the game of Nim
    • Demonstrate the winning strategy of Nim
    • Discuss other variations of Nim including their winning strategies.
    • Discuss the importance of Nim to other impartial games using the Sprague-Grundy Theorem
history of nim
History of Nim
  • Origins of the game are uncertain
  • Charles Bouton, 1901
    • Coined the name “Nim” for the game
    • Developed a complete theory of the game, including a winning strategy
rules of nim
Rules of Nim
  • Game starts with a number of piles (or rows, columns, etc.) and a number of objects (pennies, peanuts, counters, etc.) in each pile.
  • Example
rules of nim1
Rules of Nim
  • Two Player Game
  • Players take turns
  • On each turn, a player must choose one pile and remove at least one object from the chosen pile.
  • Example
rules of nim2
Rules of Nim
  • Two ways to play:
    • Normal Play: the player who removes the last object is the winner
    • Misère Play: the player who removes the last object is the loser
winning strategy
Winning Strategy
  • *For the normal play convention
  • Convert the size of each pile into its binary notation
  • Add the columns up independently modulo 2.
  • The resulting value is called the Nim sum
winning strategy1
Winning Strategy
  • Example

Binary

  • 7 = 1 1 1
  • 4 = 1 0 0
  • 5 = 1 0 1

1 1 0

Nim Sum

winning losing positions
Winning/Losing Positions
  • A winning position occurs when the Nim sum equal zero
  • A losing position occurs when the Nim sum is greater than zero
  • A player can always make a move from a losing position to a winning one.
  • Once in a winning position, the next move will always result in a losing position
  • Therefore, the optimal strategy is to always be converting losing positions to winning positions on each move.
winning strategy2
Winning Strategy
  • 7 = 1 1 1
  • 4 = 1 0 0
  • 5 = 1 0 1 1 1 0

0 0 1 = 1

1 0 0 = 4

1 0 1 = 5

0 0 0

1 1 1 = 7

0 1 0 = 2

1 0 1 = 5

0 0 0

1 1 1 = 7

1 0 0 = 4

0 1 1 = 3

0 0 0

winning strategy3
Winning Strategy
  • Intuition
    • If the Nim sum is greater than 0, then we know that at least one of the column sums is 1.

7 = 1 1 1

4 = 1 0 0

5 = 1 0 1

1 1 0

winning strategy4
Winning Strategy
  • Intuition
    • Thus, a player can convert a losing position into a winning one by changing the digits in the columns where the Nim sums are 1 starting with the left most column where the column sum is 1.

= 1 1 1

= 1 0 0

= 1 0 1

1 1 0

1 1 1 = 7

0 1 0 = 2

1 0 1 = 5

0 0 0

winning strategy5
Winning Strategy
  • Intuition:
    • If a player moves to a winning position, then the Nim sum equals 0. If this is not the final position (no objects left on the table), then every digit that is a 1 will have a corresponding 1 in a different row that will result in a column Nim sum of 0.

0 0 1

1 0 0

1 0 1

0 0 0

winning strategy6
Winning Strategy
  • Intuition
    • Thus, any move from a winning position will result in a losing position, then, since a player will change one, and only one, row of digits on a given move creating a new Nim sum.

1 = 0 0 1

4 = 1 0 0

5 = 1 0 1

0 0 0

winning strategy7
Winning Strategy
  • Two Absolutes:
    • 1. A player cannot move from a winning position back to a winning position (Nim Sum = 0)
    • 2. Every losing position (Nim Sum > 0) has an allowable move to a winning position.
  • Thus the winning strategy is to continue making moves converting losing positions to winning positions until the ultimate winning position is achieved (No more objects on the table).
winning strategy8
Winning Strategy
  • Of course, this assumes the other player does not know the winning strategy as well.
  • If both players know the winning strategy and play without error, then the winner can be determined by the starting position of the game.
  • If the game starts in a losing position, then the first player to move will ultimately win.
  • If the game starts in winning position, then the second player to move will ultimately win.
mis re nim
Misère Nim
  • The player who removes the last object loses!
  • Therefore, the goal is to leave the last object for your opponent to take
  • Winning Strategy:
    • Play exactly like you would in normal play until your opponent leaves one pile of size greater than one.
    • At this point, reduce this pile to size 1 or 0, whichever leaves an odd number of piles with only one object.
mis re nim1
Misère Nim

1 0 0 = 4 0 1 1 = 3

0 1 0 = 2 0 1 0 = 2

0 0 1 = 1 0 0 1 = 1

1 1 1 0 0 0

0 0 1 = 1 0 0 1 = 1

0 1 0 = 2 0 0 1 = 1

0 0 1 = 1 0 0 1 = 1

0 1 0

0 0 0 = 0 0 0 0 = 0

0 0 1 = 1 0 0 1 = 1

0 0 1 = 1 0 0 0 = 0

mis re nim2
Misère Nim

1 0 0 = 4 0 1 1 = 3

0 1 0 = 2 0 1 0 = 2

0 0 1 = 1 0 0 1 = 1

1 1 1 0 0 0

0 1 0 = 2 0 0 1 = 2

0 1 0 = 2 0 0 1 = 2

0 0 1 = 1 0 0 0 = 0

0 0 1 0 0 0

0 0 1 = 1 0 1 0 = 1

0 1 0 = 2 0 0 0 = 0

0 0 0 = 0 0 0 0 = 0

0 1 1

mis re nim3
Misère Nim
  • Why this works
    • Optimal play from normal Nim will never leave you with exactly one pile of size greater than one (because this leaves a losing position).
    • Your opponent can’t move from two piles of size greater than one to no piles of size greater than one.
    • So eventually your opponent must make a move that leaves only one pile of size greater than one.
bounded nim
Bounded Nim
  • Same game as the normal version of Nim except one restriction.
  • Restriction: An upper limit, k, is placed on the amount of objects that may be selected on a given turn. So a player may remove 1≤ m ≤ k objects on each turn.
  • Once again, the winning strategy is very much like the normal game!
bounded nim1
Bounded Nim
  • Winning Strategy:
    • Convert each pile into a “residue pile” by reducing each pile modulo (k + 1).
    • Perform the same Nim Sum operation on these new piles
    • Then, make the same moves to the actual piles that you would to make the residue piles into a Nim sum of 0.
bounded nim2
Bounded Nim
  • Example : k = 4

Pile SizesResidue PilesBinary

11 = 1 (mod 5) 0 0 1

14 = 4 (mod 5) 1 0 0

9 = 4 (mod 5) 1 0 0

13 = 3 (mod 5) 0 1 1

0 1 0

  • The Nim sum is not 0, so this is a losing position. Therefore, we would continue to use the same strategy as we would in normal play to make the Nim sum of the residue piles equal zero!
importance of nim
Importance of Nim
  • Nim is an Impartial game.
  • Impartial game:
    • Combinatorial Game
      • Two-players, Perfect Information, no moves are left to chance (so poker is not a combinatorial game)
    • * Any play available to one player must be available to the other as well
    • Examples: Hackenbush, Kayles, and Sprouts
  • Partizan Game
    • Combinatorial Game
    • *Players have different sets of possible moves
    • Examples: Chess, Checkers, and Go
importance of nim1
Importance of Nim
  • Sprague-Grundy Theorem:
    • Every impartial game in its normal play convention is equivalent to some Nim pile using the Sprague-Grundy Function
    • Using this Sprague Grundy function, every impartial game gets assigned a Nim pile value that allows us to analyze the game.
    • Discovered independently by R. P. Sprague (1935) and P. M. Grundy (1939)
what have we learned
What have we learned?
  • The Game of Nim
  • The winning strategy of Nim
  • Misère and Bounded Nim
  • The Sprague-Grundy Theorem of Impartial Games
special thanks
Special Thanks
  • To:
    • Professor TamasLengyel
    • Professor Ron Buckmire
    • Professor Eric Sundberg
references
References
  • [1] E. R. Berlekamp, J. H. Conway and R. K. Guy (1982) Winning Ways for your mathematical plays, vols. 1 and 2, Academic Press, New York.
  • [2] C. L. Bouton (1902) Nim, a game with a complete mathematical theory, Ann. Math. 3, 35-39.
  • [3] J. H. Conway (1976) On Numbers and Games, Academic Press, New York.
  • [4] E. H. Moore (1910) A generalization of a game called nim, Ann. Math. 11, 93-94
  • [5] J. G. Baron (1974) The Game of Nim-A Heuristic Approach. Mathematics Magazine 47.1, 23-28.
  • [6] B. L. Schwartz (1971) Extensions of NIM, Mathematics Magazine 44.5, 252-57.
  • [7] G.H. Hardy and E.M. Wright (1960), An Introduction to the Theory of Numbers, 4th ed., Oxford, Clarendon Press, 117-120