DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

In Undercut the Optimal Strategy Never Names 1 or 2, and the Closed Form Breaks at n=7

Undercut is two players naming a number from 1 to 5 at the same time. You score your number — unless you named exactly one less than the other player, in which case you score both.

Play it: https://dev48.infy.uk/game/day78-undercut.html

It is the smallest game I know of where the best strategy is provably random. Not "mix it up so you're unpredictable" — a theorem, with an exact price on every deterministic alternative.

Nothing here is a float

Payoffs are integers. The equilibrium is solved by support enumeration over rationals with BigInt numerator and denominator. Exploitability is a rational compared by cross-multiplication. "Unexploitable" means n === 0n, not Math.abs(v) < 1e-9.

The equilibrium refuses two of your five options

say 1 :  0
say 2 :  0
say 3 :  4/9
say 4 :  2/9
say 5 :  1/3
Enter fullscreen mode Exit fullscreen mode

Weight exactly zero on 1 and 2. And they are not merely suboptimal — playing them hands an informed opponent 26/9 and 5/9 a round respectively.

Randomness is necessary and nowhere near sufficient

strategy exploitable for
always say 3 (best pure) 2
"undercut the top" (always 4) 3
a fair die over all five 6/5
the equilibrium 0

The fair die beats every pure strategy — and still leaks, because 40% of its weight goes on the two numbers the equilibrium refuses to name at all. "Just randomise" is half an answer.

The part that went against the build

Solving every board from 2 to 9, a pattern appears immediately. From n=4 the support is the top three numbers with weights (n−1, 2, n−2) / (2n−1):

n equilibrium closed form
4 3/7, 2/7, 2/7 ✅ fits
5 4/9, 2/9, 1/3 ✅ fits
6 5/11, 2/11, 4/11 ✅ fits
7 5/11, 2/11, 4/11, 0 🔴 breaks

Three consecutive sizes is enough to feel certain. At n=7 the formula predicts weight on the number 7 and the truth puts exactly zero there — the n=7 equilibrium is byte-for-byte the n=6 one. Adding an option changed the answer not at all.

By n=8 and n=9 the support widens to five numbers and the denominators reach 123 and 165. No pattern left to see.

Checked twice, by two methods that share no code

The page solves by support enumeration over rationals. The verifier solves by fictitious play in integers — no linear algebra, no rationals at all — and the two agree. 194 asserts, 0 failures.

That verifier also caught my own arithmetic: I had asserted payoff(2,3) === 3, when 2 undercutting 3 scores 5 against their 3, a margin of 2. The engine was right and the test was wrong.

Top comments (0)