Pirc 4.Bg5: Trying out some endgames against Leela!

January 1, 2024 Matthew Sadler 4 comments

A little while ago, I released 2 videos featuring some amazing engine discoveries in the 4.Bg5 system against the Pirc (1.e4 d6 2.d4 Nf6 3.Nc3 g6 4.Bg5) These videos can be found here: https://youtu.be/1IXfyQszI2o and https://youtu.be/gyh3stkwjWI

The second of these videos ended up – after much sacrificial play from Black found by Dragon 3.3 – in a knight endgame with a better structure for White.

Position after White’s 30th move (30.Ke2)

The engines nonetheless made this endgame seem like an easy hold. One of the dangers of relying on engine lines for your preparation is to lose track of what is easy and difficult. You have to pinch yourself and remind yourself that you’ll have to play this resulting position in a practical game all alone!

My main analysis method is to run hundreds of engine vs engine games from various positions in my openings. This generates ideas and gives me a feel for the flow of games that will ensue from each variation (this technique is described at length in my books “The Silicon Road to Chess Improvement” and “Re-Engineering the Chess Classics”) However, I also like to get my hands dirty and play out certain positions myself against an engine as a sanity-check to make sure I’m keeping up (sort of) with the genius of the engines! My tooling of choice for such games I the Nibbler UI (https://github.com/rooklift/nibbler) together with the Leela chess engine (https://lczero.org/play/download/) The big advantage of this setup is that I can set Leela to search at various depths (1 node / 10 nodes / 1000 nodes / 100000 nodes) which is a very effective way of naturally limiting Leela’s strength. I can give a position a go (getting my bearings) against a somewhat weaker Leela (searching less deeply) and then gradually boost Leela until superhuman strength. To put things in perspective, Leela searching 1 node per move is about 2400-2500 (rather up and down because it misses quite a few tactics), 10-node Leela is about my strength (around 2650-2700) and 1000-node Leela is already going to 3000 and beyond!    

Before I started, I gathered my thoughts about the position and came up with the following general observations, all of which turned out to be accurate after verification with the engines (that’s what grandmasters are good at😉)

1. The most salient feature of the position is the set of doubled black d-pawns. However, White’s doubled c-pawns are just as crucial as these prevent White from creating a passed pawn on the queenside. Any attempt to do so will require c4, liquidating Black’s main weakness. My impression was that Black would be struggling badly if the white c2-pawn were on a2.

Position with the White c-pawn moved from c2 to a2.

Indeed, the engines concurred with a +5 evaluation! White’s ability to stretch the play by creating a passed pawn by pushing the a- and b-pawns is too much for Black to handle.

2.The exchange of knights is very risky for Black. Once again the engines concurred! Remove the knights from this position…

Position with the knights removed

…and White is completely winning. The only caveat to that was I felt that the exchange of knights on d4 with a recapture by the c3-pawn

Position after the exchange of knights on d4 and recapture with the c-pawn

would be most likely drawn (the white king can exert less pressure against Black’s structure). This was indeed the case.

3. Putting pressure on the d5-pawn with king (on d4) and knight and then advancing the kingside pawns seemed like the obvious way to make progress with c4 possibly played to clear entry lines for the white king or knight once the ground had been properly prepared. I didn’t manage to come to any concrete decisions about the effect of changes in the kingside pawn structure on White’s chances. Playing the f-pawn to f5 seemed the most natural (it takes away e6 from the black pieces)

Position after White has just played the f5 break

but I wasn’t sure whether I should meet this with …g5, taking on f5 or just leaving it.

4. My basic approach was to essentially stay still, keep my tempo moves in reserve and assume my position was strong enough to withstand any attempts from White. I also glanced at the somewhat meandering games that Stockfish and Dragon had played out in this endgame which seemed to confirm that Black’s position was essentially solid and resilient.

So, on to my Leela games! All the games are available as normal at this location so you can play along with the games on your favourite database program: http://cloudserver.chessbase.com/MTIyMTYx/replay.html

The first one at 1000 nodes went fairly well

30.Ke2 Kd7 31.Kd3 Ne7 32.g4 Ke6 33.Nd4+ Kd7 34.Ke3 Kc7 35.f5

35.Nb5+ Kc6 is the nice trick as 36.Nxa7+ Kb6 loses the knight. This means that Black doesn’t have to spend one of his reserve tempi (yet) to cover the b5–square with …a6.


I’m waiting consistently and seeing what White can come up with.

36.h4 g5

Not quite consistent with my stated goal of remaining passive, but it struck me that I should now be able to tie down a white piece to the defence of the g4–pawn and this is an excellent way to restrict the opportunities of the stronger side in an endgame.

37.hxg5 hxg5 38.Nf3 f6 39.Kd4 Kc6 40.Ne1 Ng8 41.Ng2 Nh6

Position after Black’s 41st move 41…Nh6

Tying down the opposing knight to the defence of a pawn and having a reserve tempo …a5 holds the draw!

42.Ne3 a5

42…a6 43.b4 would lose for Black.


43.b4 a4 is not advisable for White!

43…dxc4 44.Kxc4 Nf7

Taking the opportunity to transfer the knight to a square from which it still attacks the g4–pawn but can also restrict and harass the white king.

45.Kd4 Ne5 46.c4 Kd7 47.Kd5 Nd3 48.Kd4 Ne5 49.Kd5 Nd3 50.Kd4 Ne5 ½–½

Although this had worked out well, I felt quite nervous as 42…a5 was the only move to hold a draw. I felt I didn’t have half as much to spare in making a draw as the series of easy draws between the engines had seemed to indicate.

I decided to up Leela to 100000 nodes which bumps Leela up to something like 3300. That was quite a tough experience! Note that Leela was evaluating this endgame at 64.6% expected score. So not a win by any means, but definitely with potential. And that’s very much how it felt like when defending! Let’s take a look at a couple of attempts:

30.Ke2 Kd7 31.g4 Ne7 32.Nd4 Ng8

I’d taken a look at some more Stockfish-Dragon games and I saw that those engines had often played this knight quickly to f6, sometimes following up with …Ne8–c7 so it seemed a good thing to try. In the previous game, I had got a bit worried about my knight on e7 becoming passive or dominated so f6 looked like a more active square. The plan though was still mainly to sit and wait.

33.Ke3 Nf6 34.h3 Ne8 35.Ne2 Nf6 36.Ng3 Kc7 37.Kd4 Kc6 38.Nf1 Ne8 39.Ne3 Nc7 40.f5 g5

My standard reaction. At some stage the black knight should find a comfortable outpost on f6 from where it defends d5, supports …h5 looking to create a weakness on g4 and can also invade to e4.

41.Nf1 Ne8 42.Ng3 Nf6 43.Nh5

Position after Leela’s 43rd move 43.Nh5

Played with a 62.6% expected score. When it was played, I felt that Black should be able to hold this: after all, I had a couple of reserve tempi and White only had one.

43…Nxh5 44.gxh5

Just a 55.8% expected score now from Leela so it clearly sees that Black can hold. But is far from trivial and I started to get nervous as the questions started to rise up in me (I wasn’t looking at Leela’s evaluation during the playouts)

44…f6 45.b4 a6

Reserve tempi used so now the white king must retreat or White must liquidate Black’s doubled d-pawns with c4 to try and make progress.

46.Ke3 Kc7 47.Kd3 Kd7 48.Ke3 Kc7 49.Kd3 Kd7 50.c4 dxc4+ 51.Kxc4 Kc6 52.Kb3

Still with an expected score of 52.6% but it made me very worried. All of a sudden I couldn’t see how I was going to stop White from creating a distracting outside passed pawn and I was going to need to calculate!


Trying to scare Leela with activity, but Leela isn’t easily scared

53.Ka4 Kc6

53…Kc4 54.Ka5 is simply winning for White: all the queenside pawns get traded and White marches over to the kingside.

54.Ka5 Kb7 55.c4 Ka7 56.b5 axb5 57.cxb5

Position after Leela’s 57th move 57.cxb5

Here I panicked


57…d5 is the necessary antidote: 58.b6+ Kb7 59.Kb5 d4 60.Kc4 Kxb6 61.Kxd4 Kc6 62.Kc4 Kd6 63.Kd4 Kc6 64.Kc4 Kd6 65.Kd4 Kc6 with a draw. I was expecting something similar with my move but I had alas misunderstood something!

58.Kb4 with a 98.8% expected score from Leela and the penny dropped for me too! No b6 needed from White. 1–0

58.Kb4 Kb6 59.Kc4 and the king picks up the d-pawn and then moves to the kingside.

I might have managed to make a draw there, but once again it was all so close and fraught! A small detail changed in the position and I might stumble into something completely lost. I decided to try another game and this time just avoid exchanging knights and keep the position as it is. Surely that should make life easier for Black than calculating all these tricky king and pawn endgames?

30.Ke2 Kd7 31.g4 Ne7 32.Nd4 Ng8 33.Ke3 Nf6 34.h3 Ne8 35.Ne2 Nf6 36.Ng3 Kc7 37.Kd4 Kc6 38.Nf1 Ne8 39.Ne3 Nc7 40.f5 g5 41.Nf1 Ne8 42.Ng3 Nf6 43.Nh5 Nd7

Position after Black’s 43rd move: 43…Nd7


Played with an expected score of 62.5%. For now everything seems good: Leela is shuffling and I’m just holding everything as it is. Success guaranteed?

44…Kc5 45.b4+ Kb5 46.Kd4 Kc6 47.Kd3 Kb5 48.Ng3 Kc6 49.Ke3 Kb5 50.Kd4 Kc6 51.Kd3

In a human game it would time to gaze meaningfully into the opponent’s eyes and try to gauge whether a tacit draw offer was being made!

51…Kb5 52.Nh5 Kb6 53.Ng3 Kb5 54.Ne2 Nf6 55.Kd4 Kb6 56.c4

Ah here it comes! After a lot of shuffling, Leela decides to take action! Leela’s expected score is still just 62.0% but for me the pressure is on!

56…dxc4 57.Nc3

Leela getting confusing, stopping me from playing …d5 easily

57…Kc6 58.b5+ Kb6 59.Kxc4

Well I assumed that this should be OK for me. After all, how much can White do with the b5–pawn to protect and Black’s pieces are all pretty active.

59…Ka5 60.Kd4 Kb4

Position after Black’s 60th move: 60…Kb4

Played with confidence! I could have retreated back to b6 but this seemed clearer and more forcing.


Gobsmacked doesn’t even begin to describe it! What is this?? 96.3% expected score according to Leela so my human brain clearly had a lot of catching up to do!

61.Nd5+ Nxd5 62.Kxd5 Kxb5 63.c4+ Kb4 64.Kxd6 Forcing me to waste a tempo getting the c4–pawn. 64…Kxc4 65.Ke7 a5 66.Kxf7 a4 67.f6 a3 68.Kg8 a2 69.f7 a1Q 70.f8Q and then…something! Since I had queened first I assumed that I would find a way to check or grab the h-pawn. It’s actually much more tricky than I thought so I would have suffered there anyway, although the engines give it a soothing 0.18 evaluation! However, Leela was much more vicious!

61…axb6 62.Nd5+ Nxd5 63.Kxd5 Kc3

Position after Black’s 63rd move: 63…Kc3.

63…b5 64.Kxd6 Kc3 65.Kc5 was easy to understand, though also oddly confusing. White’s king ends up on the b-file, mine is on the c-file and it’s Black to move… and yet I lose the race! 65…Kxc2 (65…b4 66.f6) 66.Kxb5 Kd3 67.Kc5 Ke4 68.Kd6 Kf4 69.f6 and White is way too quick

I was still trying to justify myself why I hadn’t been completely tricked and outplayed! 64.Kxd6 Kxc2 65.Ke7 b5 looked pretty similar to the earlier lines after 61.Nd5+. But Leela had something unbelievable planned!


White will pick up the b-pawn first and then move over to the kingside taking the d-pawn along the way!


64…d5 65.Kxb6 Kxc2 66.Kc5

65.Kxb6 I’d seen enough! 1–0

65.Kxb6 Kd3 66.Kc6 Ke4 67.Kxd6 Kf4 68.f6 and we’ve seen this position before!

So what’s the conclusion? Well, the endgame is most certainly drawn but playing it out against Leela really demonstrated a huge number of pitfalls. If you play this line as White, a study of Leela’s technique should help you win this position against an unprepared opponent! If you want to play this line as Black, you definitely need to drill this line to make sure you have some good basic reactions against White’s main tries. In any case, I think this exercise shows most of all that it’s always worth digging deeper into engine recommendations. If a position feels a bit awkward to you, then give it a go against Leela in the way I did. Much better to find out the difficulties now than during a game and as a bonus, it improves your endgame technique enormously!  

4 Comments on “Pirc 4.Bg5: Trying out some endgames against Leela!

  1. The fight of the knight’s for the d5-pawn and the f6-square are quite interesting. When i see that, i know that i have to improve my play with my knights.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.