amog.fun∘
kayles : Pins → Gutter

Kayles

A row of skittles. On your turn, bowl down one pin (click it) or two neighbouring pins at once (click the ball between them). Whoever knocks down the last pin wins.

Why Amog always wins

Pins are secretly heaps

Knocking pins splits the row into separate runs, and each run is its own little game. The Sprague–Grundy theorem says each run of $n$ pins behaves exactly like a Nim heap of size $G(n)$.

\begin{definition}$G(0) = 0$ and $G(n) = \operatorname{mex}\{\, G(a) \oplus G(b) : a + b = n - 1 \text{ or } a + b = n - 2 \,\}$, where $\operatorname{mex}$ is the smallest natural number not in the set.\end{definition}

\begin{theorem}[Sprague–Grundy]The row is a loss for the player to move exactly when the nim-sum of $G$ over all runs is $0$.\end{theorem}

\begin{remark}The values start $0, 1, 2, 3, 1, 4, 3, 2, 1, 4, 2, 6, \dots$ and, from $n = 71$ on, repeat with period $12$ (Guy and Smith, 1956). So Amog never really needs to count past 83.\end{remark}