How to know if a pile in “Grundy’s game” have a winning strategy

combinatorial-game-theorydiscrete mathematics

Assume that I'm playing Grundy's game and I have pile of $n$ coins.
I want to know if I have a winning strategy (no matter what is it). How can I know if there is?

I understand the transform to Nim heap, but I don't understand how it can tell me if there is a winning strategy or not:
For example: Wikipedia says that pile of 18 equals to Nim heap at size 4, but if I have one pile at Nim, no matter what the size is – I can win at the first move.

So my question is: for a pile of size $n$ at Grundy's game how can I know if there a winning strategy or not? (for any size of pile) and if someone can explain me the idea of transform it to Nim heap it will be great (as I said – I don't understand the transform idea, because pile of any size at Nim have a winning strategy).

Thank you!

Best Answer

It helps to know what it means to say that a Grundy game with 18 tokens is equivalent to a Nim heap of size 4. Imagine you have two tables, one playing the Grundy game with a single 18 token pile, and one playing Nim with a single 4 token pile. One player makes a legal move on one of the games, and then the other player makes a move on either the same game or the other game, and so on. (That's the combination in combinatorial game theory.) Since those two games are equivalent, we can conclude that the second player will always be able to win by making a balancing move on the game that the first player did not choose for their move.

So, just like Nim, you win in Grundy's game if the nim-sum of nimbers of all the piles is not equal to 0, and you win by making a move that leaves the nim-sum equal to 0. Here is the list of nim-values of single piles (from the wiki):

enter image description here

We can see that 3 and 15 both have a nim-value of 1. So if we split the pile of 18 into 3 and 15, the nim-sum left to our opponent is $1+1=0$, so they will lose if we keep up with optimal play.

Related Question