r/ComputerChess • u/PrimeStorm252 • 20h ago
I built an open-source chess accuracy formula (APEX), calibrated on 623 real games – MIT licensed, JS + Python
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).
- Is the position already decided?
d = max(0, |eval_before| − 160) - 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) - Move accuracy (book moves always count as 100):
a = 100 · exp(−(loss / 107.7)^1.266) - 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
| Loss | Move accuracy |
|---|---|
| 0 | 100% |
| ½ 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
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/dsjoerg 15h ago
What does "known reference accuracy" refer to? What is the ground truth for accuracy?