Thursday, January 22, 2009

Chess Query Language

I picked up a copy of Aquarium for Rybka last week and have enjoyed playing with it and taking a while getting used to the interface. Chess Assistant users are no doubt family with Chess Query Language (CQL) as a way to search a database for specific chess positions and themes, but it was new to me. Aquarium offers this capability, although in a scaled down version compared to the Chess Assistant interface. If you're as unfamiliar with CQL as I was, I've included a few informative links at the end of this article. Here's an example of a simple inquiry that will find all games in a database where White delivers mate with a Knight:
(position :mate :attackcount N k 1 100 )
If you change the N to a B you find games where White mates with a Bishop. If you run that on a subset of the database with Knight mates you turn up positions where White mates with Knight and Bishop simultaneously. A few examples in the BDG: Peilen,M - Daniels,Erbie Boaz, AL match, 1986 BDG, Gunderam Defense 1.d4 d5 2.e4 dxe4 3.Nc3 Nf6 4.f3 exf3 5.Nxf3 Bf5 6.Ne5 c5? 7.g4 Bg6 8.Bb5+ Nbd7 9.dxc5 Qc7 10.Bf4 Rd8 11.Nxd7 Qxf4?? 12.Nxf6#
Meszaros,Guyla - Videki Kecskemet, Blitz, 1993 BDG Avoided, Lemberger CG 1.d4 d5 2.e4 dxe4 3.Nc3 e5 4.Nxe4 exd4 5.Bc4 Be7 6.Qe2 Nd7?! 7.Nf3 Ngf6? 8.Bxf7+ Kxf7 9.Neg5+ Kg6 [9...Kg8 10.Qe6+; 9...Kf8 10.Ne6+; 9...Ke8 10.Ne6 Bb4+ 11.c3] 10.Nh4+ Kh6 11.Nf7#
Diemer,EJ - Albrecht Isny, 1948 BDG Declined 1.d4 d5 2.e4 dxe4 3.Nc3 Nf6 4.f3 g6 5.fxe4 Bg7 6.Bc4 0-0 7.Nf3 e6 8.Bg5 h6 9.Bh4 g5 10.Bf2 Ng4 11.Bg1 Nc6 12.h4 e5 13.d5 Na5 14.Bd3 b6 15.hxg5 hxg5 16.Qd2 f6 17.0-0-0 Qe7 18.Qe2 Bd7 19.d6 cxd6 20.b4 Nc6 21.Bc4+ Be6 22.Nd5 Qd7 23.Nxg5 fxg5 24.Qxg4 Bxg4 25.Nf6#
Should you care to read more on Chess Query Language (CQL), here are a few references: