DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

In Wythoff's Game, Playing the Nim Strategy Is 22x Worse Than Closing Your Eyes

Wythoff's game is two piles. A move takes any number of stones from one pile, or the same number from both.

Delete that second clause and it is 2-pile Nim, whose answer everybody knows: keep the piles equal.

Play it: https://dev48.infy.uk/game/day76-wythoff.html

The diagonal move does not perturb the answer. It inverts it.

Across 4,004,001 positions, the Nim-safe set and the Wythoff-safe set share exactly one square — the empty board. Every other Nim-safe square is a one-move loss: your opponent takes the diagonal and you are done.

So the natural instinct — this is almost Nim, so the Nim answer is almost right — is not approximately right. It is maximally wrong, on every position where it applies.

Measured, not argued

Over all 20,024 won positions on a 200×200 board:

policy keeps the win
play the Nim rule 0.0294%
move at random 0.6497%

Closing your eyes is 22× better than applying the best-known theory for the game next door. Random play at least stumbles onto a safe square occasionally; the Nim rule steers deliberately onto the one set of squares that are all losses.

There is a closed form, and it is irrational

The safe squares are ⌊kφ⌋, ⌊kφ²⌋ with φ the golden ratio — checked against the full enumeration rather than quoted.

k:  1      2      3      4      5
    (1,2)  (3,5)  (4,7)  (6,10) (8,13)
Enter fullscreen mode Exit fullscreen mode

Two piles, one extra move, and the answer stops being combinatorial and starts being about Beatty sequences.

The transferable part

A game one clause away from a solved game does not inherit an approximate version of its solution. The safe set is a global property of the move set, and adding a move can permute it completely. "Almost the same game" is not a statement about strategies.

Verifier 4,494,815 asserts, 0 failures. Vanilla JavaScript, one file, no build step.

Top comments (0)