Chess AI
How the engine behind Chessblood thinks
Not a chatbot: a search for the best move
When people say “chess AI” today they often picture a language model. Stockfish is nothing like that. It does not read, talk or explain. It does two things, extremely fast: it searches the tree of possible moves and replies, and it evaluates the positions at the end of each line. The move it recommends is the one whose outcome stays best when the opponent also plays the best replies.
Everything Chessblood shows you is built on those two outputs: a score for the position and the line of moves the engine expects. The grades, accuracy figures, key moments and coach notes are calculated from them by fixed, published rules.
Search: looking ahead
Minimax with alpha-beta pruning. The engine assumes both sides play their best. Alpha-beta pruning lets it skip any branch that can no longer change the result, which is what makes deep searches affordable.
Iterative deepening. Stockfish searches to depth 1, then 2, then 3 and so on, using each pass to order the moves for the next. That is why the evaluation on the analysis board jumps around at first and then settles.
Selectivity. Promising moves are searched more deeply and unpromising ones less. At the end of each line the engine keeps resolving captures until the position is quiet, so it never stops counting in the middle of an exchange. A depth-20 search therefore sees some forcing lines far beyond 20 half-moves.
Memory. A hash table remembers positions already searched, so a position reached by two different move orders is analysed once. The builds here use 32 MB for it, or 64 MB for the multi-threaded engine.
Evaluation: a small, fast neural network
At the end of every line the engine needs a judgement: who is better, and by how much? Since Stockfish 12 in 2020 that judgement has come from a neural network called NNUE, short for “efficiently updatable neural network”, an idea first developed for computer shogi. Its first layer is updated incrementally as pieces move, so after each move only a small part of the network has to be recomputed. That keeps evaluation fast enough for a deep search on an ordinary processor, without a graphics card. The old hand-written evaluation has since been removed from Stockfish entirely.
The score comes out in pawns from White's point of view: +1.0 means White is better by about a pawn's worth, -0.5 means Black is slightly better. When the search finds a forced checkmate the score becomes a mate distance instead, such as M4.
The lite network
Chessblood serves the “lite” builds of stockfish.js, which pair the Stockfish 19 engine with a much smaller network so that the whole engine is under 2 MB. The stockfish.js maintainers describe the lite engine as quite a bit weaker than the full one but still far stronger than any human. For finding the mistakes in a human game, that trade is worth it: the engine starts in seconds, even on a phone.
Running in your browser
The engine is compiled to WebAssembly and served from this site, so it runs inside your browser tab on your own processor. No position is sent anywhere while it thinks, and there is no queue to wait in.
- Game reviews start up to four copies of the engine, one fewer than your processor has cores, and two at most on devices that report little memory. Each copy is single-threaded and analyses a different position, so the copies never wait for each other. On a recent laptop that is several times faster than one engine sharing four threads.
- The analysis board runs one engine. When the browser allows it, that engine uses up to four threads on a single position; otherwise it falls back to one thread, which is slower but finds the same kind of moves.
- Results are repeatable. A search to a fixed depth gives the same answer every time on the same device, so a game reviewed twice gets the same grades.
Depth presets
Fast
Depth 12
Depth 12. A 40-move game in a few seconds. Good for blitz.
up to 2s per position · 2 lines
Balanced
Depth 16
Depth 16. About 15 seconds for a 40-move game. Our default.
up to 4s per position · 2 lines
Deep
Depth 20
Depth 20. About a minute for a 40-move game. For serious games.
up to 10s per position · 2 lines
Once a position is clearly decided (a forced mate, or more than ten pawns either way, on two consecutive iterations), the review stops searching it up to four plies early: deeper search could not move a grade by more than a couple of points there.
From evaluations to move grades
A raw score is hard to compare across positions: losing a pawn matters a lot at 0.0 and hardly at all at +9. So every evaluation is first converted into a win probability for the side to move, using the curve Lichess published with its open-source accuracy code:
win% = 50 + 50 × (2 / (1 + e^(−0.00368208 × cp)) − 1)A move is then graded by how many percentage points of win probability it gave away compared with the position before it. The rules are fixed and listed in the table, in the order they are checked. Accuracy is built from the same numbers; the accuracy calculator explains the formula step by step.
| Grade | Rule |
|---|---|
| ⧉Book | The position after the move appears in the ECO opening table (3,600 named positions). |
| →Forced | There was only one legal move. Forced moves are never praised or punished. |
| !!Brilliant | The engine's top move (or within half a point of it), and along the engine's continuation the mover is still at least two pawns' worth of material down after their own next reply. Ordinary trades never qualify. The position must not already be decided, and the mover must keep at least 35% winning chances. |
| !Great | The engine's top move in a position where the second-best move would have cost at least 10 percentage points of win probability: the only good move. Recaptures, captures of an equal or bigger piece and replies to check are excluded, because they are the natural move anyway. |
| ★Best | Matches the engine's first choice, or loses no more than half a percentage point of win probability. |
| ✓Excellent | Loses less than 2 percentage points of win probability. |
| ·Good | Loses less than 5 points. |
| ?!Inaccuracy | Loses between 5 and 10 points. |
| ?Mistake | Loses between 10 and 20 points. |
| ×Missed win | The mover had at least 85% winning chances and the move dropped them below 60% without falling below 30%. The win is gone but the game is not. |
| ??Blunder | Loses 20 points or more, or converts a winning position into a lost one. |
What the engine cannot tell you
- Why. Stockfish gives a score and a line, not a reason. The explanations in reviews and coach notes are written by fixed rules from those numbers. No language model is involved.
- Anything beyond its horizon. A plan that only pays off after the search depth can be misjudged. The Deep preset or a longer run on the analysis board helps in quiet, strategic positions.
- Endgame certainty. No endgame tablebases are used. Positions with few pieces are judged by search, so a won ending may show as +8 rather than a mate in 40.
- How hard a position is for a human. A line that keeps +0.3 may demand five only-moves in a row. The engine does not care; you should.
Stockfish and other chess AIs
In 2017 DeepMind's AlphaZero showed a different approach: a large neural network trained only by playing itself, guiding a Monte Carlo tree search that looks at far fewer positions but judges each one more deeply. Leela Chess Zero is the open-source project built on the same ideas, and it runs best on a graphics card.
Stockfish combines a very fast alpha-beta search with a small network that runs well on an ordinary processor. Both approaches are far beyond human strength. Stockfish's is the one that fits in a browser tab, which is why Chessblood can offer unlimited analysis without a server farm.
Free · runs in your browser
See the search for yourself
- Watch the depth climb and the evaluation settle
- Show up to five lines to compare the candidate moves
- Play any move on the board and the engine starts again