Section 3.2 Subtraction Games
Let's calculate some examples of Sprague-Grundy values for some simple games. We'll get to Nim soon enough, but for now we explore a class of games called Subtraction Games. Our first game is namedExploration 3.2.1.
Play a few games of single heap
Exploration 3.2.2.
Find the Sprague-Grundy values for a few more subtraction games
Theorem 3.2.4.
The Sprague-Grundy values for the subtraction game
Proof.
Without loss of generality, we have \(s_1 < s_2 < \cdots < s_k\text{.}\)
For \(n \geq s_k\text{,}\) we have
Since there are only \(k\) followers, we have \(\g(\pile{n}) \leq k\text{,}\) with \(\g(\pile{n})=k\) precisely when the followers of \(\pile{n}\) take on the Sprague-Grundy values \(0,1,2,\ldots , k-1\) in some order.
Partition \(\W\) into disjoint sets \(B_0, B_1, \ldots, B_m, \ldots\) where \(B_0 = \{ 0, 1, 2, \ldots , s_{k}-1 \}\text{,}\) \(B_1 = \{ s_k, s_k + 1, \ldots, 2 s_k -1 \}\) and in general,
There are an infinite number of \(B_i\)'s. However, there are \((k+1)^{s_k}\) possibilities for the sequence of Sprague-Grundy values associated to each \(B_i\text{.}\) This means that these blocks Sprague-Grundy sequences of length \(s_k\) must repeat! In other words, there exists \(i \neq j\) such that \(B_i = B_j\text{.}\) Furthermore, there must be an infinite number of repeats (because there are only a finite number of possible blocks.
Next, we show that as soon as we encounter our first repeated block, we can be sure that the sequence has become periodic. Choose \(i < j\) such that \(B_i=B_j\text{,}\) and this is the first such pair of repeating blocks in the sequence. In other words, setting \(N=i \cdot s_k\) and \(M = j \cdot s_k\) we have
But this forces \(\g(\ppile{M + s_k}) = \g(\ppile{N + s_k}) \) because
This repetition continues (for the same exact reason). We have \(\g(\ppile{M + s_k+1}) = \g(\ppile{N + s_k+1}), \) and \(\g(\ppile{M + s_k+2}) = \g(\ppile{N + s_k+2})\text{,}\) and so on. Therefore, the sequences continue to coincide forever.