Chapter 26 Subtraction Games
Calculating the mex of a set of whole numbers.
Recall that \(\W = \{ 0,1,2,3, \ldots \}\text{.}\) For a subset \(S \subset \W\) the mex of \(S\) is the minimum excluded value
Calculating the Sprague-Grundy value of a game position.
Given a position \(X\) of a game with followers \(\cF(X) = \{ Y_1, Y_2, \ldots , Y_k \}\) The Sprague-Grundy value of the position is
This formula for the Sprague-Grundy value recursive: you is calculate the value for \(X\) by looking at the values of the followers. This is a lot like working your way back up a game tree to figure out whether \(X\) is an \(\cN\)-position or a \(\cP\)-position.
Subtraction Games.
A subtraction game \(S(k_1, k_2, \ldots , k_r)\) is a nim game with a single heap in which you are only allowed to remove \(k_1, k_2, \ldots , k_r\) beans on any given turn. We will use
to denote a heap of \(n\) beans. It will be helpful to be able to differentiate between the number \(n\) and the pile \(\pile{n}\text{.}\)
Exercises Practice Problems
1. Subtraction \(S(1,2,3,4)\).
-
Play \(S(1,2,3, 4)\) with pile sizes \(n=1,2,3, \ldots\text{.}\) Determine which pile sizes are \(\cP\)-positions and which ones are \(\cP\)-posititions.
\begin{equation*} \begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c} n & 0 & 1 & 2 & 3 & 4& 5 & 6 & 7 & 8& 9& 10 & 11 & 12 \\ \hline \hline \cP \mbox{ or } \cN? &&&&&&&&&&&& \end{array} \end{equation*} -
Calculate \(g(\pile{n})\) for the game \(S(1,2,3,4)\text{.}\)
\begin{equation*} \begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c} n & 0 & 1 & 2 & 3 & 4& 5 & 6 & 7 & 8& 9& 10 & 11 & 12 \\ \hline \hline g(\pile{n}) &&&&&&&&&&&& \end{array} \end{equation*} Compare your answers to (a) and (b). What do you observe? Make a conjecture about the relationship of the Sprague-Grundy value to the winner of the game.
2. Subtraction \(S(1,2,4)\).
-
Calculate \(g(\pile{n})\) for the game \(S(1,2,4)\text{.}\)
\begin{equation*} S(1,2,4): \qquad \begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c} n & 0 & 1 & 2 & 3 & 4& 5 & 6 & 7 & 8& 9& 10 & 11 & 12 \\ \hline \hline g(\pile{n}) &&&&&&&&&&&& \end{array} \end{equation*} Is \(\pile{8}\) an \(\cN\)-position or a \(\cP\)-position in \(S(1,2,4)\text{?}\) If it is an \(\cN\)-position, list every winning move.
Is \(\pile{9}\) an \(\cN\)-position or a \(\cP\)-position in \(S(1,2,4)\text{?}\) If it is an \(\cN\)-position, list every winning move.
3. Subtraction \(S(3,4)\).
-
Calculate \(g(\pile{n})\) for the game \(S(3,4)\) Note that there is no legal move for a pile of size 1 or of size 2, so \(g(\pile{1})=0\) and \(g(\pile{2})=0\text{.}\)
\begin{equation*} S(3,4): \qquad \begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c} n & 0 & 1 & 2 & 3 & 4& 5 & 6 & 7 & 8& 9& 10 & 11 & 12 \\ \hline \hline g(\pile{n}) &&&&&&&&&&&& \end{array} \end{equation*} Is \(\pile{8}\) an \(\cN\)-position or a \(\cP\)-position in \(S(3,4)\text{?}\) If it is an \(\cN\)-position, list every winning move.
Is \(\pile{10}\) an \(\cN\)-position or a \(\cP\)-position in \(S(3,4)\text{?}\) If it is an \(\cN\)-position, list every winning move.
4. Subtraction \(S(3,5)\).
Here is the table of Sprague-Grundy values for \(S(3,5)\)
Who wins the following games of \(S(3,5)\text{?}\)
\(\displaystyle \pile{4}\)
\(\displaystyle \pile{10}\)
\(\displaystyle \pile{14}\)
\(\displaystyle \pile{20}\)
5. Two-Heap Subtraction \(S(3,5)\).
Now let's play 2-heap \(S(3,5)\text{.}\) Just like 2-heap nim, you choose one pile and then make a valid move in that pile.
-
Play the following \(S(3,5)\) games to determine whether each one is an \(\cN\)-position or a \(\cP\)-position.
\(\displaystyle ( \pile{4} , \pile{4})\)
\(\displaystyle (\pile{4} , \pile{5})\)
\(\displaystyle (\pile{5} , \pile{6})\)
\(\displaystyle ( \pile{6} , \pile{7})\)
-
Now calculate the following nim sums \(g(\pile{n}) \oplus g(\pile{m})\) for the \(S(3,5)\) positions that you just played. What do you notice?
\(\displaystyle ( \pile{4} , \pile{4})\)
\(\displaystyle (\pile{4} , \pile{5})\)
\(\displaystyle (\pile{5} , \pile{6})\)
\(\displaystyle ( \pile{6} , \pile{7})\)
-
Decide whether the following \(S(3,5)\) positions are \(\cN\)-positions or \(\cP\)-positions. If it is an \(\cN\)-position, give the list of winning moves.
\(\displaystyle ( \pile{4} , \pile{11})\)
\(\displaystyle (\pile{7} , \pile{13})\)
\(\displaystyle (\pile{7} , \pile{14})\)
\(\displaystyle ( \pile{13} , \pile{18})\)
6. The Sprague-Grundy Value for Nim.
Recall that we use \(*n\) to denote a heap of \(n\) beans in nim.
What is \(g(*n)\text{,}\) the Sprague-Grundy value of a nim heap of size \(n\text{?}\) Start with \(n=0,1,2,3,\ldots\) until you see the pattern.
-
Calculate the Sprague-Grundy values of the following two-heap nim positions
\begin{equation*} \begin{array}{c|c|c|c|c|c} g(*n \oplus *m) & *0 & *1 & *2 & *3 & *4 \\ \hline \hline *0 &&&& & \\ \hline *1 &&&& & \\ \hline *2 &&&& & \\ \hline *3 &&&& & \\ \hline *4 &&&& & \\ \end{array} \end{equation*} -
Calculate the nim sum \(n \oplus m\)
\begin{equation*} \begin{array}{c|c|c|c|c|c} n \oplus m & 0 & 1 & 2 & 3 & 4 \\ \hline \hline 0 &&&& & \\ \hline 1 &&&& & \\ \hline 2 &&&& & \\ \hline 3 &&&& & \\ \hline 4 &&&& & \\ \end{array} \end{equation*} Compare your answers to problems 2 and 3. What do you observe?