The exact formulas behind win probability, move classification, accuracy, and validated tactics in Chess Analyzer Pro.
This page documents the pipeline from a loaded PGN to the accuracy numbers on screen. Every value here is taken from the application source, not estimated.
Game loaded (PGN / Chess.com / Lichess)
│
▼
PGNParser → GameAnalysis + MoveAnalysis
│
▼
AnalysisWorker (QThread, keeps the UI responsive)
│
▼
EngineManager → Stockfish over UCI
│
▼
Per position: cache lookup → engine search → store Multi-PV
│
▼
Classify and aggregate:
├─ Win probability (logistic from centipawns)
├─ Win probability loss (WPL)
├─ Classification (priority rules)
├─ Book detection (SQLite + Polyglot)
├─ Per-move accuracy (exponential decay)
├─ Game accuracy (volatility-weighted + harmonic mean)
└─ Validated tactics (legal-capture SEE + engine/game confirmation)
│
├─► Live UI stream: badges, eval bar, best-move arrow
▼
Staged game saved to SQLite (completed / paused / not started)
│
▼
Report, Tactics, dashboard stats, and Coach facts
src/backend/storage/pgn_parser.py uses python-chess to build GameAnalysis and MoveAnalysis
records.
GameAnalysis: game_id, metadata, moves, summary, ai_summary, pgn_contentGameMetadata: white, black, event, date, result, headers starting_fen, white_elo, black_elo, time_control eco, termination, termination_mode, opening, source, chess960MoveAnalysis: move_number, ply, san, uci, fen_before eval_before_cp, eval_before_mate, best_move best_eval_cp, best_eval_mate, pv eval_after_cp, eval_after_mate win_chance_before, win_chance_after classification, explanation multi_pvs, summary time_left, time_spent, raw_clk is_book_move, book_move_count, book_exit_move eco, opening_name, candidate_continuations
[%clk] comments.UCI_Chess960 and boards are created
with chess960=True.game_id is md5(pgn_content), so importing the same game twice updates one record instead of
creating a duplicate.src/backend/analysis/engine.py owns a chess.engine.SimpleEngine subprocess and speaks UCI.
Path resolution order: configured engine_path → system PATH → platform install locations
(Homebrew, Program Files, /usr/games) → a previously downloaded binary in the app data folder.
| Parameter | Default | Note |
|---|---|---|
| Threads | 1 | Kept low to avoid thermal throttling |
| Hash | 128 MB | Transposition table |
| Depth | 18 | Full-game analysis |
| Time cap | 1.0s | Stops at time or depth, whichever comes first |
| Multi-PV | 2 | Full-game lines |
| Live Multi-PV | 2 | Live engine panel |
| Live time | 0.5s | Per position |
The engine is stopped in a finally block, and a new analysis restarts it rather than assuming it is
running.
src/backend/storage/cache.py checks the position cache before searching:
cache_key = SHA256(f"{fen}|multipv:{multi_pv}")
Cached results are depth-aware: a stored result is reused only when its depth is at least the requested depth. The database runs in WAL mode for concurrent reads.
src/backend/analysis/math_utils.py converts centipawns to a 0–1 win probability with a logistic
curve:
exponent = -0.00368208 * cp
wp = 1 / (1 + exp(exponent))
The result is White's win probability, because the stored scores are White-perspective.
Clamping:
exponent > 40 → wp = 0.0exponent < -40 → wp = 1.0wp = 1.0wp = 0.0wp = 0.5| Position | Centipawns | Win probability |
|---|---|---|
| Equal | 0 | 50% |
| Slight edge | +150 | ~66% |
| Clear edge | +350 | ~85% |
| Winning | +600 | ~97% |
| Mate in 3 | Mate(3) | 100% |
src/backend/analysis/move_classifier.py computes win probability loss from the mover's point of
view:
if side == "white": wpl = wp_before - wp_afterelse: wpl = wp_after - wp_beforewpl = max(wpl, 0)
Then it applies rules in priority order:
| Priority | Result | Condition |
|---|---|---|
| 1 | Best | Delivers checkmate |
| 2 | Miss | Had a forced mate and did not play it |
| 2.5 | Best | Position is at least 99% winning after the move, unless it is a verified sacrifice |
| 3 | Brilliant | Sound sacrifice: WPL ≤ 5%, position still at least 40%, no clearly better alternative, contextually justified |
| 3 | Great | The only good move: alternatives are at least 15% worse, excluding recaptures, routine trades, and forced moves |
| 3 | Best | Matches the engine's top move |
| 4 | Miss | Was winning (≥ 70%) and let it slip (WPL ≥ 15%, still ≥ 42%), or fell below 42% with WPL ≥ 25% |
| 5 | Blunder | WPL ≥ 25% and no longer winning (< 60%), or WPL ≥ 20% and dropped below 35% |
| 6 | Mistake | WPL ≥ 10% |
| 6 | Inaccuracy | WPL ≥ 5% |
| 6 | Good | WPL ≥ 2% |
| 6 | Excellent | WPL < 2% |
A noise guard suppresses mistake and blunder labels while the player is still completely winning (around +700 or more).
Two sources are checked before the WPL tiers:
.bin bookA theory move is classified Book and receives 100% accuracy.
src/backend/analysis/math_utils.py:
diff = wp_before_pct - wp_after_pct
if diff <= 0: return 100.0
raw = 103.1668 * exp(-0.06 * diff) - 3.1669
clamp to [0, 100]
The decay constant is 0.06, stricter than Lichess's 0.04354, which keeps the result closer to
Chess.com's scale.
| Condition | Accuracy |
|---|---|
| Book move | 100% |
| Delivers checkmate | 100% |
| Leads to a forced mate | 100% |
| Floor | 10% |
The 10% floor is deliberate. Without it, one catastrophic move could collapse the harmonic mean and make an otherwise strong game look like 0%.
src/backend/analysis/analyzer.py combines a volatility-weighted mean with a harmonic mean.
A sliding window of max(2, min(8, len(accuracies) // 10)) measures the standard deviation of win
percentages over the trailing window; moves before the first full window share the opening window's
weight.
weight = max(0.5, min(12.0, std_dev(window)))
Critical, volatile positions therefore weigh more than quiet ones.
weighted_mean = sum(accuracy[i] * weight[i]) / sum(weights)
harmonic_mean = n / sum(1 / accuracy[i])
accuracy = (weighted_mean + harmonic_mean) / 2
clamp to [0, 100]
A game with a single move uses that move's accuracy directly.
The Tactics tab and the headline tactic counts use a confirmation pipeline rather than a static attacker map. Every candidate fact must survive:
Missed tactics are suppressed on best and mating moves. Sacrifices require the engine-approved move and report net material. Pins need a tactical consequence, skewers need an interposed-free vacate-then-capture line, and Morphy/Boden mates need real mating geometry. Only confirmed facts enter the headline stats.
Results are saved through GameHistoryManager.save_game().
The games table stores metadata, the full PGN, a denormalized moves_json payload, and list columns
(move count, last FEN, phase accuracies, tactic counts, termination mode) so History can render
without parsing every game.
Games are staged as soon as they are imported:
| Status | Meaning |
|---|---|
not_started | Loaded, no analysis yet |
paused | Analysis stopped early, resumable |
completed | Full analysis finished |
See Data & Storage for the schema and maintenance tools.
| Platform | Primary method | Difference |
|---|---|---|
| Chess.com | Proprietary CAP formula | Adapts to rating |
| Lichess | Volatility-weighted + harmonic mean | Open source |
| Chess Analyzer Pro | Volatility-weighted + harmonic mean | Independent implementation with decay constant 0.06 and a 10% floor |
The accuracy model follows Lichess's published approach, but the win-probability, volatility, and accuracy helpers in Chess Analyzer Pro are an original implementation. No upstream AGPL source is reproduced.
Related guides
Download Chess Analyzer Pro for Windows, macOS, or Linux. 100% free, private, and open-source.