Combinatorial Game Theory – Optimal Strategy for Nim Generalisation

combinatorial-game-theory

Consider the following game:

There are a number of piles of stones. On each turn a player can remove as many stones he likes (at least 1) from up to $N$ piles (at least 1). It is allowed to remove a different amount of stones from each of the up to $N$ piles. The first player that can't move loses.

For $N=1$ we have the original game of nim with its well known optimal strategy.

For $N \geq$ number of piles the obvious optimal strategy is to remove all the stones.

What is the optimal strategy for $N=2,3,..$?

Extra question: What is the sprague-grundy value for these games?

Best Answer

The winning strategy is described under section "Index-k Nim" in http://en.wikipedia.org/wiki/Nim.

In short: Instead of doing arithmetic in $Z_2^\infty$, you do it in $Z_{k+1}^\infty$ and choose a move that leaves you with $0$ as a result.

For example, let us consider $N=2$ and three piles of sizes $5,8,10$. The sizes in binary are $101$, $1000$ and $1010$. Their bitwise sum modulo $N+1 = 3$ is $2111$. Remove $3$ stones from the second and $5$ from the third pile to get new pile sizes $101,101,101$, whose mod $3$ sum is $0$.