# What Is The Idea Behind Winning A Game Called Nim?

Okay, so I'm currently trying to win a game called Nim, but with little to no success in the case of larger boards. For those who might not be too familiar with the game, it is essentially a board with several rows(usually 6), each containing one or more pieces. Two players would take turns removing pieces from... show more Okay, so I'm currently trying to win a game called Nim, but with little to no success in the case of larger boards. For those who might not be too familiar with the game, it is essentially a board with several rows(usually 6), each containing one or more pieces. Two players would take turns removing pieces from the board. Each time a move is made, the player can only remove pieces from one row. The player who forces his or her opponent to take the last piece wins.

Now I've been trying to devise a strategy to beat the computer at Nim and have decided to divide the pieces into units, each unit containing at least a piece. I would force the computer to make several moves in such a way that when it's my turn, there'd be an even number of rows containing pieces of which only one row could contain more than one piece. I'd then remove all the pieces on the row containing more than one piece and this would undoubtedly guarantee me a victory. However, I'm unable to force the computer to make such a combination of moves.

Some experts have implied that if there are n pieces on the board and log₂n is an integer(or maybe there just needs to be an even number of pieces, I'm not too sure), one would have to group the pieces into 1s, 2s and 4s(the maximum number of pieces in a row is 7, so 2² is the maximum number of pieces in any of the groups). Each time the opponent makes a move, one would have to ensure that there is an even number of 2⁰s, 2¹s and 2²s on the board. Unfortunately, I'm unable to spot the rule/law/logical reason which explains why exactly this is so. Could some of you please share your insight and explain this as well as tell me if my strategy is plausible or not? I have attached two screenshots of the game, each of a different board size.
http://i.imgur.com/bksI2Dp.png
http://i.imgur.com/n9CMew9.png