Learn After the game Lesson 1 of 5
How a chess engine thinks
Stockfish looks ahead and judges what it finds: how each half works, and what an engine can't do for you.
The strongest player there has ever been
A chess engine is a program that plays chess. The best known is Stockfish, and it's stronger than any person has ever been: the world champion would lose to it game after game.
It's one of the things at work on this site. A report starts from Stockfish's view of every move of every game, and that's only the raw material: our own analysis, with a second neural network that models how people really play, then goes looking for what no engine can tell you by itself, the habits behind your losses. You can also play Stockfish yourself, at whatever strength you like, on Play the engine.
It isn't magic, and it isn't a teacher. This lesson is how it works, because that explains what it's good for after a game and what it can't do for you. It has two jobs: looking ahead, and judging what it finds there.
Try it: how fast the moves multiply
Looking ahead sounds simple: try every move, then every answer to it, then every answer to that. The trouble is how many there are.
Three questions about the very first moves of a game. Guess if you're not sure: the answers are the point.
So it doesn't look at everything
An engine gets through millions of positions a second, and that still isn't nearly enough. So it prunes: it gives up on a line as soon as it's sure the line is worse than one it has already found.
Say it has found a move that keeps the game level, and then sees that another move loses a knight to one particular reply. It doesn't need to know whether that move loses even more to some other reply. It's worse, and that's enough. Whole branches of the tree are cut off like this, unexamined.
What's left is a search that goes deep along the lines that matter and hardly at all along the ones that don't.
Try it: the other side gets a say
The idea at the heart of every engine is one you can use yourself: a move is only as good as the position after the best reply to it.
So for each move it tries, the engine changes sides and looks for the answer that hurts most. Then it changes back and looks for the best answer to that. It never hopes the other side will miss something.
Here you do both halves. Play the move, then be the opponent.
Judging a position
Sooner or later the engine has to stop looking and decide how good a position is, just as it stands. That's the second job: evaluation.
For decades this was done by rules that people wrote: count the pieces by what each is worth, then add a little for a safe king, for pawns that work together, for pieces with room to move.
Today Stockfish uses a neural network instead. Nobody wrote its rules: it was trained on billions of positions until it could look at where every piece stands and give back one number for the whole board. It judges better than the hand-written rules ever did.
Count the pieces on this board and you'll find them level. The network sees that Black's king is stuck in the middle with half his army still at home.
Try it: looking deeper changes the answer
How far ahead the engine has looked is its depth, counted in single moves by either side. Depth 20 is ten moves each.
The deeper it goes, the more it can be trusted, and its opinion can turn right round on the way. A move that looks like the worst on the board at depth one can be the best at depth three.
This is why an engine left to think for longer sometimes changes its mind, and why a quick look is worth less than a long one.
What it can't do
- It doesn't say why. An engine gives a move and a number. The reason is left for you to find.
- It doesn't know you're a person. Its best move may only be best if you then find five more exact moves in a row. A simpler move that scores a little less is often the better choice for a human.
- It doesn't know what you were thinking. It can show that a move was a mistake. It can't tell whether you missed a threat, moved too fast or never knew the idea.
So an engine is a measuring tool. It's for after the game, to check what really happened in it, and never during one: using an engine while you play another person is cheating.
The rest of this level is how to read what it measures, and how to turn that into something you can use in your next game.