Sailesh Chandra

Think Like An Engine 2

Part 2 of a 6 part series

“To put everything in balance is good, to put everything in harmony is even better”

It is generally felt that thumb rules for imbalances are for humans to follow, and chess engines will use brute force to calculate and there cannot be generalizations in a chess evaluation algorithm. But is it true?

Let us take one of the well-known imbalances. Rook and Pawn versus Knight and Bishop: This is a classic beginner error, where in Ruy Lopez White exchanges knight and bishop for a rook and pawn.

This gives an instant valuation loss of 1.5 pawns to white. It is not a rule of thumb, the evaluation function sees an exchange of knight and bishop in the opening for a rook and pawn as not a good thing.

In the end game it is practically equal. As can be seen below.

In general, the Stockfish engine uses a point system to evaluate the material balance on the board. The values used byStockfish are as follows:

ManPoints
Midgame
Points
Endgame
Pawn 126 208
Knight 781 854
Bishop 825 915
Rook 12761380

So, in terms of pure material value, a knight and a bishop (1606-1769 points) are worth more than a rook and a pawn (1402-1588 points).

Notice that there is never a time when knight and bishop is worse than the rook and a pawn. They are closer to equality in endgame, but never better. The human psychology thinks that pawn can be queen, but an engine, knows it will never queen.

There are other endgames such as two rooks versus the queen and pawn. This many feel gives some chances to the queen and the potential queen. Let us see what Stockfish thinks about it.

The values used by Stockfish are as follows:

ManPoints
Midgame
Points
Endgame
Pawn 126 208
Rook 12761380
Queen25212682

So, in terms of pure material value, a queen and a pawn (2654-2890 points) are worth more than two rooks (2552-2760 points).

So again from a stand point of view , you would be comfortable with a queen and a pawn versus two rooks. But of-course there is a point which can be brought up, that chess is a complex game and cannot be simplified on static quantities. Yes, there is some truth to that, and there is a complex engine evaluation which can be seen below:

The Stockfish evaluation function is a complex formula that the engine uses to assess the value of a position. It takes into account a multitude of factors, but here’s a simplified explanation:

Material: The most basic part of the evaluation is the material balance. Each type of piece has a certain point value (e.g., pawn = 1, knight = 3, bishop = 3, rook = 5, queen = 9). The engine adds up the material for both sides to get a basic idea of who’s ahead.

Piece-Square Tables: Each piece has a “piece-square table”, which is a matrix of values that represent how good or bad each square is for that piece. For example, central squares might be more valuable for knights, while bishops might prefer long open diagonals.

Mobility: The engine evaluates the mobility of the pieces. Pieces that have more legal moves are generally more powerful, so this is factored into the evaluation.

King Safety: The safety of the king is crucial in chess, so the engine checks factors like the number of safe squares around the king, whether the king is exposed to checks, and so on.

Pawn Structure: Pawns are the soul of chess. The engine looks at the pawn structure - doubled pawns, isolated pawns, passed pawns, etc., can all be weaknesses or strengths.

Tapered Evaluation: The engine calculates separate scores for the midgame and endgame, and interpolates between these based on the current phase of the game. This allows for a smooth transition in the evaluation as the game progresses.

But here is the thing: all other factors being equal, can you determine your imbalances?

Would you most likely always choose a bishop over a knight? Would you never give up the two bishops?

How about two pawns and a knight versus rook in the endgame? There comes some clarity there. Is the bishop pair given a bonus? The numerical value comes from the individual bishop values in the endgame.

How does the engine know when the endgame is about to start. The tapered evaluation ensures that this is an ongoing process.

In your evaluation, you would want certain positions to go to the endgame, or certain you would not?

Let us take this to a real absurd looking ending: 5 pawns versus rook.

ManPoints
Midgame
Points
Endgame
Pawn 126 208
Rook 12761380

So, in terms of pure material value, five pawns (630-1040 points) are worth less than a rook (1276-1380 points).

As a general rule, a rook is often considered to be better than five pawns, especially in open positions where the rook can exert control over long lines.

Clearly, I would fancy my chances as white. Again it brings back to the same caveat. All other things being equal. The static calculations only work if the dynamic factors are equal. These could be advanced pawns, king safety, etc.

In conclusion, Engines do have their own way at looking at imbalances, but we can adopt a similar at-least partially rigid approach for example, not giving up a bishop pair without strong compensation or not exchanging a knight for a bishop unless there is some clear cut benefit which can occur from it.

There are a couple of games which are instructive. The first one is rook and pawn versus knight and bishop. This is a game where my students would come to the position where the bishop and knight would be exchanged for the pawn and the rook, and a perfect game would be played after that. Essentially you would have a game with 1 inaccuracy (Ng5) and 1 Blunder (Knight or Bishop ✕ f7).

A few elements came out of it. The game should be won before it goes into an endgame with very few pawns. That could be a draw or worse, the rook will prevail. The second point is the phase where the advantage is realized is towards the end of the middle game. The third point is that the bishop pair plays a big role in the win, and that is usually by creating a passed pawn which it escorts till the end.

The second game is between perhaps two greatest natural geniuses who ever played the game Mir Sultan Khan and Capablanca . Sultan Khan’s two rooks beat Capablanca’s queen. The position is kept closed by Sultan Khan with just one open file for the two rooks to operate on. The open board which the queen craves is not given for her double attacks or even perpetual checks. The imprisonment of the queen is instructive. (Another game of Sultan Khan had a similar situation and fortunes reversed: Sultan Khan had a Queen vs two Rooks as White which he lost after 108 moves. Sultan was conferred with a posthumous GM title in 2024 -Ed)

Both the games are annotated by Stockfish, so we understand how the engine thinks, at the same time looking at the patterns which emerge in these games.