diff --git a/data/wcc_2023_eolcomment.pgn b/data/wcc_2023_eolcomment.pgn new file mode 100644 index 0000000..7d0b3b4 --- /dev/null +++ b/data/wcc_2023_eolcomment.pgn @@ -0,0 +1,196 @@ +[Event "FIDE World Championship 2023"] +[Site "Astana, Kazakhstan"] +[Date "2023.04.09"] +[Round "1.1"] +[White "Nepomniachtchi, Ian"] +[Black "Liren, Ding"] +[Result "1/2-1/2"] +[WhiteElo "2795"] +[BlackElo "2788"] +[Annotator "Navara,David"] +[UTCDate "2023.04.11"] +[UTCTime "07:41:19"] +[Variant "Standard"] +[ECO "C85"] +[Opening "Ruy Lopez: Closed, Delayed Exchange"] + +{The initial game of a World Championship match is always a bit specific. Both players have come there very well prepared, but they know little about the opponent's preparation. Is the opponent willing to enter a theoretical debate, repeating the same openings again or again, or is he going to vary them, coming with many surprising lines for one or two games? In the initial games +the players are also trying to learn as much as possible about the opponent's preparation, while trying not to reveal much about their own. It makes sense to surprise the opponent, but one should not take too many risks, as a loss in a relatively short match might cause a player big problems. } +1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {Contrary to many other top players, Ding Liren mostly plays 3...a6, although he sometimes plays Berlin, too. Ian Nepomniachtchi has undoubtedly prepared some dangerous ideas against it. } 4. Ba4 Nf6 5. O-O Be7 6. Bxc6 { This move probably came as a surprise. As far as I know, Ian +Nepomniachtchi had not played this move before. White steers the game into a less explored position with some imbalances. Black's doubled pawn is not much of a problem. On the other hand, his bishop pair is not so strong so far. Why +White did not take on c6 already on move 4? Black's e5-pawn might hang in many lines, and Black will need to spend the extra tempo on protecting it. Objectively speaking, White has no advantage here, but it is the case with most topical lines nowadays. The element of surprise can be quite important, as Ian Nepomniachtchi has surely studied the resulting positions deeper. } (6. Re1 { and }) (6. d3 { are much more popular and have also been played by Ian Nepomniachtchi many times. }) 6... dxc6 7. Re1!? { For the second time in a row, Ian Nepomniachtchi chooses a less common move. I am not sure if Ding Liren faced this move before. } (7. d3 { is much more common. Then } 7... Nd7 { leads to quieter positions with mutual chances. Ding Liren faced 7.d3 at least three times in recent years. }) 7... Nd7 { Ding spent 9 minutes on this move. When going for } (7... Bg4 { , Black has to be ready for } 8. h3 Bh5 9. g4!? { . } (9. d3 { is a reasonable positional move, but it looks less dangerous for both +sides, primarily for the one which had not expected this line. }) 9... Nxg4 (9... Bg6 10. Nxe5 { +also deserves a deeper analysis, Black has various option +there. }) 10. hxg4 Bxg4 { looks fine for Black, but it is mostly a good idea to avoid the sharpest lines when a well-prepared opponent surprises you. And there is no doubt that both players came very well prepared! A very sharp position with mutual chances could arise after } 11. d4!? exd4 12. Qd3 c5 13. Nbd2 Qd6 14. c3 { . }) 8. d4!? { White opens the position, postponing his queenside development for the time being. After } (8. Nc3 { Black has reasonable ways to avoid the exchange on d4, e.g. } 8... c5 { or } (8... O-O 9. d4 Bd6!? { , with approximate equality in both cases. })) 8... exd4 { Here } (8... Bd6?! { is less good in view of } 9. Nbd2! exd4 10. Nc4!? \$14 { or } (10. Nxd4 { , as Black's bishop on d6 becomes a target. (The exchange for a White's knight is mostly undesirable, as it deprives Black of his main asset, the bishop pair. })) 9. Qxd4 O-O 10. Bf4 { Black need not be afraid of } (10. Nc3 Bf6 11. Qd3 (11. e5? { is a natural but careless move which runs into nice tactics: } 11... Nxe5! 12. Qxd8 (12. Rxe5? Qxd4 13. Nxd4 Bxe5 \$19) 12... Nxf3+ 13. gxf3 Bxd8 { , when Black remains a healthy pawn up. }) 11... Ne5 { Black can exchange some pieces and develop his queenside with decent play. }) 10... Nc5 11. Qe3 (11. Qxd8?! Bxd8 { leads to an endgame which is good for Black. White's pawn +majority is not very relevant with so many pieces on the board, he would need to exchange the dark-squared bishops and rooks to make his kingside majority count. Without losing his queenside pawns, of course. As it is, Black can just develop the pieces and achieve a good position. }) 11... Bg4?! { This move might be inaccurate. It is not so easy to handle an unfamiliar position over the board. After } (11... Ne6! 12. Bg3 { Black has many reasonable moves leading to approximate equality. Personally I like } (12. Nc3?! Nxf4 13. Qxf4 Qd6 14. e5 Qg6 \$15 { looks promising for Black, whose bishop pair might become more important in the future. }) 12... Bc5 { as well as } (12... f6 { , as these two moves give some room to Black's queen, who might feel uncomfortable on the open d-file. })) 12. Nd4 { After } (12. h3?! Bxf3! 13. Qxf3 Qd4 14. Nc3 Ne6 15. Be3 Qb4 { Black's activity fully compensates for a minor structure defect. In +fact, the c6-pawn protects the d5-square. }) 12... Qd7 { While } (12... Bd6?! 13. Bxd6 cxd6 { would have undoubled Black's pawns, the d6-pawn would remain weak. White would have a better development and a slight advantage after } 14. f3 Be6 15. Nc3 \$14 { or even } (15. Nd2!? Re8 16. Rad1 Qc7 17. Nf1!? \$14 { . })) 13. Nc3 { Ian Nepomniachtchi played very quickly until now, but spent 24 minutes on this move. Either he was already on his own, or he had forgotten the details of his preparation. There is a plenty of theory, so it is impossible to prepare/remember everything. Harikrishna Pentala found a nice idea during his +commentary, namely } (13. h3! Rad8 14. Nc3! Qxd4? (14... Bf6 15. Nf3 Bxf3 16. Qxc5! b6 17. Qf5 Qxf5 18. exf5 Bxc3 19. bxc3 Bd5 20. Bxc7 \$16 { also +leaves White with a clear advantage. }) 15. Nd5! { , when White wins material: } 15... Rxd5 (15... Qxe3 16. Nxe7+ Kh8 17. Bxe3 Nxe4 18. hxg4 \$18) 16. exd5 Qxe3 17. Rxe3 \$18 { . We will learn more about this option from the next note. }) 13... Rad8 14. Nf5?! { White could again play } (14. h3! { , transposing to the previous line. The centralized knight is indirectly protected and Black's bishop needs to make a choice between allowing an exchange and losing control of the f5-square. I should add that Black can (and should) play } 14... Rfe8! { , trying to exchange the centralized knight. } 15. Qg3!? (15. Nb3 { promises White a moderate initiative after } 15... Nxb3 16. cxb3 Bh5 17. Qg3 Bd6 18. e5 { , but not more than that. }) 15... Qxd4! 16. Bxc7! Rd7! { Black has to +watch out. } (16... Bh5? {loses a queen and the game to } 17. Be5! \$18 { . }) 17. hxg4 Bf8! 18. Rad1 Qb4 19. Rxd7 Nxd7 20. Rb1 Nf6 { . Black's activity +compensates for the missing pawn. }) 14... Ne6 { The knight move does not spoil anything, although it might have more accurate to exchange White's active knight for the other bishop, thus doubling White's pawns: } (14... Bxf5 15. exf5 Rfe8 16. g4 { Black's position looks a bit cramped and the knight on c5 currently has no good move, but chess is a very concrete game. Black should equalize through } (16. f6 { is less strong than it looks. Black has at least +two good replies: } 16... Bd6 (16... Bf8!? 17. Qg3 g6 18. Bxc7 Qd2!? \$44 { is risky +but sound, as } 19. Red1 { loses outright to } 19... Qxd1+! 20. Rxd1 Rxd1+ 21. Nxd1 Re1# { . }) (16... gxf6 { is not exactly bad, but } 17. Qg3+ Kh8 18. Bxc7!? { looks pleasant for White, as } 18... Rg8? { loses to a queen sacrifice: } 19. Bxd8! Rxg3 20. Bxe7 { Everything hangs and } 20... Rxg2+ (20... Rxc3 21. Bxf6+!) 21. Kxg2 Qg4+ 22. Kf1 Qh3+ 23. Ke2 { allows White's king to escape. }) 17. Qg3 g6) 16... Bd6 17. Qf3 Bxf4 18. Qxf4 Qd6! 19. Qg3 { and now Black can try } (19. Qxd6 cxd6 20. b4?! Nd7 21. Ne4 Ne5! \$36) 19... h5!? { with mutual chances. } (19... Qxg3+?! 20. hxg3 { is less accurate, as White's pawns would be better doubled than Black's, controling many important squares on the kingside. The h7-pawn could be vulnerable in some lines involving the g4-g5 advance. })) 15. Nxe7+ Qxe7 16. Bg3 Bh5?! { Given that Black needs to move his f-pawn sooner or later, it made sense to play } (16... f5! { , threatening f5-f4. After } 17. exf5 Bxf5 18. f3 Qb4 { Black gets sufficient counterplay against White's queenside pawns. }) 17. f3! \$14 { This move limits the opponent's bishop. White has a slight edge due to his better pawn structure and a more active bishop. He can play for a win without any risk, which is an ideal scenario in a World Championship match. } 17... f6 { Black had to move his f-pawn sooner or later to bring his bishop back into play. That said, such a move also weakens his king a bit. It is not relevant now, but could matter later on. } 18. h3 h6 19. Kh2 { White improves his position little by little. There is no need to hurry, as Black cannot improve his position much, either. } 19... Bf7 20. Rad1 b6 { This is a logical move. The position resembles the Berlin defense, but in our game the pawn formation a5-b6-c5-c7 is more vulnerable, as a loss of the c7-pawn could cost Black another pawn and a game. In Berlin endgames such a danger hardly exists with Black's king on the queenside, and even with Black's king on the kingside White mostly needs to sacrifice a pawn (e5-e6) to win the c7-pawn and perhaps another one. In contrast, in our game the bishop on g3 already eyes c7. After } (20... Rxd1 21. Rxd1 (21. Nxd1!? \$14) 21... Rd8 { White could try } 22. Qa7!? { , a move which is no longer possible after 20...b6. That said, Black +holds his own after } { , a move which is no longer possible after 20...b6. That said, Black holds his own after } 22... Rxd1 23. Nxd1 Qb4! { . }) 21. a3 { White could already play } (21. f4 Rxd1 22. Rxd1 \$14 { , but protecting the b4-square makes sense. }) 21... a5 22. Ne2 (22. f4!? Rxd1 23. Rxd1 Bh5 \$14) 22... Rxd1 (22... c5 \$14 { is a good positional move. It weakens the d5-square, but White is unable to exploit it. After } 23. Nf4 { Black should avoid the knight swap with } 23... Nd4! { , as } (23... Nxf4?! 24. Qxf4 { would leave his queenside somewhat exposed. While } 24... Rxd1 25. Rxd1 Rc8 26. e5!? fxe5 27. Qxe5 Qxe5 28. Bxe5 Be8 \$14 { is not too bad for Black, he would have weak pawns on both flanks. })) 23. Rxd1 Rd8 24. Rd3 { White maintains the pressure, hoping to exchange the rooks under favorable conditions. After } (24. Rxd8+ Qxd8 25. f4 c5 { Black should not face many problems. In many lines he can sacrifice a pawn, steering into a drawish opposite-coloured bishop endgame: } 26. Qd3 (26. f5 Nd4! 27. Qd3 b5!? 28. Nxd4 Qxd4 29. Qxd4 cxd4 30. Bxc7 a4 31. Bb6 Ba2 32. Bxd4 Bb1 { White's +extra pawn does not matter there. } { White's extra pawn does not matter there. }) 26... Qxd3 27. cxd3 Nd4 28. Nxd4 cxd4 29. f5 c6 30. Bc7 Bb3 31. Bxb6 a4 32. Bxd4 Bc2 33. Kg3 Bxd3 34. Kf3 h5!? \$14 { . If White managed to win the c6-pawn, create a passed pawn on f6 and then push b2-b4 to be able to play a3-a4 after Black takes en passant a4xb3, he could generate real winning chances. That said, such a scenario would require too many things going White's way, which is unrealistic on a top level. }) 24... c5 { Black could also play } (24... Rxd3 25. Qxd3 (25. cxd3 c5!) 25... b5!? { with a later a5-a4, moving his queenside pawns outside the reach of White's bishop. Even a loss of the c7-pawn would not be a big problem then, if Black managed to exchange the knights. Knowing the further course of the game, I believe it to be a safer option }) 25. Qd2 c6?! { This move is inaccurate, as it allows an activation of White's pieces and loses a pawn. } (25... Rxd3 26. Qxd3 { is still better for White due to the vulnerability of Black's queenside pawns, but Black should be able to neutralize that advantage with an accurate defense. He can make waiting moves like } 26... Kh7 (26... Be8!? 27. Nc3 c6! { is another option. Then } 28. e5 fxe5 29. Bxe5 b5 30. f4 c4 \$14 { is only +slightly worse for Black. }) 27. Nc3 c6 \$14 { . It is not much fun, but who says that playing a World Championship match is fun? Top players are used to defending worse positions than this one. }) (25... Kf8 26. Rd5!? (26. Rxd8+ Nxd8) 26... Ke8 27. Qd3 c6 28. Rxd8+ Qxd8 29. Qa6 { is also unpleasant for +Black, but } 29... Kf8! 30. Qb7 Kg8! \$14 { brings the king back into safety, while preparing a queen sortie to d2. }) 26. Rxd8+ Nxd8 27. Qf4! { The queen wants to attack the pawns from behind. It seems that Black underestimated this strong maneuver. Ian played this move very quickly. } 27... b5 { Similar was } (27... Bc4!? 28. Nc3 b5 29. Qb8 Kh7 \$16 { . }) 28. Qb8 Kh7 { White has achieved a tangible advantage with strong play. That said, Black has many defensive resources. At this moment Black had 13 minutes left for his next 12 moves. } 29. Bd6?! { White spent 14 minutes on this move. He could collect a pawn through } (29. Bc7 Ne6 30. Bxa5 { , but it is not easy to neutralize Black's counterplay after } 30... Qd7 \$16 { . That said, White has at least two promising options here: } 31. Nf4! (31. Bc3 Qd1 32. Nf4! Nxf4 33. Qxf4 { , when } 33... Qxc2? { loses a +second pawn to } (33... b4! 34. axb4 cxb4 35. Bxb4 Qxc2 36. Bc3 Qd3 { is a much better defense, as Black is ready to meet } 37. e5 { with } 37... f5! { . His +position is not great but seems to be defensible. }) 34. Qf5+ Kg8 35. Qc8+ Kh7 36. Qxc6 b4 37. Bxb4! Qxb2 (37... cxb4? 38. Qxc2) 38. Qxc5 \$18) 31... Nd4!? (31... c4!?) 32. Bb6 Nxc2 33. Bxc5 Ne1! 34. Bd6!? \$16 { White limits Black's queen, staying a healthy pawn up. Perhaps Black can still defend with precise play, but White's position is surely promising in practical terms. }) 29... Qd7 30. Ng3 { White could try } (30. Qc7! Qxc7 31. Bxc7 Nb7 32. Kg3 \$14 { , when Black's position is defensible but unpleasant. }) 30... Ne6 31. f4?! { White could protect the d4-square with } (31. c3 { , maintaining pressure. A +logical move } 31... c4 { could then be met with } (31... a4!? \$14) 32. a4!? bxa4 33. Nf5 \$14 { , when more active pieces would give White an edge. True, it is not much after } 33... Nd8! { , as the opposite-squared bishop endgames are mostly drawn. }) 31... h5 { Black could also play } (31... Nd4!? 32. Bxc5 Nxc2 33. Nf5 Bg6 34. Ne7 Qe8 (34... Be8)) 32. c3 { 1/2-1/2 The game is a draw. } 32... c4 { Black could play } (32... h4! 33. Nf5 Bg6 \$10 { , as } 34. Ne7 Be8 { does not promise White more than equality. His pieces are active but also hang in many lines. Right now Black would like to play 35...Nxf4! }) 33. h4 { White prevents the h5-h4 ideas. } 33... Qd8 34. Qb7 { This move requires a good reaction from Black. On the other hand, the correct reaction resolves the problems. White could try } (34. Qxd8!? Nxd8 { and now perhaps } 35. f5!? (35. a4!?) 35... Nb7 36. Be7 a4 37. Ne2 \$14 { with 38.Kg3 to follow. Black should be able to defend, but I can imagine Magnus Carlsen happily pushing for many decades of moves in such a position. }) 34... Be8! { The only move, but a sufficient one. After } (34... Qxd6? 35. Qxf7 { White wins easily: } 35... Qxf4 (35... Nxf4 36. Nf5 \$18) 36. Qxe6 Qxh4+ 37. Qh3 \$18) 35. Nf5 Qd7 36. Qb8 Qd8 37. Qxd8 Nxd8 38. Nd4 (38. a4!?) 38... Nb7 39. e5 { After } (39. Be7 Kg8 { White's bishop lacks retreat squares. }) 39... Kg8 40. Kg3 Bd7 { The time control is over. Ding Liren has consolidated his position. } 41. Bc7 (41. e6?! Bxe6!) 41... Nc5 { Black temporarily gives a pawn. He must have been happy to activate the knight which had largely been performing defensive tasks until now. } 42. Bxa5 Kf7 43. Bb4 Nd3 44. e6+ Bxe6 45. Nxc6 Bd7 46. Nd4 Nxb2 \$10 { The position is dead equal now, as a knight swap almost invariably leads to a simple draw. } 47. Kf3 Nd3 48. g3 Nc1 { The knight heads for b3, trying to exchange White's centralized knight. } 49. Ke3 Nb3 { An interesting strategic game. It contained no fireworks, but we have seen a high-level fighting game, not a boring theoretical draw. Ian Nepomniachtchi achieved to receive a fresh position and build up an advantage with strong play, but Black's position remained hard to crack even after some inaccuracies. Starting from move 27, Ding Liren demonstrated a high-level defense and made a draw. With the current level of preparation and play, it is very hard to win a classical game against a top player who acts solidly. That said, I am sure that we will see such games soon. (I swear that I had written this before the start of game 2!) } 1/2-1/2 + +[Event "FIDE World Championship 2023"] +[Site "Astana, Kazakhstan"] +[Date "2023.04.07"] +[Round "2.1"] +[White "Liren, Ding"] +[Black "Nepomniachtchi, Ian"] +[Result "0-1"] +[WhiteElo "2788"] +[BlackElo "2795"] +[Annotator "Navara,David"] +[UTCDate "2023.04.11"] +[UTCTime "07:41:19"] +[Variant "Standard"] +[ECO "E10"] +[Opening "Indian Defense: Anti-Nimzo-Indian"] + +1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. h3!? { A very rare continuation as early as on move 4! It leads to fresh positions, or rather to fresh variations on well-known topics. } 4... dxc4 { Ian Nepomniachtchi spent 9 minutes on this move. +Black had a wide choice, but needed to show some cards, as some of the available plans cannot be combined. (Say, both c7-c6 and c7-c5 are reasonable options here, but playing c7-c6-c5 is rarely good here.) Ian Nepomniachtchi decided to steer play into the Queen's Gambit Accepted, where h2-h3 is not the most useful move. } (4... c5!? { looks very reasonable, as the engine's top line } 5. cxd5 (5. e3 { is always an option, but hardly dangerous for Black. }) 5... exd5 6. g3 { does not look impressive with the inclusion of the h2-h3 advance, which somewhat weakens White's kingside. }) (4... c6 5. e3 { leads to a Slav position where h2-h3 is a reasonable move, though not the most ambitious one. } (5. cxd5 exd5 6. Bf4 Bf5)) (4... a6!? { is a witty reply to White's previous move. White can react with } 5. cxd5 exd5 6. Bf4 { , hoping for a +slight edge. }) (4... Be7 5. cxd5 exd5 6. Bf4 { leads to a line where the h2-h3 +advance is useful, although Black should be doing well after } 6... c6 7. Nc3 Bf5 8. g4 Be4!? { . }) (4... Nbd7 5. cxd5 exd5 6. Bf4 Bb4+!? { is another case of a +dynamic equilibrium. }) 5. e3 c5 6. Bxc4 a6 7. O-O { We have transposed to a Queen's Gambit Accepted with a rather unusual h2-h3 move, which is not bad at all. } 7... Nc6 { This move cost Black another 9 minutes. } (7... b5 8. Be2 Nbd7 { was a relevant alternative. White might have a slight initiative after } 9. a4!? b4 10. Nbd2 Bb7 11. b3 { , but the position does not look too scary for Black. }) 8. Nc3 (8. dxc5 Qxd1 9. Rxd1 Bxc5 { leads to a symmetric position +where White cannot hope for much. That said, } 10. Nfd2!? O-O 11. Nb3 Be7 12. Nc3 { still promises him mild initiative. }) 8... b5 9. Bd3 Bb7 { Black managed to develop his pieces. Such positions are considered good for him, but Ding Liren had a concrete idea in mind. } (9... cxd4!? 10. exd4 Nb4!? { was a more +circumspect option, as Black should be doing well after } (10... Be7 11. a4 bxa4 { is another relevant option, but } 12. Ne5 { requires some precision from Black: } 12... Bb7! 13. Rxa4 (13. Qxa4 Qxd4! 14. Nxc6 Qxa4 15. Rxa4 Bxc6 16. Rxa6 Rxa6 17. Bxa6) 13... O-O 14. Bxa6!? Rxa6!? 15. Rxa6 Nxe5 16. Ra7 Qb6 (16... Nf3+!? 17. gxf3 Qb8 \$14 { is a braver option, but it seems that an exchange coupled with an extra pawn are worth slightly less than Black's activity and structural advantage. }) 17. Rxb7 Qxb7 18. dxe5 Nd7 \$44 { White is a pawn up, +but Black's pieces are more active. }) 11. Be2 Be7 12. a4 bxa4 13. Nxa4 O-O { . }) 10. a4! { White immediately attacks Black's queenside before the opponent could complete development. } 10... b4 (10... c4?! 11. axb5! axb5 12. Rxa8 Bxa8 (12... Qxa8?? 13. Nxb5 cxd3 14. Nc7+) 13. Bb1 b4 (13... Qa5 14. e4 \$14 { gives White a central control, with both advances d4-d5 and e4-e5 being +dangerous for Black. }) 14. Ne4 { Black has to tread carefully to avoid problems with his weak c4-pawn or undeveloped kingside }) (10... cxd4 { gives White an extra option } 11. axb5!? (11. exd4 { might transpose to 10...b4 followed by 11. +..cxd4. }) 11... dxc3 12. bxc6 Bxc6 { . Computer slightly prefers White's position, although it is hard to achieve anything tangible here. } 13. Nd4!? (13. Ne5 Bb5 14. bxc3 Bxd3 15. Nxd3 Be7) 13... Bd7 14. bxc3 (14. Qc2!? cxb2 15. Bxb2 Bd6 16. Rfd1 O-O 17. Nb3 Be7! 18. Nc5 Kh8!? { should be safe for Black, +as } 19. Nxd7 Qxd7 20. Bxh7 { allows } 20... Qc8! { with a queen exchange. }) 14... e5 15. Ne2 \$14) 11. Ne4 Na5!? { A good move, and possibly also an unexpected one. } (11... cxd4 12. exd4 Be7 13. Re1 O-O 14. Be3 \$36 { looks preferable for White, as Black has weak squares on the c-file }) (11... Qd7 { was another relevant option. } 12. a5 (12. Nxc5 Bxc5 13. dxc5 O-O-O! 14. Be2 Qxd1 15. Bxd1 a5 { Black is going to regain a pawn without allowing the activation of +White's bishop pair. } (15... Ne4 { might be less accurate, as the following +sharp line promises White more than enough compensation for a pawn: } 16. a5! Nxc5 17. Ng5! Rd7 18. e4 h6 19. Be3 Nd3 20. Nf3 Nxb2 21. Be2 Nd3 22. Nd2! Kb8 23. Nc4 \$14)) 12... cxd4 13. exd4 Be7 14. Bf4!? (14. Be3) 14... O-O 15. Nc5 Bxc5 16. dxc5 Rfd8 17. Be2 \$14) 12. Nxf6+ { White spent 33 minutes on this move. He had played quickly until now. My first independent move often turns out to be inaccurate. It occasionally happens even to stronger players. } (12. Nxc5! Bxc5 13. dxc5 { was more promising. Black can regain the pawn in many ways, but White has a bishop pair in an open position, which often ensures him an edge. } 13... Be4! { is the critical option, which looks very good for Black at first sight and not bad under a closer inspection, either: } (13... Nd7 14. c6!? { This move brings some a shade of disharmony in Black's setup. Black would prefer taking on c5 with his other two minor pieces remaining in their positions. } 14... Bxc6 (14... Nxc6 15. Qe2 Nce5 (15... Nc5 { is a relevant option even here, but the other knight would be slightly better placed on a5 than on c6. }) 16. Nxe5 Nxe5 17. Bc2 \$14) 15. Nd4 Nc5 16. Bc2 \$14) 14. Bxe4 Qxd1 15. Rxd1 Nxe4 16. Bd2!? (16. c6!? Nb3 (16... Nxc6?! 17. Bd2 Rd8 18. Rac1 \$14 { causes Black problems with his queenside weaknesses. }) 17. Rb1 Rd8! 18. Nd4! Ke7 19. c7!? Rd6 20. f3 Nec5 21. Bd2 a5 22. Nxb3 Nxb3 23. Be1 { . Now Black should be able to regain the pawn after } 23... f6 24. Bg3 Rc6! (24... e5? { is surprisingly bad in view of } 25. f4! { , when White's bishop enters play with a decisive effect, e.g. } 25... Ke6 26. fxe5 fxe5 27. Rxd6+ Kxd6 28. Rd1+! Kxc7 29. Bxe5+ \$18) 25. Rd3 Nc1! { with equality. All these lines look risky for White, whose queenside is underdeveloped. }) 16... Nxd2! (16... Nb3?! 17. Bxb4 Rb8 18. Ba3 Nxa1 19. Rxa1 { slightly favors White. If Black castles, his king might be too far from the queenside pawns. If he directs his king to the queenside instead, his monarch might become a target. }) 17. Nxd2 O-O-O! 18. Ne4 Nb3! 19. Nd6+ Rxd6 20. cxd6 Nxa1 21. Rxa1 Kd7 22. Rc1 Kxd6 { is a sharp line leading to a drawish endgame. }) 12... gxf6 13. e4?! (13. dxc5!? Qd7!? (13... Bxc5 { and }) (13... Rg8 { are relevant options as well. }) 14. c6! Qxc6 (14... Bxc6 15. Nd4 Bb7 16. Qe2 Rg8 17. f3 \$13) 15. e4) 13... c4! 14. Bc2 Qc7 \$15 { Black has achieved a favorable pawn structure. His queenside majority will protect the king on b8 and might become a big asset in the endgame. He can attack along the g-file. White currently controls the center, but Black can easily attack it with his pieces and with the f6-f5 push. Ian Nepomniachtchi is an experienced Gruenfeld player, so he knows well how to undermine a pawn center! } 15. Bd2 Rg8 (15... O-O-O { was also an option, and possibly a slightly better one. The game has demonstrated that Black achieves an advantage if he manages to bring his king into safety without losing anything. } 16. Qe1 Qb6 17. Bf4 Bd6 18. Qe3 Kb8 \$15) 16. Rc1 { This is a very +logical move, but even more concrete action was needed. } (16. Qe1! f5! 17. Qe2! (17. d5 O-O-O! 18. Bxb4 Bxb4 19. Qxb4 fxe4 20. Bxe4 Qf4! 21. Qc5+ Kb8 22. Qe3! Qxe3 23. fxe3 f5! 24. Bc2 Bxd5 25. Rae1 Nc6 26. e4 fxe4 27. Bxe4 \$15) 17... O-O-O 18. Rad1 { leads to a position with mutual chances. +Black's position might be easier to play, but both sides need to play +precisely. }) 16... O-O-O 17. Bd3?! { This is logical but wrong. White spent 15 minutes on this move and then played the next one very quickly. } (17. Qe1! f5! 18. Kh1 Nc6! { also seems to favor Black, but } 19. Qe2! Nxd4 20. Nxd4 Rxd4 21. f3 fxe4 22. Bxe4 Bxe4 23. fxe4 Bd6 24. e5! Bxe5 25. Bxb4 \$132 { gives White reasonable counterplay. }) 17... Kb8 { Before pushing f6-f5, Black brings his king into (relative) safety. } 18. Re1?! { This does not work, but +nor did a concrete action: } (18. Bxc4!? { I guess that the Chinese grandmaster planned this from afar, but spotted some important nuance only after move 16. } 18... Nxc4 19. Qe2 { looks good before one finds } (19. b3 Nb2! (19... Nxd2? 20. Rxc7 Nxf3+ 21. Qxf3 Kxc7 22. Qxf6 { allows White to generate counterplay against Black's weak king: } 22... Rd7 23. d5! exd5 24. Qf4+! Kb6 (24... Bd6? { loses material to } 25. e5! Bf8 26. e6+ Bd6 27. Qc1+! \$18) 25. Qb8! dxe4 26. a5+! Kxa5 27. Qe8! \$44 { with a possible move repetition after } 27... Bc6 28. Qb8 Bb7 29. Qe8 { . }) (19... Bxe4! { This is simple and strong. } 20. Rxc4 Qb7 21. Bf4+ Bd6 22. Bxd6+ Rxd6 23. Kh2 Rc6! 24. Rxc6 Qxc6 \$17 { The material is +equal, but Black has a huge positional advantage. His pieces are more active. In the middlegame White has problems with his king and the g2-pawn, whereas in endgames the b3-pawn could easily become vulnerable. }) 20. Rxc7 (20. Qe2?! Qd6 21. Rc2 f5! { allows White to win the knight back, but in the meantime Black opens the long diagonal with a decisive attack. }) 20... Nxd1 21. Rxb7+ Kxb7 22. Rxd1 Be7 \$17 { gives Black a technically winning position. }) 19... Rc8! (19... Nxd2? 20. Rxc7 Nxf3+ 21. Qxf3 Kxc7 22. Qxf6 { is a much worse version, as the +king is exposed on c7. }) 20. b3 Nxd2 21. Rxc7 Nxf3+ 22. Qxf3 Rxc7 { , when +Black has both material and positional advantage. }) (18. Kh1 f5! 19. Qe1 Qb6 20. Bc2 \$17 { also favors Black, but looks less one-sided. }) (18. Qe1 f5! 19. Kh1 Qb6 \$17 { transposes to the previous line. }) 18... f5! 19. Bc2 Nc6! { The e4-pawn is currently well protected, but it turns out that Black can also attack d4! } (19... f6!?) 20. Bg5 (20. Bb1 fxe4 21. Bxe4 f5! 22. Bxc6 Qxc6 { gives Black a strong pressure along the long diagonal, coupled with a positional advantage due to a bishop pair and a favorable queenside structure. }) 20... Rxg5! { Ian Nepomniachtchi is in his element. He sacrifices an +exchange to further activate his pieces. } 21. Nxg5 Nxd4 22. Qh5 f6 (22... Bc5!?) 23. Nf3? { White faced a very difficult choice, but this move simplifies +Black's task. Given that all the options were bad, it made sense to complicate the position. True, the resulting positions are not only highly advantageous for Black, but usually also easier to play for him in terms of avoiding mistakes. } (23. Nxh7! Bc5 { was also bad for White, but } 24. Bd1! { forces +Black to make some accurate steps on each of the ways to Rome. } (24. Nxf6 Qf4! { is not over yet, but it is winning for Black. } 25. Red1 Ka7!) 24... Bd6!? (24... fxe4 { This might be winning, but Black needs to find many precise moves on the way to the whole point. } 25. Rxc4 Nf5! 26. Rxc5 (26. Qe2 Bxf2+!) 26... Qxc5 27. Nxf6 Rd2 28. Ng4 Qd6! { A very important move, which is easy to miss. } 29. Bb3 (29. Be2 Rxe2! 30. Qe8+ Bc8! { The bishop protects +the e6-pawn. } 31. Rxe2 Qd1+ 32. Kh2 Qxe2 \$19) 29... Nd4! 30. Bc4 Nc2! 31. Rf1 e3! \$19) 25. Nxf6 { This is far from forced, but the alternatives are +similarly bad. } 25... Bh2+ 26. Kh1 Bf4 27. Rb1 (27. Ra1 c3!? 28. bxc3 Qxc3! { leads to a rare fork. In fact, even White's knight is hanging in many lines, e. +g. } 29. Bf3 Bd2 30. Red1 Nxf3 31. Qxf3 Qxf6 { . }) 27... Bd2 28. Rf1 Qg7 29. Qh4 Bg5 30. Nh5 Bxh4 31. Nxg7 Bxe4 32. Rc1 Bd3 \$19) (23. exf5?! fxg5 24. fxe6 { is bad for many reasons, as Black has a slight material advantage and dominates the board. }) (23. Nf7 Rd7 24. exf5 (24. Nh6 { leaves White's pieces +in complete disarray. Black has numerous winning continuations, } 24... Nxc2 25. Rxc2 b3 26. Rcc1 Bb4 27. Red1 Bd2! 28. Ra1 Bxe4 \$19 { being one of them. }) 24... Nxc2 25. Rxc2 e5!? 26. Nxe5 fxe5 27. Qe8+ Rd8 28. Qxe5?! Qxe5 29. Rxe5 Rd1+ 30. Kh2 Bd6 31. f4 { and now many continuations win, but it might be better to +postpone taking on e5, first protecting the c4-pawn with a move like } 31... Rd4!? \$19 { . }) 23... Nxc2 24. Rxc2 Bxe4 { This is simple and strong. } (24... b3!? { was even more resolute, e.g. } 25. Rd2 (25. Rcc1 fxe4 \$19) 25... Bb4! 26. Rxd8+ Qxd8 27. Rf1 fxe4 \$19) 25. Rd2 (25. Rcc1!? Bc5! 26. Qh4 Rg8 27. Kh1 Qg7 28. Rg1 { would have avoided an immediate catastrophe at the cost of a long +suffering with very little hope. Black has many good moves, including } 28... c3 29. bxc3 b3! 30. Qf4+ Ka8 31. Qd2 Qb7! { with a decisive advantage. The difference in piece activity is striking. }) 25... Bd6 \$19 { The game is over. The bishop pair controls the board. Moreover, Black's c-pawn can hardly be stopped. } 26. Kh1 { Black was threatening to exchange on f3, give a check on h2 and then take a rook. } (26. Nd4 c3 27. bxc3 bxc3 { was equally bad for White, +who has no time to capture on e6: } 28. Rdd1 (28. Nxe6 cxd2! \$19) 28... c2 29. Nxe6 cxd1=Q 30. Rxd1 Bh2+! \$19) 26... c3 27. bxc3 bxc3 28. Rd4 c2 29. Qh6 e5 { White resigned, as he loses a lot of material without getting anything in return. Ian Nepomniachtchi was surely surprised by Ding Liren's move 4, but with healthy moves he achieved a good position, overtook initiative, gained central control with a strong exchange sacrifice and then went on to convert his advantage. A convincing victory with Black! That said, the match has just begun and there are many games left. Hopefully the Chinese grandmaster recovers from a loss and we will be able to see a dramatic match of two elite players! } 0-1 + +[Event "FIDE World Championship 2023"] +[Site "Astana, Kazakhstan"] +[Date "2023.04.12"] +[Round "3.1"] +[White "Nepomniachtchi, Ian"] +[Black "Ding, Liren"] +[Result "1/2-1/2"] +[WhiteElo "2795"] +[BlackElo "2788"] +[Annotator "Navara,David"] +[UTCDate "2023.04.14"] +[UTCTime "07:55:51"] +[Variant "Standard"] +[ECO "D35"] +[Opening "Queen's Gambit Declined: Exchange Variation, Positional Variation"] + +1. d4 { A slight surprise for many people, as Ian Nepomniachtchi mostly plays 1. +e4. That said, players prepare for such matches for many months, so this in +itself cannot surprise the opponent. } 1... Nf6 2. c4 e6 3. Nc3 { The Russian +grandmaster played this move rarely, mostly in speed games played until 2021. +True, he played the Nimzo in a game against Andrei Esipenko in February 2023, +in his last classical tournament before the match. } (3. Nf3 { was a bit more +common move in Ian's games, although he also used it mostly in speed games. }) 3... d5 (3... Bb4 { is the most common move on a top level. Ding Liren also +mostly chooses it, but Ian Nepomniachtchi has surely prepared something there. }) 4. cxd5 exd5 5. Bg5 c6 6. e3 { The Carlsbad structure is strategically very +complex, as both sides have a multitude of plans. The resulting positions +mostly require good understanding rather then a precise calculation or +imagination. White has slightly easier play, but Black has a solid position. +Carlsbad ("Karlsbad" in German, "Karlovy Vary" in Czech, "Карловы +Вары" in Russian) is a lovely Czech spa town near the border with Germany, +very popular among Russians. Even the legendary chess trainer and writer Mark +Dvoretsky was travelling there often. } 6... h6 { This push had been considered +inaccurate until recently, but has become very popular during the last 10 +years. Black can no longer transfer his knight to g6, but it has turned out +that a bishop exchange leads to a satisfactory position. } 7. Bh4 Be7 8. Bd3 O-O 9. Qc2 Re8 10. Nge2 Nbd7 11. O-O (11. O-O-O? { is too optimistic, as Black's +attack comes first. Here is a sample variation: } 11... b5! 12. Rdg1 (12. g4 Nxg4 { does not give White sufficient compensation. }) 12... Nb6 13. Bxf6 Bxf6 14. h4 b4 15. Nd1 h5! 16. Nf4 c5 17. dxc5 Bd7 18. Nxh5 Rc8 19. Nxf6+ Qxf6 \$17 { with a strong attack. }) (11. f3!? { avoids the +bishop exchange, but Black can again continue with } 11... b5!? 12. O-O Bb7 13. Rac1 a6! { , preparing c6-c5. Now } 14. e4?! { invites strong counterplay: } (14. Qd2 c5 15. dxc5 Nxc5 { leaves both pawns e3 and d5 equally weak. }) 14... b4! { If you dislike long variations, feel free to skip them. They just show +that the untimely e3-e4 push allows Black to take over initiative. } (14... dxe4 15. Nxe4 (15. fxe4? c5! 16. Bxf6 Bxf6 17. e5 Bg5 \$17 { is already bad for +White. }) 15... Nxe4 16. Bxe7 Qxe7 17. Bxe4 (17. fxe4 Rac8 \$36 { followed by +c6-c5 is pleasant for Black. }) 17... Rad8) 15. e5 (15. Na4 dxe4! 16. fxe4 c5! (16... Nxe4!? 17. Bxe4 Bxh4 { is a relevant motif which I missed in +several games here on Lichess. Right now it only leads to an unclear position +after } 18. Bh7+! Kh8 (18... Kf8?! 19. Qc4) 19. Rxf7 { . }) 17. Nxc5 (17. e5? Nd5 \$17 { creates problems with a fork on e3. }) 17... Nxc5 18. dxc5 Rc8 19. Bc4 Kh8! (19... Bxc5+ 20. Kh1 Be3 21. Bxf6 gxf6 { is also an option, but a +dangerous-looking one. }) 20. Bxf7 Bxc5+ 21. Kh1 Bxe4 22. Bxf6 gxf6 23. Qd1! Qxd1 24. Rfxd1 Bxg2+! 25. Kxg2 Rxe2+ 26. Kh1 Rxb2 27. Bb3! { White +threatens 28.Rd5. } 27... Re2 28. Bc4 \$15 { White regains one pawn and should hold +rather easily. That said, it is not an inspiring line from White's point of +view, anyway. }) 15... bxc3 16. exf6 Bxf6 17. Bxf6 Qxf6 18. bxc3 (18. Qxc3 Nf8! \$36 { Black has initiative in spite of his passive bishop. White has a weak +square on e3 and a weak central pawn. Black cannot invade there immediately +because of 20. Bh7+, but he can double the rooks or just play 19...a5, +improving a queenside structure. Moving the knight to g3 would weaken d4 and +f4. }) 18... a5 { Black will exchange the bishops on a6 with good play. His +knight could then be transferred to c4. }) 11... a5 { Black makes a useful move. +The weakening of the b6-square is not a big problem. Black might play b7-b5 +later. } (11... Nh5 12. Bxe7 Qxe7 { leads to a typical position which might be +slightly better for White according to Stockfish, but it is very hard to prove +that in a game. }) (11... Ne4 { is a more straightforward approach. After } 12. Bxe7 Qxe7 13. Bxe4 dxe4 14. Rfd1 Nf6 15. d5 { or } (15. h3!? { White seems to be +slightly better, though. })) 12. a3 (12. f3 b5 13. Bf2 { and }) (12. Rfe1!? Nh5 13. Bxe7 Qxe7 14. h3 \$36 { are two of many alternatives to the game +continuation. }) 12... Nh5 (12... b5 { is another option. White cannot exploit a +weakening of the c5-square here, as his knights cannot get there easily. }) 13. Bxe7 Qxe7 14. Rae1 { It often makes sense to play for e3-e4 once Black has +played a7-a5, as the typical push c6-c5 has become problematic because of the +weakening of the b5-square. } 14... Nf8 15. Nc1 (15. Na4 { was a reasonable +alternative, but Black remains solid after } 15... Nf6 { . It is hard improve White's +position. }) 15... Nf6 16. f3 { If being given enough time, White would like to +push e3-e4. That said, Black can prevent that by attacking the d4-pawn. } 16... Ne6 { All this has already been played in an online rapid game Giri - Ding in May +2022. } 17. N1e2 { The knight returns now when Black's queen no longer attacks +e3. That said, this plan is not very dangerous for Black. } (17. Qd2 Rb8 { should also be equal. Black can choose between b7-b6 (often followed by c6-c5) +and b7-b5-b4 depending on White's move, for instance } 18. Nb3 (18. N1e2 b5! \$132) 18... Qd8! { Black prevents e3-e4. } (18... b6?! 19. e4! { allows +White to execute a strategically desirable advance at the right moment. }) 19. Kh1 Kh8!? { The king avoids a check on h7, thus complicating the e3-e4 advance. +(If you ask for a more detailed explanation, please look at the 19...b6 20.e4 +line.) } (19... b6 { allows } 20. e4 { , when } 20... dxe4?! (20... Nh5!) 21. fxe4 Nxd4? { fails tactically to } 22. Nxd4 Qxd4 23. e5! Rd8 (23... Rxe5? { immediately loses to } 24. Bh7+! Kxh7 25. Qxd4 \$18) 24. exf6 Qxd3 25. Qf4! { White attacks both rooks at the same time, as 26.Rd1 is also a threat. } 25... Bb7 26. fxg7 Qg6 27. Ne4 c5 28. Nf6+ Kxg7 29. Rf2 { with a crushing attack. We have +gone too far, but lines like this are typical for the Carlsbad structure. A +recent blitz game Navara - Alonso Rosell from the European Blitz Championship +2022 saw such a scenario. We played a different opening, yet the similarities +are striking. }) 20. Qf2 b6 21. e4 Nf4! 22. Bb1 Ba6 23. Rg1 { Here Black needs +to do something not to get steamrolled after e4-e5. There are several ways to +counter this scenario, including } 23... dxe4 (23... Bd3!?) (23... c5!?) 24. fxe4 Nd3 25. Bxd3 Bxd3 26. e5 Ng4!? 27. Qg3 Bc4 { with mutual chances. It is +fascinating how quickly can a positional struggle transform into a tactical +skirmish! Given how many razor-sharp opening lines have been analyzed to a +draw, playing "slower" openings like Carlsbad makes a lot of sense even for +sharper players. }) (17. Qf2 b5! { looks good for Black, who is ready to +push b5-b4 and then perhaps develop his bishop to a6. } (17... c5 18. Bb5! Rd8 19. dxc5 Qxc5 20. Nb3 Qb6 21. Rd1 Bd7 22. Bxd7 Rxd7 23. Nd4 Re8 { happened in +the aforementioned Giri - Ding game. White seems to have a minute edge after } 24. Rfe1 { or } (24. Na4))) 17... c5 (17... b5! { was a good option, here. It +would be bad if White could settle his knight on c5, but it is unrealistic. +Concrete attempts to attack c6 or c5 fail: } 18. Bf5?! (18. Nd1 Ba6!? 19. Qxc6?! Rec8 20. Qb6 Bb7! { Here White would have to exchange the queen for a rook, +a bishop and two pawns. It is more than enough material, but White's pieces +would not be placed too harmoniously and the f2-f3 advance could cause some +problems to White's king, as the pawns do not go backwards. } 21. Bxb5 (21. Qxb5 Ba6! 22. Qxa6 Rxa6 23. Bxa6 Rc2 \$36) 21... Rcb8! 22. Bd3 Ba6 23. Qxa6 Rxa6 24. Bxa6 h5 \$36) 18... b4 19. axb4 axb4 20. Nd1 Ba6 { and now } 21. Qxc6? { loses to } 21... Bxe2 22. Rxe2 Nxd4! 23. exd4 Qxe2 \$19) 18. Bb5?! { White only had +a slight initiative, but this move allows Black to equalize. } (18. Nf4! cxd4 (18... Nxf4 19. exf4 Qxe1? 20. Rxe1 Rxe1+ 21. Kf2 Re8 22. dxc5 \$16 { is very +bad for Black, who lacks counterplay. White will just transfer the knight to +d4 and then start pushing pawns on the kingside or even on the queenside. }) 19. exd4 Qd8 20. Nxe6 Bxe6 21. Qf2 \$36 { It is not much, but a risk-free edge is +welcome in such matches. }) 18... Rd8 19. dxc5 (19. Qd2!? b6 20. Ng3 { would +have maintained the tension, but Black is doing well. Computer suggests +strange moves like } 20... Qf8 { (bringing the queen to a safer place) and } (20... Ra7 { , preparing a rook transfer to e7 or d7 (after Bc8-d7). })) 19... Qxc5 20. Qd2 Bd7 (20... d4 21. exd4 Nxd4 22. Nxd4 Qxd4+ 23. Qxd4 Rxd4 { should also lead to +equality, but White would still have a very slight initiative. In the game +Ding Liren soon overtook the initiative, therefore his choice looks better. }) 21. Bxd7 (21. Nd4 Rac8 22. Rc1 (22. Nxe6 fxe6) 22... Nxd4 23. exd4 Qd6) 21... Nxd7 22. Nd4 Nb6 { Black has reached a comfortable position. } 23. Rd1 Nc4 24. Qf2 Rac8 { Black maintains the pressure. } (24... Nxa3 { is also equal if +White finds } 25. e4! { . There is no doubt that both players saw that. } 25... Nxd4 (25... dxe4?? { loses a piece to } 26. Nxe6 (26. Nxe4 \$18) 26... Qxf2+ 27. Kxf2 fxe6 28. bxa3 \$18) 26. Rxd4 Nb5 27. Nxb5 (27. Rxd5 Qxf2+ 28. Kxf2 Nxc3 29. Rxd8+ Rxd8 30. bxc3 b5 31. Rb1 Rb8 32. Ke3) 27... Qxb5 28. Rfd1 { White regains a pawn with equality. }) 25. Na4 Qe7 26. Rfe1 Qf6 (26... Nxd4!? 27. Rxd4 (27. exd4 Qf6 \$15) 27... b5 28. Nc3 Qc5 { looks equal, but with the +pawns a3 and b2 hanging, White needs to be a bit careful: } 29. b4!? (29. Red1 Nxb2 30. Qxb2 Qxc3 31. Qxc3 Rxc3 32. Rxd5 Rxd5 33. Rxd5 Rxe3 34. Rxb5 Rxa3 35. h4 \$15 { leads to a drawish endgame. Some versions of such an endgame can be +very tricky, but here Black's king is passive and the kingside pawn structure +is better for the defender than usually, so it would be a simple draw. }) 29... Qc6 30. Red1!? Nxe3 31. Qxe3 Re8! (31... Qxc3 32. Qxc3 Rxc3 33. Rxd5 Rxd5 34. Rxd5 Rxa3 35. Rxb5 { leads to mass exchanges and a dead draw. }) 32. Ne4!? dxe4 33. bxa5 exf3 34. Qxf3 Qxf3 35. gxf3 Ra8 36. a4 Rxa5 37. axb5 Rxb5 38. Rd8 { is another very drawish endgame where an extra pawn cannot be converted. }) (26... Qe8!? 27. Nc3 Nxa3 { was more ambitious but also somewhat risky. White +equalizes after } 28. Nf5 Rc5 29. Qg3 (29. Nd4!? b6 30. e4 { might also lead to +equality. }) 29... Kf8 (29... Nc4 { looks very dangerous, as Black's king will +be exposed once the h6-pawn gets off the board. That said, White needs to be +more accurate in the ensuing complications: } 30. Nxh6+ Kf8 31. Nf5 g6 32. e4! d4 (32... gxf5? 33. exf5) 33. Qh3! gxf5 34. exf5 Rxf5! 35. Qxf5 dxc3 36. Qh7 { White also has other moves here. } 36... Rxd1 37. Rxd1 c2! 38. Qh8+! (38. Qxc2? Ne3! \$19) 38... Ke7 39. Qh4+ f6 40. Re1! Ne5 41. Qh7+ Kf8 42. Qxc2 \$13 { with a dynamic equilibrium. }) 30. e4! d4 31. Rxd4! Rxd4 32. Nxd4 Nc4 (32... Nxd4 33. Qd6+ Qe7 34. Qb8+! Qe8 35. Qd6+ { leads to a move repetition. }) 33. Nxe6+ Qxe6 34. Qf2) 27. Nb5 Nc7 28. Nd4 Ne6 (28... b5 29. Nc3 { is also +equal, e.g. } 29... b4 30. axb4 axb4 31. Na2! (31. Na4 Ne6 { is pleasant for +Black. }) 31... b3 { and now any knight retreat maintains equality, while } 32. Nxb3?! (32. Nc1) (32. Nc3) 32... Nxb2 \$15 { followed by 33...Nc4 gives +Black a slight pull due to disorganized White's pieces, but not more. }) 29. Nb5 Nc7 30. Nd4 Ne6 { Ding Liren has recovered from the previous loss and played a +good game. He equalized easily and even had slight initiative towards the end. +On the other hand, White was never in real danger. The game was relatively +short, with most of the action remaining behind the curtains. Ian +Nepomniachtchi maintains the lead, while Ding Liren needs only one win to +level the score. } 1/2-1/2 diff --git a/lib/src/pgn.dart b/lib/src/pgn.dart index c729aad..5bb6340 100644 --- a/lib/src/pgn.dart +++ b/lib/src/pgn.dart @@ -123,11 +123,19 @@ class PgnGame { /// tokens. static List> parseMultiGamePgn(String pgn, {PgnHeaders Function() initHeaders = defaultHeaders}) { + final multiGamePgnSplit = RegExp(r'\n\s+(?=\[)'); final List> games = []; - _PgnParser((PgnGame game) { - games.add(game); - }, initHeaders) - .parse(pgn); + final pgnGames = pgn.split(multiGamePgnSplit); + for (final pgnGame in pgnGames) { + final List> parsedGames = []; + _PgnParser((PgnGame game) { + parsedGames.add(game); + }, initHeaders) + .parse(pgnGame); + if (parsedGames.isNotEmpty) { + games.add(parsedGames[0]); + } + } return games; } @@ -775,8 +783,7 @@ class _PgnParser { case _ParserState.moves: { if (freshLine) { - if (_isCommentLine(line)) return; - if (_isWhitespace(line)) return _emit(); + if (_isWhitespace(line) || _isCommentLine(line)) return; } final tokenRegex = RegExp( r'(?:[NBKRQ]?[a-h]?[1-8]?[-x]?[a-h][1-8](?:=?[nbrqkNBRQK])?|[pnbrqkPNBRQK]?@[a-h][1-8]|O-O-O|0-0-0|O-O|0-0)[+#]?|--|Z0|0000|@@@@|{|;|\$\d{1,4}|[?!]{1,2}|\(|\)|\*|1-0|0-1|1\/2-1\/2/'); @@ -814,12 +821,14 @@ class _PgnParser { if (_stack.length > 1) _stack.removeLast(); } else if (token == '{') { final openIndex = match.end; + _state = _ParserState.comment; if (openIndex < line.length) { final beginIndex = line[openIndex] == ' ' ? openIndex + 1 : openIndex; line = line.substring(beginIndex); + } else if (openIndex == line.length) { + return; } - _state = _ParserState.comment; continue continuedLine; } else { if (token == 'Z0' || token == '0000' || token == '@@@@') { diff --git a/test/pgn_test.dart b/test/pgn_test.dart index b5cc20c..ce9be5b 100644 --- a/test/pgn_test.dart +++ b/test/pgn_test.dart @@ -276,6 +276,39 @@ the players are also trying to learn as much as possible about the opponent's pr expect(games.length, 3); }); + /// Test for scenario where + /// a. '{' is the last character on a line + /// b. a '}' character appears somewhere before the '{' on that same line + /// (line 22 of wcc_2023_eolcomment.pgn) + /// + /// This tests a fix which avoids an infinite loop in the described scenario. + test('Parse initial game comments - comment before newline', () { + final String data = + File('./data/wcc_2023_eolcomment.pgn').readAsStringSync(); + final game = PgnGame.parsePgn(data); + expect( + game.comments, + [ + ''' +The initial game of a World Championship match is always a bit specific. Both players have come there very well prepared, but they know little about the opponent's preparation. Is the opponent willing to enter a theoretical debate, repeating the same openings again or again, or is he going to vary them, coming with many surprising lines for one or two games? In the initial games +the players are also trying to learn as much as possible about the opponent's preparation, while trying not to reveal much about their own. It makes sense to surprise the opponent, but one should not take too many risks, as a loss in a relatively short match might cause a player big problems.''' + ], + ); + }); + + /// Test for scenario where + /// a. '{' is the last character on a line + /// b. a '}' character appears somewhere before the '{' on that same line + /// (line 22 of wcc_2023_eolcomment.pgn) + /// + /// This tests a fix which avoids an infinite loop in the described scenario. + test('pgn file - WCC 2023 - comment before newline', () { + final String data = + File('./data/wcc_2023_eolcomment.pgn').readAsStringSync(); + final List> games = PgnGame.parseMultiGamePgn(data); + expect(games.length, 3); + }); + test('pgn file - kasparov-deep-blue-1997', () { final String data = File('./data/kasparov-deep-blue-1997.pgn').readAsStringSync(); @@ -297,7 +330,9 @@ the players are also trying to learn as much as possible about the opponent's pr final List> games = PgnGame.parseMultiGamePgn(data); expect(games[0].moves.mainline().map((move) => move.san).toList(), ['e4', 'e5', 'Nf3', 'Nc6', 'Bb5']); - expect(games.length, 4); + expect(games[2].moves.mainline().map((move) => move.san).toList(), + ['e4', 'e5', 'Nf3', 'Nc6', 'Bb5', 'e4', 'e5', 'Nf3', 'Nc6', 'Bb5']); + expect(games.length, 3); }); test('pgn file - headers-and-moves-on-the-same-line', () { @@ -364,10 +399,10 @@ the players are also trying to learn as much as possible about the opponent's pr expect(game.moves.mainline().length, 65); }); - // test('game from crafty', () { - // final game = PgnGame.parsePgn(PgnFixtures.fromCrafty); - // expect(game.moves.mainline().length, 68); - // }); + test('game from crafty', () { + final game = PgnGame.parsePgn(PgnFixtures.fromCrafty); + expect(game.moves.mainline().length, 68); + }); }); }