lichess.org
Donate

Finding Threats and Piece Manoeuvres with Engines

ChessStrategyChess engine
How helpful are the mainlines of Stockfish to explain the ideas behind moves?

One of the most frustrating things about looking at chess engines is that they can't tell you the idea behind moves. Often knowing the best move isn't very helpful when you don't understand the ideas behind it.
There could be many possible reasons for playing a certain move so it's difficult to programmatically explain every move. But I think that many moves can be explained be threats (either creating or preventing them) and piece manoeuvres. So I focused on detecting these kind of moves with engines first.

Finding threats

Lichess has had a threat detection feature for a while which works by switching the side to move, so that one player is moving twice in a row.
This is both simple and works quite well in my experience. When thinking about threats, we mostly think about tactics, but this way of detecting threats also works for strategic threats. Take a look at the following example from the game Timman-Ikonnikov, 2009:

https://lichess.org/study/DEfXX4Ra/Zg08HLwJ#0

The engine points out that black threatens to play 1...c4, which would shut in the white bishop on c1. This explains why playing 1.c4! from White is an important move in this position.
My only problem with this approach is that this only detects very direct threats. If one side would need to play two setup moves to create a threat, the idea might not be found after the first setup move (as long as the final threat could still be prevented).
One idea I had was that one side would be allowed to make 3 moves in a row. The problem I ran into is that it's not possible to let Stockfish play as if it was allowed to make multiple moves in a row. So it might not even try to create the threat, since it sees that it can be prevented, even though we would allow Stockfish to move multiple times in a row.
If you have an idea how to detect threats that are further down the line, I'd be very interested to hear them.


If you enjoy this post, check out my Substack.

Piece Manoeuvres

While looking at threats can be very insightful, there’re many positions where it won't be very helpful. Quiet positions are by definition absent of threats, so looking for threats won't explain the moves played. But finding piece manoeuvres might be more insightful.
To find manoeuvres, I looked if the best engine line consists of moving one piece multiple times in a row. Then one can look for the square where the piece will eventually end up on, instead of focusing on the individual moves.
One very typical piece manoeuvre happens in many lines of the Ruy Lopez:

https://lichess.org/study/DEfXX4Ra/zbDmFrmj#0

The most common move in this position is 1.Nbd2. It might not be clear at first what the knight is doing on d2. But the idea is clear when one sees that the final square is either e3 or g3.
The main problem with this approach is that engines often prevent strong manoeuvres even at the cost of material. One extreme case is the classic example from Short-Timman, 1991:
https://lichess.org/study/U8U0Hb2d/CIzRNrm3#60

I thought that the engine would show classic king manoeuvre Kh2-g3-f4-g5 in this position, but that wasn’t the case. Stockfish wanted to play 31.Kh2 Ra8 32.Kg3 Qxd7, giving up the queen to prevent mate. Since this stops the king manoeuvre, it doesn’t show up that the king is heading for h6. The manoeuvre is the winning idea, but Stockfish prevents it from happening.

Conclusion

Explaining ideas with just engine moves turned out to be more difficult than I had expected. While finding immediate threats is simple and works quite well, it's harder to get deeper ideas out of engine lines.
The main problem is that engines often see that a certain plan is very strong and try to prevent it, often at the cost of material. If one could force the engine to play "human" moves for the other side, the ideas might show up more clearly. But classifying moves as human is even more difficult.
I'd be very interesting to hear if you have any thoughts about addressing the problems I've mentioned.