A MATLAB program related to Wythoff’s Game.
Wythoff’s Game1 is a two-player subtraction game2. The following are the rules and setup of the game:
- There are 2 piles of chips
- Player A and B take turns to remove chips according to the following rules:
- Remove any positive number of chips from one of the piles or
- Remove the same positive number of chips from both piles
- The player removing the last chip wins
We want to determine the winning and losing positions of Wythoff’s Game.
In combinatorial games3, we introduce the definition of P-positions and N-positions. We say that a position is called a
- P-position if the player who makes the previous move has a winning strategy
- N-position if the player who makes the next move has a winning strategy
The classification of P-positions and N-positions can be carried out based on the following rules:
- Terminal position
$(0,0)$ is a P-position - A position which has a move to a P-position is a N-position
- A position which can ONLY move to a N-position is a P-position
We want to determine all P-positions and N-positions so as to find out the optimal strategy of the game.
Suppose there are 4 and 5 chips in the 1st and the 2nd pile. Denote
Step 1: Terminal position
0 | 1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|---|
0 | P | |||||
1 | ||||||
2 | ||||||
3 | ||||||
4 |
Step 2:
0 | 1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|---|
0 | P | N | N | N | N | N |
1 | N | N | ||||
2 | N | N | ||||
3 | N | N | ||||
4 | N | N |
Step 3:
0 | 1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|---|
0 | P | N | N | N | N | N |
1 | N | N | P | |||
2 | N | P | N | |||
3 | N | N | ||||
4 | N | N |
Repeat similar steps to find out all P-positions and N-positions
0 | 1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|---|
0 | P | N | N | N | N | N |
1 | N | N | P | N | N | N |
2 | N | P | N | N | N | N |
3 | N | N | N | N | N | P |
4 | N | N | N | N | N | N |
If there are 4 and 5 chips in the 1st and the 2nd pile,
then the P-positions are
Footnotes
-
Wikipedia contributors. (2023). Wythoff’s game. Wikipedia. https://en.wikipedia.org/wiki/Wythoff%27s_game ↩
-
Wikipedia contributors. (2023). Subtraction game. Wikipedia. https://en.wikipedia.org/wiki/Subtraction_game ↩
-
Combinatorial Games - Definition | Brilliant Math & Science Wiki. (n.d.). https://brilliant.org/wiki/combinatorial-games-definition/ ↩