Skip to content
Back to the blog

Chess engines: Stockfish, AlphaZero and how to use them

What a chess engine is, how Stockfish and AlphaZero think, what changed with neural networks and how to use an engine to improve instead of just following the arrow.

By AcademiaTal8 min read

A chess engine is a program that analyses a position and tells you the best move and how much the position is worth. Today's strongest, such as Stockfish and Leela Chess Zero, play far above any world champion, and the one that changed how engines are built was AlphaZero, which taught itself the game in 2017 and beat Stockfish. For a club player the important question is not which is stronger —any of them will beat you— but how to use them to learn rather than to stare at an arrow.

What an engine does under the bonnet

Every engine does two things, and understanding them explains almost everything you see on the screen.

It searches. From the current position it goes through moves, replies and counter-replies and builds a tree of continuations. A modern engine visits millions of positions per second, but not all equally: it discards hopeless branches very quickly and goes deeper into the ones that matter. That is why the screen shows a depth ("depth 30"): how many moves ahead it reached on the main line.

It evaluates. When it stops searching, it has to say how good the position it reached is. That number is the evaluation you see: +1.0 means White is roughly a pawn better; −2.5, that Black has a big advantage; 0.0, that the position is balanced. A forced mate appears as "M5" or "#5".

The history of engines is, at bottom, the history of how those two parts got better.

From Deep Blue to Stockfish: well-directed brute force

For decades programs were built the same way: a huge search and an evaluation written by hand by programmers and players. That evaluation added up criteria any coach would recognise —material, piece activity, king safety, pawn structure— with weights tuned through endless testing.

The symbolic moment was Deep Blue, IBM's computer. Kasparov won the first match in Philadelphia in 1996 by 4–2 and lost the 1997 rematch in New York by 3.5–2.5. The last game was a Caro-Kann in which Deep Blue sacrificed a knight on e6 and Kasparov resigned on move 19 (1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 7.N1f3 h6 8.Nxe6). The full story is in the article on Garry Kasparov, and the opening in the guide to the Caro-Kann Defence.

Deep Blue was a machine built for the job. A few years later ordinary programs on a desktop computer played as well or better, and Stockfish, an open-source engine, became the standard: free, maintained by a huge community and stronger every year.

AlphaZero: learning without being taught

In December 2017 DeepMind, Google's artificial intelligence lab, published AlphaZero. The novelty was not the strength but the method: AlphaZero had no human-written evaluation and no opening book. It knew the rules and nothing else, and it learned by playing millions of games against itself, tuning a neural network that learned to recognise which positions are good.

It also searched differently. Instead of millions of positions per second it looked at far fewer, chosen by the network itself: a search closer to that of a person who "sees" which moves deserve attention.

The result stunned everyone. In the match from the first paper it beat Stockfish 8 with 28 wins, 72 draws and no losses in 100 games. There was fair criticism: Stockfish played with little memory and a fixed minute per move, which is not how it performs best. In the final version, published in Science in December 2018, the match was 1,000 games at a long time control, and AlphaZero won 155 and lost 6, with the rest drawn.

What impressed players most was not the score but the style. AlphaZero gave up material for long-term compensation, shut enemy pieces out of play, pushed its rook's pawn against the castled king and played as if activity were worth more than the textbooks said. It seemed less like a computer and more like an attacking player with infinite patience.

AlphaZero was never released. What did appear in 2018 was Leela Chess Zero, an open project that copied the idea —a neural network learning against itself— and is today one of the strongest engines in the world, alongside Stockfish.

Stockfish NNUE: the best of both worlds

Stockfish's answer came from shogi, Japanese chess. There, in 2018, Yu Nasu had invented a kind of small neural network, NNUE ("efficiently updatable neural network"), which can be computed very quickly on an ordinary processor because after each move it only updates what changed.

Stockfish 12, released on 2 September 2020, replaced the hand-written evaluation with one of those networks and kept its classical search. The combination —search as always, but evaluate with a trained network— produced a huge jump in strength from one version to the next, and hand-written evaluation has been left behind ever since.

Today both paths coexist: Stockfish with deep search and a small network, Leela with selective search and a large one. For analysing your games, either is more than enough.

What engines changed in human chess

Preparation. Elite openings are studied with the engine deep into the game. "Impossible" ideas are tested at home, and many lines once considered bad came back because the machine found how to play them.

Style. After AlphaZero, pushing the rook's pawn in positions that used to be played quietly became a normal weapon, and players accepted that a pawn or the exchange is worth less than the initiative in more positions than they had thought. That is what the course Masterclass Chess: Ideas, Plans and Sacrifices works on, with a class on attacking ideas inspired by AlphaZero.

Defence. The engine showed that many "lost" positions can be held with precise moves. Strong players defend better than thirty years ago because they got used to seeing positions that looked terrible and held.

Evaluation. Today everyone talks about "+0.8" as if it were a fact on the board. It is useful but misleading: a +0.8 that needs ten only-moves is of no use to a human being. Understanding that difference —what a position is worth to a person and what it is worth to a machine— is the subject of the course Modern chess logic, which devotes a class to reading what the engine says.

How to read what the engine says

Three things so you don't misread it:

  • Look at more than one line. Turn on two or three variations at once. If the first gives +1.5 and the second +0.2, the position has a single good move and it is easy to go wrong; if all three are similar, there are several ways to play and you can choose the one you understand.
  • Small differences don't matter. There is no lesson between +0.3 and +0.5. There is one between +0.3 and −2.0: that was a real mistake.
  • Wait for it to settle. In the first few seconds the evaluation jumps around. Let it think until the main line stops changing.

How to use the engine to learn

The most common mistake is switching the engine on from move one. You learn nothing that way: the arrow tells you what to play and you stop thinking. What works is the other way round.

The engine comes last. First you analyse: what you were thinking at each moment, which alternatives you saw, what plan you had. Only then do you turn it on and compare. The step-by-step method is in how to analyse your own games.

When it disagrees, look for the reason. "The engine prefers Re1" teaches nothing. "It prefers Re1 because it prepares e5 and my move prevented it" does. If you can't find the why, play its line on the board for a few moves and see what changes.

Play positions against it. Take a position from one of your games or a course, with an advantage for you, and try to win it against the engine. It is the best way to practise converting an advantage and to discover that "winning" is not the same as "easy".

Don't use it to train calculation. Calculation is trained without moving the pieces and without help, as explained in how to calculate in chess. The engine is for checking afterwards where your calculation broke down.

And when the engine isn't enough, ask a person. There are moves the engine approves that nobody can explain to you with the engine alone. That is what Ask the GM is for: a grandmaster answers about the concrete position, in words (the service works in Spanish, English and Portuguese).

Which courses cover this

The two courses closest to the topic are Modern chess logic, on modern evaluation and how to read the engine, and Masterclass Chess: Ideas, Plans and Sacrifices, with the attacking ideas AlphaZero made popular. Both are taught in Spanish with English subtitles. And in the courses' game viewer the engine is at hand, switched off until you turn it on: exactly for doing what this article says, thinking first and comparing afterwards.

Keep going with a free class

Open classTopalov–Shirov, Linares 1998: 47…Bh3!!with GM Alexei Shirov · 12 min · no account needed
Free with an account

Watch «Faustino Oro live» in full

1 h 3 min of recorded class. Create your free account, no card needed, and it stays in «Recordings» to watch whenever you like.

Frequently asked questions

What is a chess engine?
It is a program that analyses a position and suggests the best move. It combines a search, which looks through millions of continuations, with an evaluation, which says how good each resulting position is. Stockfish and Leela Chess Zero are the best known.
What is the difference between Stockfish and AlphaZero?
Stockfish began as a classical search engine with a hand-written evaluation and since 2020 has evaluated with a small neural network (NNUE). AlphaZero, from DeepMind, learned by playing against itself with a large neural network and searches far fewer positions, but better chosen ones. AlphaZero was never released; Leela Chess Zero is the open version of the same idea.
Who won between AlphaZero and Stockfish?
AlphaZero. In the match published in December 2017 it beat Stockfish 8 with 28 wins, 72 draws and no losses, and in the final 2018 paper, over 1,000 games, it won 155 and lost 6. The conditions of the first match were criticised, but the margin of the second was not disputed.
How do you use a chess engine to improve?
Last, and with a question. First you analyse the game or position yourself and write down what you were thinking, and only then do you switch the engine on to compare. When it disagrees, the useful thing is to find out why its move is better, not to memorise the line.

Courses that cover this

If you want to put this into practice with structured material:

IntermediateAdvanced

Masterclass Chess: Ideas, Plans and Sacrifices

A practical journey through strategic ideas, attacking plans, and thematic sacrifices across six masterclasses.

By GM Andrés Rodríguez Vila, GM Diego Flores, and GM Leandro Krysa

6 lessons12 h6 Videos64 PGN games

Included in the membership

USD 30.00
View details
All levels

Modern chess logic: evaluation, middlegame and endgame

Four classes and eight hours of training to master modern evaluation, read the engine, handle complex positions and improve your endgame technique.

By GM Andrés Rodríguez Vila

4 lessons8 h4 Videos23 PGN games

Included in the membership

USD 25.00
View details

Keep reading

8 min read

How to calculate in chess: a step-by-step method

Candidate moves, forcing moves first, the tree of analysis, where to stop and evaluate, the final blunder check and the classic mistakes: how to calculate better.

Read the article