Define P-position as the winning position of the previous player; N-position as the winning position of the next player.
For example, take {1, 4} in the stone game.
N means that the first mover who immediately takes the next step will win, and P means the first mover will lose.
x is the number of stones, and pos represents the state.
1. When the stone is 0, the first player will lose. When x = 1, the first mover wins. When x = 2, the player who moves first must lose. At this time, because 2 - 1 = 1, it is known from the previous x = 1 that the player who moves first will win when x = 1, so the player who moves first must lose when x = 2. (This sentence is very important to understand well) Others and so on.
2. When x = 6, when taking a stone first, 6 - 1 = 5. In the state of x = 5, the first hand will lose, so x = 6, the first hand will win.
Notice:
The victory here is that as long as one of them can launch a certain victory, he will win, because if both of them want to win, they must rely on the winning one.