Title: from one of a number of piles.

Title: How To Win At NimQED ProjectMuhammad SaeedSkinner NorthAbstractNim is a traditional game played with two players  in which two players alternatively take at least one object or more from one of a number of piles. You may only take an object from 1 pile. Whoever takes the last object wins. If you are playing with one pile, the person who starts can win by taking the whole pile. Playing with two rows, you can win by copying the other players move and keep the rows equal. If we keep an even number of 1’s in each binary position to keep the game balanced,we can win.Introduction What Is Nim? Nim is a two player mathematical game, played with any  number of objects (coins, sticks, counters, etc) arranged in piles. The number of objects and piles could be as many as one would like. Players alternate turns and on each turn a player can remove as many objects as they want but only from one pile. The player can’t take objects from more than one pile.  In the normal version of Nim, which is the one I will be discussing the player who takes the last object wins. In the other version (also known as the Misere version) the player who takes the last object loses (Wood, 2013).History Of Nim The game of Nim originated in China where it was called Jianshizi or picking stones. “But the origin remains uncertain and the current name of this game is a loan word from the German verb nimm (meaning take)” (Sarcone, 2009). “The name Nim and winning strategy were first described and proved in a math research paper by Charles Burton in 1901” (Sarcone, 2009) Nim style games however have existed for centuries and its first references date back to the 15th century. Nim has even gained popularity as a computer game. For the 1940s World’s Fair Westinghouse developed one of the first computer games “Nimatron” (Bruckner, 2000).How To Win At NimGame Of Nim With One Pile The game Nim isn’t purely won by luck it is a game of logic and strategy. As we know the game Nim can be played with any number of piles so suppose the game is played with one pile. Whoever goes first can easily win by talking all of the objects but that isn’t very challenging because whoever goes first has a huge advantage.Game Of Nim With Two RowsWhen there are two rows the key to winning is to make the rows equal. One can do this by copying the other player’s moves and keeping the rows balanced.In this example the game is played with two rows between You and IA    B7    5              The game starts with the rows unbalanced row A has 7 row B has 5.           5    5               To balance the piles I remove two objects from pile A.3     5               You unbalance the rows by removing two objects from pile A and A has 3 objects.3     3                I then balance the rows by removing two from Pile B.1     3                You unbalance the rows and remove two from Pile A.1     1                 I balance the rows by removing two from pile B 0      1                You unbalance the rows by removing one from pile A 0      0                 I balance the rows by removing one from pile B, take the last object, and win.From this game one can conclude that whoever balances the rows and keeps the rows balanced will eventually win the game. This is because once the game is balanced any move will unbalance it. So to win one must balance it ( if it isn’t already) and then copy the other players moves and eventually take the last object and win.Binary Numbers And Base 10 Humans are typically endowed with 10 fingers and 10 toes so we developed our earliest number system on base 10.Decimal= Base 10Digits= 0, 1, 2, 3, 4, 5, 6, 7, 8, 910^0= 10, 10^1= 10, 10^2= 100, 10^3= 1000….For example 1,574 could also be represented as 1*(10^3) + 5*(10^2) + 7*(10^1) + 5*(10^0)However the Base 10 system isn’t the only system there are many other systems with one of them being the Binary system. The binary system is based on the number 2. In the Binary system there are only two numbers 0 and 1.2^0= 1,  2^1= 2,  2^2= 4,  2^3= 8,  2^4= 16,  2^5= 32…If one were to express the number 13 in binary it would be 1101. This is because it has 1 group of 8 1 group of 4 no groups 2 and one group of 1.Winning StrategyIf there are more than two rows then one can win by converting each row to a binary number and each row should be broken into increasing powers of 2. The person who eventually keeps the balance will win. Suppose one has four rows. Row 1 has 1 object so therefore a group of one is the only option. Row two has three objects so one can do  a group of 2 and group of 1. Our third row has 5 so we can do a group of 4 and a group of 1. Finally, the fourth row with 7 objects can be represented as 1 group of 4, 1 group of 2 and one group of 1. Objects 4211001301151017111count2= even2= even4= evenThe winning strategy is to keep the game balanced. If the number of rows with the power of 2 grouping is even, the group is balanced, and in turn, the game is balanced. If we look up 4 rows have a group of 1, that means it is balanced. Two rows have a group of 2, which is also balanced. 2 rows have a group of 4, which is also balanced. If we have an even number of each group, the game is balanced. Our goal is to keep an even number of 1’s in each binary position. A column is balanced if there are an even number of 1’s. A game is balanced if all the columns are balanced. Now let’s play a game and see how keeping the game in a balanced position helps someone win. Since the game is balanced we take it from Player 2’s perspective whose goal is to always keep the game balanced.A    B    C    D 1     3     5       7     1     3      5       4             Player 1 takes three objects from row D                                             Player two thinks of each row as a power of 2. Now it has two groups of                                         4, 1 group of 2, and 3 groups of 1. The group of 2 and 1 aren’t balanced                                         Because there is an odd number of each. 1    0    5    4                     Player 2 removes the whole row B to make it balanced1    0    3    4                     Player 1 takes 2 objects from row C.                                          Player 2 examines and sees he has one group of 4, one group of 2 and                                           2 groups of 1. A group of 4 and 1 aren’t balanced.1    0    3    2             Player 2 took two objects from row D to balance the rows now again he has                                  2 groups of 2 and 2 groups of 1. 1    0    3    1             Player 1 takes 1 object from row D and makes it unbalanced.                                 Player 2 sees that he has 3 groups of 1 and 1 group of 2.1    0    0    1             Player 2 takes 3 objects from row C to make it balanced. 0    0    0    1             Player 1 takes 1 object from row A0    0    0    0             Player 2 takes the last object and wins the game. How To Change Unbalanced Game To Balanced GameThe first step to changing an unbalanced game to a balanced game is to find the highest power of 2 groups that isn’t balanced. Next, choose a row with one in that column. Then, flip 1 to 0 and 0 to 1 in every column that isn’t balanced. The difference between the old numbers and the new numbers is how many objects to remove from that row.Objects84211000130011501013001191001countOddOddEvenOddChange This 91001To ThisCountOddOddEvenOdd40100To determine the amount of objects to remove we subtract the old value from new value which is 9-4=5 so we remove 5 objects from the last row to make the game balanced.Conclusion If you look at the word Nim and turn it upside down you will get Win. This makes me think that Nim isn’t a game of pure luck and there are certainly strategies for the game that will help you win. The main strategy is to make the game balanced and keep the game balanced. If a game of Nim is currently balanced then every possible move will make it unbalanced. If the game is currently unbalanced then there exists some move that will make it balanced. When playing with two rows,  the strategy is to balance the rows by copying the other person. When dealing with more than two rows change the numbers into binary. If the game is balanced every move will change some binary digit one from the column to 0. Hence, the binary position which previously had an even number of ones are now odd numbers. Now the game is unbalanced now you must keep the game balanced until the end and you will win. Works CitedNymathcircle.org. (2017). Cite a Website – Cite This For Me. online Available at: https://www.nymathcircle.org/static/docs/2013/20131021nimjimhandout.pdf Accessed 2 Dec. 2017.Web.mit.edu. (2017). Cite a Website – Cite This For Me. online Available at: http://web.mit.edu/sp.268/www/nim.pdfPo?lya, G. (2009). Mathematical discovery. New York: Ishi Press.