How Does Stockfish Work? The World's Strongest Chess Engine, Explained
Stockfish looks at tens of millions of positions per second on a good computer, yet it does not check every possible move. It combines a very clever search with a small, fast neural network that judges positions. Here is how it works, step by step, with two real examples from the engine itself.
- The two parts: search and evaluation
- Minimax and alpha-beta: looking ahead without checking everything
- Iterative deepening: shallow first, then deeper
- Pruning, reductions and move ordering
- The evaluation: a neural network called NNUE
- Tablebases: perfect endgames
- Fishtest: how Stockfish keeps getting stronger
- Where Stockfish came from
- Frequently asked questions
- Sources and checks
Stockfish works in two parts. A search looks ahead through possible moves using alpha-beta search with iterative deepening: it starts shallow, goes deeper step by step, and cuts away lines that cannot change the result. At the end of each line a small neural network called NNUE gives the position a score. The move with the best score after the deepest search is played. Every change to the code is tested in thousands of games on Fishtest, a network of volunteers' computers, before it is accepted.
The two parts: search and evaluation
Every classic chess engine answers two questions over and over:
- Search: "If I play this, what can my opponent do, and what can I do then?" It builds a tree of moves and replies.
- Evaluation: "Who is better in this position, and by how much?" It gives a number such as +0.30.
A search with no evaluation is blind, and an evaluation with no search misses tactics. Stockfish's strength comes from doing both extremely well and extremely fast. It has no board or buttons of its own: chess programs, websites and apps talk to it through the UCI protocol. That is how it plays on the Rama Chess Stockfish page and inside our analyser.
Minimax and alpha-beta: looking ahead without checking everything
The basic idea is called minimax. Stockfish assumes both sides play their best: it picks the move that gives it the highest score, while the opponent always replies with the move that gives the lowest score. The problem: a position has about 30-40 legal moves, so looking 10 moves deep the plain way would mean an astronomical number of positions.
Alpha-beta solves much of this. Once the engine has found one good move, it can stop looking at another move as soon as it sees one strong enough reply against it. That reply already proves the second move is worse, so the rest of its replies do not need to be checked. Stockfish uses a refined form called Principal Variation Search (PVS).
Iterative deepening: shallow first, then deeper
Stockfish does not jump straight to depth 30. It searches depth 1, then depth 2, then 3, and so on. Each round uses what it learned in the round before, especially which move was best, so the next, deeper search looks at the most promising moves first. That makes alpha-beta cut away far more. It also means Stockfish always has a move ready if its time runs out.
Here is a real example from Stockfish 18 on our own computer (1 thread, 16 October 2026). The position comes from a well-known trap: after 1.e4 e5 2.Nf3 Nc6 3.Bc4 Nd4, taking the pawn with 4.Nxe5 looks good but runs into 4...Qg5.
| Depth | Best move found | Score | Positions searched |
|---|---|---|---|
| 1 | 4.Nxe5 | +2.03 | 39 |
| 2 | 4.Nxe5 | +3.20 | 76 |
| 4 | 4.Nxe5 | +2.56 | 218 |
| 8 | 4.Nxe5 | +1.47 | 2,422 |
| 16 | 4.Nxd4 | +1.21 | 222,077 |
| 22 | 4.Nxd4 | +1.15 | 1,025,175 |
Stockfish 19commentaryIterative deepening: shallow first, then deeper: moves and commentary as text
1.e4 White puts a pawn on e4 and claims space in the centre.
1...e5 Black puts a pawn on e5 and claims space in the centre.
2.Nf3 White develops the knight to f3.
2...Nc6 Black develops the knight to c6.
3.Bc4 This is the Italian Game. White develops the bishop to c4.
3...Nd4 At low depth the greedy 4.Nxe5 looks best. Deeper, Stockfish sees 4...Qg5 coming and switches to the simple 4.Nxd4, still clearly better for White.
4.Nxe5 A move that looks good at a shallow depth can be refuted when the engine sees further, as in the 4.Nxe5 example on this page.
4.Nxd4 Once the search was deep enough to see Black's queen counter-attack, Stockfish switched to the safe 4.Nxd4.
4...Qg5 The queen comes out to g5. It attacks the knight on e5. Stockfish: Black is slightly better (-0.7).
Shallow searches liked the pawn grab. Once the search was deep enough to see Black's queen counter-attack, Stockfish switched to the safe 4.Nxd4. This is why depth matters when you read an engine, as explained in how to use a chess engine.
Pruning, reductions and move ordering
Alpha-beta alone is not enough. Stockfish adds many tricks that skip or shorten lines that are very unlikely to matter. The main ones:
| Technique | What it does, in plain words |
|---|---|
| Move ordering | Try the most promising moves first (the best move from the last depth, captures, moves that worked before). Good ordering makes alpha-beta cut much more. |
| Transposition table | A big memory ("Hash") of positions already searched. The same position can arise by different move orders; Stockfish looks it up instead of searching it again. |
| Null-move pruning | "If I pass and my position is still great, this line is good enough": skip deeper work there. |
| Late move reductions | Moves sorted near the end of the list are searched less deeply first. Only if one surprises is it searched in full. |
| Quiescence search | At the end of a line, keep looking at captures so the score is not taken in the middle of an exchange. |
| Lazy SMP | Many processor cores search at the same time and share the transposition table. Used since Stockfish 7 (2016). |
The result: Stockfish searches a very narrow, very deep tree. It looks at the good moves many moves ahead and spends almost no time on bad ones.
The evaluation: a neural network called NNUE
For its first 12 years, Stockfish judged positions with a hand-written formula: material, piece activity, pawn structure, king safety and more. In 2020 it added NNUE, an "efficiently updatable neural network" first invented for computer shogi. Stockfish 12 (2 September 2020) was the first release with it. In Stockfish 16.1 (February 2024) the hand-written evaluation was removed completely.
NNUE is small and fast on purpose. After a move, only a few of its inputs change, so it updates its sums instead of starting again, and it runs on a normal CPU without a graphics card. Today's networks are trained on huge numbers of positions; for Stockfish 19 the team says hundreds of billions of positions were rescored with a strong Leela Chess Zero network. The full story is in what is NNUE.
Tablebases: perfect endgames
When only a few pieces are left, Stockfish can use Syzygy endgame tablebases: files that store the exact result of every position with up to 7 pieces (kings included). If a tablebase is installed, Stockfish knows at once whether the endgame is a win, a draw or a loss, and plays it perfectly. Support was added in 2014 and extended to 7 pieces in 2018.
Fishtest: how Stockfish keeps getting stronger
Stockfish is free and open source (GPLv3), written by a team of volunteers. Anyone can suggest a change, but every change must prove itself. On Fishtest, a testing network started in 2013, volunteers donate computer time and the new version plays the old one in tens of thousands of fast games. A statistical test called SPRT decides whether the change is a real improvement. Only then is it merged.
That slow, careful process is why Stockfish gains strength with nearly every release. Stockfish 19, released on 5 September 2026, was up to 44 Elo stronger than Stockfish 18 in the team's tests. See every version on Stockfish Elo by version and how it compares with rivals in the best chess engines ranking.
Where Stockfish came from
Stockfish began in 2008 when Marco Costalba forked Glaurung, an open-source engine by Norwegian programmer Tord Romstad; Joona Kiiski joined soon after. Gary Linscott later built Fishtest. Since then hundreds of people have contributed. Stockfish has won the Top Chess Engine Championship (TCEC) 19 times, including the Season 29 Superfinal in April 2026 (what TCEC is). Its place in chess history, from Deep Blue to AlphaZero, is in our history of computer chess. Want to test it yourself? Read can you beat Stockfish 18, see how often top engines give up material in our chess engine sacrifice statistics, and how its closest rival does in Torch vs Stockfish.
Play these engines yourself. Stockfish 19, Obsidian and Stormphrax are free to play; Reckless, PlentyChess, Viridithas, Berserk, Caissa, Koivisto and Ethereal are Premium bots. They run right in your browser. All engine bots · licences and source code.
Frequently asked questions
How does Stockfish think?
Stockfish searches ahead through moves and replies with alpha-beta search, going deeper step by step (iterative deepening) and skipping lines that cannot matter. A neural network called NNUE scores the positions at the end of each line, and the best-scoring move is played.
Does Stockfish use AI?
Yes, in part. Since 2020 Stockfish's evaluation is a neural network (NNUE) trained by machine learning on billions of positions. The search that looks ahead is a classic algorithm, not a neural network.
How many positions does Stockfish look at per second?
It depends on the computer. On a normal laptop it is millions of positions per second; on big servers with many cores it is far more. Our depth-22 example above took about one million positions on a single thread.
Is Stockfish a neural network like AlphaZero?
No. AlphaZero uses a very large neural network and a Monte Carlo tree search on special hardware, and looks at far fewer positions. Stockfish uses a small, fast network (NNUE) inside an alpha-beta search on ordinary CPUs.
Who made Stockfish?
Stockfish was started in 2008 by Marco Costalba, based on Tord Romstad's engine Glaurung, with Joona Kiiski. Today it is developed by a large open-source community.
Why does Stockfish change its best move?
Because it searches deeper over time. A move that looks good at a shallow depth can be refuted when the engine sees further, as in the 4.Nxe5 example on this page.
Sources and checks
- Chess Programming Wiki: Stockfish (search techniques, Lazy SMP since Stockfish 7, origin from Glaurung), Stockfish NNUE.
- Stockfish blog: Stockfish 12 (2 September 2020), Stockfish 16.1 (24 February 2024), Stockfish 19 (5 September 2026); official Stockfish source releases.
- Wikipedia: Stockfish (Fishtest since 2013, SPRT; Syzygy support 2014, 7-piece 2018; GPLv3). Chessdom: Stockfish's 19th TCEC title (21 April 2026).
- Depth table: our own run of Stockfish 18, 1 thread, 64 MB hash, 16 October 2026. All sources checked 16 October 2026.
- Refresh 12 November 2026: the Stockfish GitHub releases page still lists Stockfish 19 (5 September 2026) as the newest official release.
Keep learning on Rama Chess
Watch on YouTube
Prefer video? Our channels show real games move by move, with clear explanations.
Play the chess bots from this article on Rama Chess: Stockfish 18 (free), Leela Chess Zero.
