# Define Grundy values

I want to helt to find out the grundy value to define a winning strategy for this game. Player 1 and 2 starts from position A where player 1 is the first one to move. The arrows show possibles ways that players can go. Lets say player 1 starts and the only possible way is from A to B. The next player to move is 2 where he has a possibility to move to C. What i know is that position D has grundy value 0 beacuse your are not able to go any way from there. But what what im uncertain in is the position in C where the player can choose to go to D or choose to go back to A. This type of game is called "loopy", since the graph of positions has a loop: $\begin{matrix}A\\\downarrow & \nwarrow\\B & \rightarrow & C\end{matrix}$

The Sprague-Grundy theory is only enough to handle loopfree games that don't have loops like this. However, there is a generalization of the theory that adds special values for positions that can generate draws (where the game goes on forever) in perfectly played sums. You can find detailed discussion of the generalized Sprague-Grundy theory on MathOverflow at https://mathoverflow.net/a/149084/28209

For the particular game in the question, it turns out we don't need any of the new values, though we do need some of the ideas of the generalized theory. Essentially, we look to discover the Grundy values one step at a time, using what we learned in previous steps (when we never find values this way is when the new values would be needed). I'll outline how this is done:

### Stage 0

We know that since $D$ is a terminal position, the Grundy value of $D$ should be 0. We don't know anything about the other positions yet.

### Stage 1

We know that the only option from $A$ is to $B$. Since we don't know if $B$ has value $0$, maybe $A$ has no move to value $0$ so that it would have to have value $0$ itself. We should check that any move from $A$ to a position with unknown value can be reversed back to $0$. But after a move from $A$ to $B$, the next move would be to $C$, whose value we don't know yet, so we can't figure out $A$'s value right now.

We know that the only options from $C$ are to $A$ and $D$ (which has value $0$). Since we don't know if $A$ has value $1$, maybe $C$ has no move to value $1$ so that it would have to have value $1$ itself. We should check that any move from $C$ to a position with unknown value can be reversed back to $1$. But after a move from $C$ to $A$, the next move would be to $B$, whose value we don't know yet, so we can't figure out $C$'s value right now. However, we know that $C$ doesn't have value $0$ (thanks Ross Millikan) since there's a move from $C$ to the value-$0$ position $D$.

We know that the only option from $B$ is $C$. Since we know that $C$ doesn't have value $0$, $B$ has no move to value $0$ so that it would have to have value $0$ itself.

### Stage 2

After a move from $C$ to $A$, the next move would be to $B$, whose value is now known to be $0$, not the $1$ we were hoping for. Therefore, we still don't know $C$'s value.

Since the only move from $A$ is to $B$ (which has value $0$), we know $A$ must have value $1$.

### Stage 3

Finally, we now know that $C$'s options have value $0$ and $1$, so that $C$ has value $2$. In summary, we have the following values: $C:2,A:1,B:0,D:0$.

For many loopy games, this process wouldn't end in any finite number of stages. As in that kind of case, we would need new values other than natural numbers to describe positions with enough information to know how they play in sums. Basically, all of the positions with "unknown" values require us to keep track of all of the "known" values of their options if we want to know the outcome of a sum (next player wins, previous player wins, both players can force a draw).

• In stage 1 we can say C is definitely not zero because it can move to D, which is zero. Then since B can only move to C, it cannot move to zero, so its value must be zero. Then A is 1 and C is 2. Same result, a little quicker. – Ross Millikan Apr 18 '16 at 0:15
• @RossMillikan, good catch! I was following a formal definition closely without thinking. The argument "since B can only move to [something which can move to zero], its value must be zero" does work in general. – Mark S. Apr 18 '16 at 0:51