As a writer, I'm often asked about themes in my books. I know nothing about themes, I write stories. They do have themes (I hope, I believe) but what they are 'really about' is up to the reader. Ten readers, ten themes.
    I'm reminded of this by Chess Query Language, a wonderful new tool for chess researchers, almost a magic wand, that will look for almost anything definable in chess games and compositions.

Take this study that I found with it.

White to play and win
A. Botokanov
3rd Prize, Fizkultura Team Tourney 1992

After 1.Qe4 Bxe2+ 2.Kxe2 f3+ 3.Kf1 h2 White would like to play Ne4+ So: 4.Qe5+ Kh3 5.Qg3+ Kxg3 and he has the same position minus the Queen. That enables a triumphant solo of the Knight. 6.Ne4+ Kh3 7.Nf2+ Kg3 8.Rxg5 Rxg5 9.Ne4+ Kh3 10.Nxg5+ Kg3 11.Ne4+ Kh3 12.Nf2+ Kg3 13.Nh1+ Kh3 14.Kf2 e5 15.e4 g3+ 16.Kxf3 g2 17.Nf2 mate

What exactly do we see here? Stunning queen sacrifice, smothered mate, anti-promotion struggle, King switchbacks, Knight's carousel? That depends on the beholder, but I found this study (and a few hundred others) when I used CQL to hunt Harold van der Heijden's famous study database for the 'WCCT7' theme. In that theme, set for the 7th World Chess Composition Tournament, White actively or passively rids himself of a piece, returns to a position with only that piece missing, and wins. Here, 4.Qe5+ Kh3 5.Qg3+ Kxg3 repeats the position without the Qe4. That square was needed as an entrance for the Knight.
    With ChessBase, it is not possible to search for such abstract themes. But just one amazingly simple line in a .cql script defines the WCCT7-theme:

:relation (:missingpiececount A 1)

The :relation tag tells CQL to look for studies and games in which more or less identical positions occur - how identical is defined by other tags, in this case :missingpiececount. 'A' stands for 'any white piece', and '1' says that one such piece should be missing. When you run the script on a database, CQL extracts a sub-database in which all studies and games meet the given definition.
    In fact, it was precisely for this missing-piece theme that Chess Query Language was developed about a year ago, by the study composer Gady Costeff and Lewis Stiller, whose second great contribution to chess this is - the first was his 6-men tablebase-research in which he discovered, among others, the famous win in 255 moves with R+B vs. 2N.

Another aim of Chess Query Language was to be a tool for testing the originality of studies. It enabled me to finally discover whether a combination I once saw in a dream (see Dream combination) had ever happened in reality.

Black to play

1...Qh3+ 2.Kxh3 Nf4+ 3.Kg3 Nxe2+ and Nxc3 and wins.

Very simple, but could I have seen this before? With ChessBase, you can only search for fixed coordinates and their mirrors but with CQL, I found two studies which had anticipated my combination, the first in 1954.

White to play and win
P. Okonkowski
Schach, 1954

1.Rc6 Rxc6 and now my dream: 2.Qf5+ Kxf5 3.Nd4+ Ke5 4.Nxc6+ Kd5 5.Nxa5 and White wins.

CQL is also the answer to the old problem of Study Classification. The Van der Heijden database has no theme classification, among other things because assigning themes is, as in literature, a matter of personal taste - and newly created or defined themes would require the whole database to be classified again.
    It is much better to define an interpretation first, and only then to look for the studies and games that fit it. Take my beloved Unguarded Guard - a linepiece checks, and a piece interposes on an unguarded square. It happens in many games and studies, but it was never recognized as a theme in itself. It was impossible to define it in any broad sense with ChessBase, but a few amazingly simple CQL-lines find all Unguarded Guards in one sweep.

:movefrom [QRBNP]
:moveto .d4
:attackcount A Ad4 0

This says White is to play and is in check, and will move any piece but the King to the empty square d4, which he attacks zero times after that. The little :shift tag, which almost singlehandedly makes CQL so powerful, changes d4 into a token square - the specified events may take place on any square. Finally, :flipcolor makes sure examples with reversed colors are also found. A :moveto ?d4 tag could be added to limit the search to cases where the interposed piece is actually captured.
    Limiting my search further to interposing Queens, I found this Unguarded Guard that escaped my attention at the time.

White to play
Topalov - Judit Polgar
Novgorod 1996

43.Rc7 An unguarded guard is the justification of this sharp move. 43...Rb8 44.Rxf7+ Kg8 45.e6 Qxe3+ 46.Qxe3 Rb1+ 47.Qc1 Clearing e3 to prevent mate. Of course she had seen that, but perhaps not that after 47...Rxc1+ 48.Kf2, the ending is lost, e.g. 48...Rf1+ 49.Ke3 Rxf7 50.d7! In the game there followed 48...Rc6 49.Rd7 Bb5 50.Ke3 Rc2 51.Rc7 Re2+ 52.Kf4 Rf2+ 53.Kxe4 Re2+ 54.Kf5 Rf2+ 55.Ke5 Re2+ 56.Kf6 Rf2+ 57.Ke7 Re2 58.d7 Bxd7 59.Kxd7 Rd2+ 60.Ke8 and Black resigned.

Although it was developed to be used with the Van der Heijden database, which has 58801 studies, CQL can just as well be used with games, and with much larger databases. But as it needs (and creates) PGN-files, I had to convert my 1.9 million game-database to PGN. I held my breath, but in just over 20 minutes, my computer managed a 1.3 Gb file, which behaves tidily. Complicated CQL-searches in such a large database may take hours, but it pays to be stupid here, and search too broadly first. It only took 15 minutes to extract a 4000-game sub-database with at least one underpromotion, and searching that instead of the mainbase, will make any search for themes involving an underpromotion, almost 500 times faster.

White to play
Zurakhov - Koblentz
Tbilisi 1956

57.g8N Kb6 58.Kc4 Ne3+ 59.Kb3 Nd5 60.c4 Nc7 61.Nf6 Ne6 62.Ne4 Nc7 63.Nf2 Ne6 64.Nd3 Nd4+ 65.Kc3 Ne2+ 66.Kb4 Nd4 67.c5+ Ka6 68.Kc4 Nf5 69.Kd5 Kb7 70.Nb4 Ne3+ 71.Kd4 Nf5+ 72.Kc4 Ne3+ 73.Kb5 Kc7 74.a5 Nf5 75.Nd5+ Kb7 76.c6+ Ka7 77.c7 Kb7 78.a6+ Ka7 79.c8N+ Kb8 80.Kb6 and Black resigned.

This is one in only 5 games with two serious Knight-promotions. 57.g8N is the only winning move, and also a rare non-checking Knight-promotion. 79.c8N is not the only winning move, but in human terms: the best move.

As Costeff says, you have to be a little computer-savvy to use CQL - in fact, it's the most wonderful user-hostile program I've ever seen. The FAQ on Stiller's site starts with the question: Why is the manual so difficult to understand. (Answer: We're sorry about that! The manual is very terse.) It is. There is one line, about the :not tag, which every time I look at it, ties a knot in my brain.

If :not is specified, the position matches if and only if, were the :not not specified, the position would not match

(PS 5 February 2017: There is a new, really good manual now, which comes with a new version (#5) of CQL itself with several new options.)

But with a little perseverance, even a rookie user like me is not dependent anymore on what others liked and published. I can do something that was not possible before: probe primary sources - all the games and all the studies. Thank you, Chess Query Language, for showing me this Zwickmühle.

White to play and win
A. Kuznetsov
L'Italia Scacchistica 1974

1.Qe4 Bb4+ 2.Kd8 e1Q 3.Qa8+ Kxa8 4.Bd5+ Kb8 5.Rb7+ Ka8 6.Rxb5+ Ka7 7.Rb7+ Ka8 8.Rxb4+ Ka7 9.Rb7+ Ka8 10.Rb1+ Ka7 11. Rxe1 Ng1 12.Rb1 h1Q 13.Rb7+ Ka8 14.Rh7+ Kb8 15.Rxh1 f2 16.Rh7 f1Q 17.Rb7+ Ka8 18.Rb1+ Ka7 19.Rxf1 and White has captured three Queens with the Zwickmühle, and wins.

You can download Chess Query Language for free. It comes with a manual and several sample .cql scripts. It is a command line-program, but the Czech study composer Emil Vlasák offers VisualCQL, a little utility for a bit more comfort in a Windows environment.

© Tim Krabbé, 2004, 2005

Top of the page | Main chess page | Main page |