CaliChess Guides

Guides ·

How a Chess Engine Works, Explained Simply

A chess engine has three parts: one that knows the rules, one that scores a position, and one that looks ahead. Here is each one in plain words, with real numbers from the engine on calichess.cc.

In one breathImagine trying every possible move, then every reply, then every reply to that, and giving each final position a score. Then you pick the move whose worst case is the best. That is a chess engine.

1. The board: knowing the rules

First, the engine must list every legal move in a position: castling, en passant, promotion, pins. A single wrong rule ruins everything after it.

This engine stores the board as eight 64-bit numbers: one for each color and one for each piece type. Each bit is one square, so a chessboard fits exactly. That trick, called bitboards, lets the computer check many squares at once with a single instruction, for example "which squares does this bishop attack?".

To prove the rules are right, engines run perft: count every position a few moves deep and compare with the known answer.

TestPositions countedTime
Starting position, 6 moves deep119,060,3243.55 s
"Kiwipete" (a tricky test position), 5 moves deep193,690,6905.63 s

Both match the published values exactly, at about 34 million positions per second.

2. The evaluation: scoring a position

When the engine stops looking ahead, it must guess who is better. It adds up simple rules:

The result is a score in centipawns, hundredths of a pawn. +100 is like being a pawn up. The weights of these rules were tuned by comparing them with the results of real games.

3. The search: looking ahead

This is where the strength comes from. The engine tries a move, then the opponent's best answer, then its own best answer, and so on. It assumes both sides play well.

Checking every move would be impossible: after just 6 moves there are already 119 million positions. So engines skip lines that cannot matter:

TrickPlain meaning
Alpha-beta"I already have a move that wins a pawn; this other move loses a piece by force, so stop looking at it."
Transposition tableRemember positions already scored, because different move orders often reach the same one.
Null move"If I skip my turn and I am still winning, this line is good enough."
Late move reductionsMoves sorted last are probably bad, so look at them less deeply first.
Quiescence searchNever stop in the middle of a trade; keep resolving captures first.

With these, the engine on calichess.cc reaches depth 19 to 31 in five seconds on a laptop chip, checking 1.9 to 3.3 million positions per second.

Putting it together

Every move you see on calichess.cc comes from these three parts working together: the board lists the moves, the search follows the lines worth following, and the evaluation scores where they end. The best move finder guide shows how to read the result.

Questions

Does a chess engine know chess like a person?

No. It does not understand plans the way people do. It checks millions of positions and adds up simple rules, very fast.

What is depth?

How many moves ahead the engine looked. Depth 20 means it followed lines 20 moves long (one move by one side counts as 1).

What is Elo?

A rating. A 100-point gap means the stronger side scores about 64%. Engines have their own lists, like CCRL, that do not map directly to human ratings.

Does this engine use a neural network?

No. Its evaluation is a list of hand-written rules, tuned automatically on real games. It reaches about 3039 Elo on the CCRL Blitz scale without one.

Open the engine →