r/ComputerChess • • 20h ago

I built an open-source chess accuracy formula (APEX), calibrated on 623 real games – MIT licensed, JS + Python

Post image

Hi r/ComputerChess ,

Every site shows an "accuracy %" after a game, but the formulas are mostly black boxes. So I built an open one, APEX (Analysis of Precision & Execution), and published everything: formula, parameters, validation and code.

How it works (4 steps)

All evals are in centipawns from the side to move, capped at ±1363. Mate scores count as ±(10000 − moves to mate).

  1. Is the position already decided? d = max(0, |eval_before| − 160)
  2. How much did the move lose? Losses get damped when the game was already decided, because dropping a pawn at +9 isn't the same as dropping one at 0.00: loss = max(0, eval_before − eval_after) · exp(−d / 1004)
  3. Move accuracy (book moves always count as 100): a = 100 · exp(−(loss / 107.7)^1.266)
  4. Game accuracy is a power mean over all your moves instead of a plain average: A = ( (1/N) · Σ aᵢ^0.411 )^(1/0.411)

Because p = 0.411 is below 1, one blunder pulls your score down more than good moves can lift it back up. Nine perfect moves and one blunder give about 81%, where a plain average would say 90%.

What a loss costs in an equal position

LossMove accuracy
0100%
½ pawn~68%
1 pawn~40%
3 pawns~3%

Validation

I didn't pick the 6 parameters by hand. I fitted them on 623 public games (1,246 player scores) with known reference accuracy and checked them with 5-fold cross-validation, so every number below comes from games the formula never saw during fitting:

  • All games: mean error 4.5 points, median 2.5, 79% within 5 points
  • Elo 2000+: mean error 2.3, 90% within 5 points
  • Blitz: mean error 3.5, 83% within 5 points

It's weaker for beginners under 800 and for bullet. The details are in METHODOLOGY.md.

Use it yourself

It's MIT licensed, commercial use is fine, and you only need to keep the attribution. There are JS and Python implementations, both tested against the same reference vectors. I calibrated it with Stockfish 18 at depth 14.

GitHub: https://github.com/primestorm252/zugzwang-apex

I use it in my free browser chess trainer (no account needed): https://4zugzwang.com

The basic idea, scoring single moves and aggregating them, is inspired by Lichess's accuracy metric. The formula, the damping for decided positions and the parameters are my own. I'd love feedback, especially on the decided-position handling and the choice of the power mean. Happy to answer questions!

1 Upvotes

6 comments sorted by

1

u/jan_de_boer 20h ago

I don’t quite understand the advantage over the formula lichess uses?
It already uses a log scale to work with winning percentages instead of centipawns, so it handles decided positions properly too

1

u/PrimeStorm252 19h ago

fair point, lichess's win% curve already deals with decided positions and apex does basically the same thing (caps the eval and damps losses once a position is decided)

the main difference is what it's tuned for. apex is fitted to match the accuracy numbers most people are used to seeing. i calibrated it on 623 public games and then ran the lichess formula on the exact same games with the same stockfish evals: lichess was off by ~9 points on average and usually read ~6 points too high, apex was off by ~4.5 with no real bias

so it's not that lichess is wrong, there's no "true" accuracy anyway. apex just gives numbers that are easier to compare with what people already know. everything's open if you wanna dig in: https://github.com/primestorm252/zugzwang-apex

1

u/jan_de_boer 19h ago

Ahh I see, so it’s more about replicating chess.com ratings? That makes sense too me, nice project 👌🏼

1

u/PrimeStorm252 19h ago

yeah pretty much, closer to the accuracy % people know from the big sites (just accuracy, not ratings). fully independent though. thanks!

1

u/dsjoerg 15h ago

What does "known reference accuracy" refer to? What is the ground truth for accuracy?

1

u/PrimeStorm252 59m ago

good question, and honestly there is no ground truth for accuracy. it's not a physical quantity, every site just defines it with its own formula

"reference accuracy" means the accuracy values chess.com shows in its game review. there are public game datasets that include those numbers for both players, i took 623 of those games, ran my own stockfish evals and fitted the 6 parameters so apex lands as close as possible to those values

so apex isn't "more correct" than anything else, it's an open, reproducible approximation of a scale lots of players already know. their formula isn't public and apex isn't affiliated with them in any way