DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

Counting the Edges in Hackenbush Is Exactly a Coin Flip, at Every Even Length, Forever

Blue-Red Hackenbush is the first partizan game in this series: the two players do not share a move set. Blue cuts blue edges, Red cuts red ones. That single change destroys the machinery that solved Nim and Kayles — nimbers cannot exist here, because a nimber assumes both players face the same options.

Play it: https://dev48.infy.uk/game/day75-hackenbush.html

A position is worth a number

Not a nim-value: an exact dyadic rational. And that one number answers three questions at once.

the number what it tells you
its sign who wins
its size by how much
keep it as large as you can a winning strategy

All three are checked rather than quoted. The sign called every one of 90,567 exhaustively solved pictures — 0 wrong — and playing for the number won 44,974 of 44,974 won positions across four seeds.

What a reasonable person does instead

Count the edges. Blue has more, so Blue is ahead. It sounds like a decent heuristic and on a single stalk it is exactly a coin flip:

It misses on exactly 2^(n−1) of the 2^n stalks of every even length.

0.500000 at length 2. 0.500000 at length 20. It never improves, because the error rate is not an approximation that tightens with size — it is a combinatorial identity.

a stalk of 20 edges: R at the ground, 19 B above it
edge count says   : Blue by 18
the value says    : negative  ->  Red wins
Enter fullscreen mode Exit fullscreen mode

The bottom edge is the whole answer

On a single stalk, the edge touching the ground decides it — 0 exceptions in 2,097,150 stalks. Everything above it contributes a strictly smaller correction, which is exactly what "dyadic rational" is telling you: each successive edge is worth half the last.

So a single red edge at the ground with nineteen blue above it belongs to Red, and no amount of counting will say so.

Verifier 5,479,563 asserts, 7,913,320 in-page assertions over 53 checks, 0 failures.

Top comments (0)