The Winning Strategy of Nim: A Strategic Game Analysis by Jason Jebbia

Slide Note
Embed
Share

In this comprehensive presentation, the origins and rules of the strategic game Nim are explored. Charles Bouton's contributions to the game's theory are highlighted, along with its variations and winning strategies. The importance of Nim in impartial games using the Sprague-Grundy Theorem is discussed. Players take turns removing objects from piles, aiming to strategically convert losing positions into winning ones based on the Nim sum. 0 0 1 1 0 0 1 0 1 0 0 0.


Uploaded on Oct 03, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. And its Winning Strategy By Jason Jebbia

  2. 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

  3. 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

  4. Game starts with a number of piles (or rows, columns, etc.) and a number of objects (pennies, peanuts, counters, etc.) in each pile. Example

  5. 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

  6. 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

  7. *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

  8. Example Binary 1 1 1 7 = 4 = 1 0 0 5 = 1 0 1 1 1 0 Nim Sum

  9. 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.

  10. 0 0 1 1 0 0 1 0 1 0 0 0 = = = 1 4 5 7 = 4 = 5 = 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 0 0 = = = 7 2 5 1 1 1 1 0 0 0 1 1 0 0 0 = = = 7 4 3

  11. 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

  12. 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. 7 = 4 = 5 = 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 = 0 1 0 = 1 0 1 = 0 0 0 7 2 5

  13. 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

  14. 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

  15. 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).

  16. 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.

  17. 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.

  18. 1 0 0 0 1 0 0 0 1 1 1 1 = = = 4 2 1 0 1 1 0 1 0 0 0 1 0 0 0 = = = 3 2 1 0 0 1 0 1 0 0 0 1 0 1 0 = = = 1 2 1 0 0 1 0 0 1 0 0 1 = = = 1 1 1 0 0 0 0 0 1 0 0 1 = = = 0 1 1 0 0 0 0 0 1 0 0 0 = = = 0 1 0

  19. 1 0 0 0 1 0 0 0 1 1 1 1 = = = 4 2 1 0 1 1 0 1 0 0 0 1 0 0 0 = = = 3 2 1 0 1 0 0 1 0 0 0 1 0 0 1 = = = 2 2 1 0 0 1 0 0 1 0 0 0 0 0 0 = = = 2 2 0 0 0 1 0 1 0 0 0 0 0 1 1 = = = 1 2 0 0 1 0 0 0 0 0 0 0 = = = 1 0 0

  20. 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.

  21. 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!

  22. 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.

  23. Example : k = 4 Pile Sizes 11 14 9 13 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! Residue Piles = 1 (mod 5) = 4 (mod 5) = 4 (mod 5) = 3 (mod 5) Binary 0 0 1 1 0 0 1 0 0 0 1 1 0 1 0

  24. 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

  25. 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)

  26. The Game of Nim The winning strategy of Nim Mis re and Bounded Nim The Sprague-Grundy Theorem of Impartial Games

  27. To: Professor Tamas Lengyel Professor Ron Buckmire Professor Eric Sundberg

  28. [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

More Related Content