Showing posts with label Chess. Show all posts
Showing posts with label Chess. Show all posts

Monday, March 15, 2010

Chess Query Language

It's amazing how many tools are available on the web for seemingly obscure tasks. Recently, a friend of mine was writing a short story, and he needed an answer to this question: In high-level chess games, how often do the different pieces survive through the game without being captured (ignoring kings)? In the context of this question, each of the 30 starting pieces is treated as distinct; we want to know how often the pawn that starts on the a2 square survives, how often the b2-pawn survives, etc., rather than how often general pawns survive.

I think this qualifies as an obscure question. It seems simple enough to answer in principle - just get a database of games, and write something to play through each game, tracking which pieces survive. Simple enough, but a fair bit of work. Luckily there's a tool that will do this type of thing: Chess Query Language.

CQL is quite powerful, and it's pretty straightforward to set up a CQL query. For example, to answer the above question about survival rates, I started by creating a query to see how often the white queen's rook survives:

:forany Rook R
(:position :initial $Rook[a1])
(:position :terminal $Rook[a-h1-8])

That's it. The first line creates a Rook piece designator; the second and third lines specify positions that have to exist in a game for the game to match the query. Thus the query will match any game where a rook is on the a1 square in the initial game position, and that same rook is somewhere on the board in the terminal game position.

This query took about 45 minutes to run through a database of about 2.5 million games, and found that this rook survived in about 1.4 million of them. I just had this repeat for all pieces and pawns to generate the final answer.

So, I can advise that if you're ever involved in a Harry Potter-style human chess game, you should volunteer to be one of the wing pawns. Don't allow yourself to play as a knight, whatever you do.

Tuesday, April 28, 2009

Blitz Tactics

Here are a few positions from recent blitz games. The solutions are in the comments.

Position #1. Black to move. Both knights are threatened; can Black play dxc3?



Position #2. White to move.



Position #3. White to move.



Position #4. Black to move.



Finally, from earlier in the same game. Black to move; what is his best?

Sunday, March 1, 2009

Zugzwang

There was an interesting position in a recent game of mine. I'm playing black.

1.e4 c5 2.Nf3 Nc6 3.Bb5 e6 4.O-O Nge7 5.c3 a6 6.Ba4 b5 7.Bc2 Bb7 8.Re1 Rc8 9.a4 Ng6 10.axb5 axb5 11.Na3 b4?!

11...Ra8 is probably better.

12.Nb5 Be7 13.e5 O-O 14.d4 Qb6 15.Bd3 c4!? 16.Bxc4 Nxd4 17.Qxd4 Qxd4 18.cxd4 Rxc4 19.Bg5 Bxf3 20.Bxe7 Nxe7 21.gxf3 Nf5?

21...Rc2

22.Rec1 Rxc1 23.Rxc1 g5 24.Rc4 Nh4

24...Rb8!

25.Rxb4 Nxf3+ 26.Kg2 Nh4+ 27.Kg3 Nf5+ 28.Kg4 f6 29.Rc4 fxe5 30.dxe5 Rb8 31.Rc5 h6 32.b3 Kg7 33.Kh5 Kh7


This is the position, although most of what I'll say about it applies to the position a few moves later, after 35...Kg6 as well.

When I reached this position, I thought it was simply fairly equal. I don't mean a dead draw, since there are still some things to play with: White has a passed pawn, but his pawns are a bit split up; Black has a backwards d-pawn, and a nice knight on f5. However, looking at the position a bit more closely, White has a problem. He has no moves.

Let's go through the possibilities. White's knight can't move without dropping the b-pawn. White's rook can't move without dropping the knight. White does have some pawn moves, but not many, and none that really change the situation. b4 doesn't do much, and actually introduces a tactic once the king goes back to g4; f3 does nothing; h3 does nothing (except block a square the king might need). The king can move back to g4, but that allows the black king into g6, when White still has the same problems, and the added problem of Black pushing the kingside pawns.

Black, on the other hand, has as many waiting moves as needed, just by moving the king between g7 and h7. As a simple variation, if White tries to delay, Black can just wait: 34.f3 Kg7 35.b4 Kh7 36.h3 Kg7 and White is stuck, and probably has to throw away the h-pawn with 37.h4 Nxh4 38.f4 Nf3.

In the game, White retreated the king before using up all the pawn moves, and I was able to press forward for a win.

34.f3 Kg7 35.Kg4 Kg6

This is where the tactic against b4 appears. 36.b4 Nd4! and Black wins the b-pawn after 37.Nxd4 Rxb4, pinning the knight.

36.Kh3 h5 37.Kg2 Ra8 38.Rc7 Ra2+ 39.Kg1 Nh4 40.Rc3 Kh5 41.Re3 Kf4 42.Re4+ Kxf3 43.Re1 Kf4 44.Nd4 Rb2 45.Re2 Rb1+ 46.Kf2 Rh1 47.b4 Rxh2+ 48.Ke1 Rxe2+ 49.Kxe2 Kxe5 50.b5 Nf5 51.Nf3+ Kd6 52.Nxg5 Kc5 53.Kf3 Kxb5 54.Ke4 Kc4 55.Ke5 Kc3 56.Kf6 Ke3 57.Ke5 h4 0-1

Friday, February 20, 2009

Another Game

Here is another game, with some notes. This was a really interesting game, and I think I mostly played well.

1.e4 e6 2.d3 d5 3.Nd2 Nf6 4.Ngf3 c5 5.g3 Nc6 6.Bg2 Be7 7.O-O

This is a normal position in the King's Indian Attack against the French. Black commonly plays 7...b6 or 7...O-O here. However, my opponent played:

7...b5

Black often plays b5 at some point against the KIA; a common continuation is 7...O-O 8.Re1 b5. I'm not sure Black gains anything by playing this right away. In the game, he ends up castling soon enough, and for the next few moves there are some issues with the fact that he's opened the long diagonal.

8.exd5 exd5 9.c4 bxc4 10.dxc4 O-O

Here Black would consider 10...d4, if not for the fact that 11.Nxd4 is possible. Instead, Black takes a couple moves to clean things up, but ends up with some slightly weak queenside pawns.

During the game I thought that d4 was just impossible, but the computer doesn't think it's too bad. It gives variations like 10...d4 11.Nxd4 Nxd4 12.Bxa8 Bg4 13.Qa4+ Kf8 14.Qxa7 Ne2+ 15. Kh1 Nxc1 16.Raxc1 Qxd2. White has a rook and two pawns for a bishop and knight.

11.b3 Rb8 12.cxd5 Nxd5 13.Bb2 Bf6 14.Bxf6 Nxf6 15.Qc2

The opening is finishing up, and I think White has a good position. There is some pressure on the c5 pawn, and Black still needs to develop a bit.

15...Qa5 16.Ne4 Nxe4 17.Qxe4 Bb7

Black's king is looking a bit lonely.

18.Ng5 g6 19.Qh4 h5 20.Ne4 Nd4?!


This allows me to win the exchange, with a kind of a serial fork. Nf6 will fork the king and the d7 square, where it can fork the two rooks. 20...Ne5 instead would cover d7 and prevent this.

21.Nf6+ Kg7 22.Nd7 Bxg2 23.Kxg2 Qa6 24.Nxf8 Kxf8

White is up the exchange, but I found it quite hard to make further progress.

25.Qe4 Re8 26.Qd5 Ne6 27.Rfd1 Qc8 28.Qd7 Qa8+ 29.Qd5 Qc8 30.Rac1 a5 31.Rc4 Kg8 32.Rd3 Qa6 33.Rdc3 Rd8 34.Qe5 Qb7+ 35.Qe4 Qb6 36.Rd3 Nd4 37.Qe7 Rd5 38.Qe8+ Kg7 39.Qe4 Rf5

Fifteen moves since winning the exchange, and not a lot has changed. Maybe there is a way to continue to improve the position, but instead I played:

40.Rdxd4?!

Now I have a pawn-up rook ending. Even if this turns out to be objectively a good move, my thought process producing it was not so good. After going up the exchange, I was a bit frustrated at not being able to force more progress. Also, I've noticed in some of my games that I can be too eager for clarity in the position.

40...cxd4 41.Qxd4+ Qxd4 42.Rxd4 g5


Here is the rook ending. Another issue with my going into this is that I didn't make myself calculate it as deeply as I should have. Originally I thought I had a straightforward plan of trading the a pawns and putting my rook behind my remaining passed b-pawn. This ends up letting his king get quite active, with something like: 43.Rd2 Kf6 44.a3 Rc5 45.b4 axb4 46.axb4 Rb5 47.Rb2 Ke5 48.Kf3 Kd4. Instead, I decided to bring my king into the game.

43.Kf1 Re5 44.Rd2 g4 45.Re2 Rc5 46.Ke1 Kf6 47.Kd2 Kf5 48.Kd3 Rc1 49.Rc2!

My king is out, and will be able to get to his a-pawn. Black can win my h-pawn, and it looks like there may be some threats there to win some more pawns, or force one through, but I think that White can cover everything.

49...Rd1+ 50.Kc4 Rh1

Another approach for Black is to try to defend the a-pawn. 50...Ke6 51.Kb5 Rd5+ 52.Kb6 and Black is tied up. The rook can't leave the defense of the pawn, and White should be able to continue by trading the a-pawns and pushing the remaining passed pawn.

51.Kb5 Rxh2 52.Kxa5 h4 53.gxh4 g3

This would be very strong, due to the unprotected white rook, if not for the check White has available. As it is, White is winning, though not with too much room to spare.

54.Rc5+ Kg4 55.Rc4+ Kf3 56.fxg3 Rxa2+ 57.Ra4 Rh2 58.b4

58.Rf4+! is given by the computer, when 58...Kxg3 59.Rxf7 is a tablebase win.

58...Kxg3 59.b5 f5 60.b6 Rb2 61.Rb4 Ra2+ 62.Kb5 Ra8 63.b7 Rb8 64.Ka6 f4 65.Ka7 1-0

Black resigned, although even here, a little care is still required. After 65...Rxb7 White has to capture with the king, as 66.Rxb7? Kxh4 is a draw.

Friday, February 6, 2009

Tactic #2

Here's a fairly complicated tactic, from computer analysis of a recent game of mine. Black to move.


Solution in the comments.

Monday, January 12, 2009

Tactic

Here is a tactic, from another Facebook game. Black to move. (The board is shown from White's perspective; White pawns are moving up the board.)


I'll post the solution later in the comments.

Sunday, January 11, 2009

First Post!

For my first real post, here's a chess game from Facebook, with some light comments.

Dixon, G - Eisler, R

1.Nf3 d5 2.d4 Nf6 3.c4 dxc4 4.Nc3 a6 5.e4 b5 6.Be2 c6 7.O-O Bb7 8.Bg5 Be7 9.Qc2 Nbd7 10.Rad1 O-O 11.d5 exd5 12.exd5 Re8 13.Rfe1 h6 14.Bh4

So far I think I have done well through the opening, but now I miscalculate fairly badly to end up in a worse position.

14...Nxd5?! 15.Nxd5 Bxh4 16.Nxh4 Qxh4 17.Nxc7 Qg5 18.g3 Nc5?

This had the idea of going to d3 with the knight, but it doesn't really work. 18...Qc5 is better, and the computer found some interesting ideas with 18...Ne5. For example, 18...Ne5 19.Nxe8 Rxe8 20.f4 Qf6 21.fxe5 Qb6+ 22.Kf1 Qc6 23.Kf2 Qb6+ 24.Kf1 is a draw.

19.Nxe8 Rxe8 20.Bxc4! Rxe1+ 21.Rxe1 Be4 22.Bxf7+

This creates a queen ending with White up a pawn; 22.Rxe4 Nxe4 23.Qxe4 bxc4 24.Qxc4 is a similar ending, with a slightly different pawn structure. This may have been a better option for White, since his extra pawn is on the queenside in this case. He may have been able to create a passed pawn there, which can be quite strong in a queen ending.

22...Kxf7 23.Rxe4 Nxe4 24.Qxe4 Qc1+ 25.Kg2 Qxb2 26.Qb7+ Kf8 27.Qxa6 Qe5 28.Qa8+ Ke7 29.h4 Kf6 30.Qd8+ Kf7 31.Qd2 Qe4+ 32.f3 Qe5 33.Qf4+


White is trying to trade down into a pawn-up king and pawn endgame, but this particular queen trade breaks up his pawn structure and causes him some big problems.

33...Qxf4 34.gxf4 h5!

White won't be able to protect his f4 pawn. Black's king will get to f5, and White will not be able to stay on e3 or g3, since Black has spare pawn moves available. So, White tries taking the b-pawn and creating a pawn race.

35.Kf2 Kf6 36.Ke3 Kf5 37.Kd4 Kxf4 38.Kc5 g5! 39.hxg5 Kxg5 40.Kxb5 h4 41.a4 h3 0-1

Black will win the pawn race.