CQL by example

This web page will discuss in some detail the examples listed in the sidebar under the heading Examples. They should be read in order.

Setting up

Unfortunately, CQL does not have a one-click installation. In fact, installing and getting set up to use CQL is probably the trickiest part of CQL for many chess players.
  1. Download and install CQL
  2. If you on Windows and using VisualCQL, install that.
  3. Make sure that the file sample database is in the directory where you are going to run the examples from. Or, if you want to run the examples on, say, the HHdbVI endgame study database, make sure that the hhdbvi.pgn file is in that directory.

All of the examples are in the distributed versio of cql in the examples/ subdirectory of the main distribution. You can also access the examples online. However, if you access the examples online, you will have to download the ones you use individually - the CQL program cannot read .cql files from a URL but requires the name of a local file.

Running the examples

The examples themselves by default use the hhdbvi.pgn database to search for games from. This what the input hhdbvi.pgn means at the start of the examples.

But if you do not have this database, you should use sample.pgn instead. There are two ways to use sample.pgn:

  • change hhdbvi.pgn to sample.pgn in the examples you want to run, or
  • run CQL with the -i sample.pgn option:
    cql -i sample.pgn examples/turton.cql
    This will generate a file in the current directory named turton-out.pgn which you view with any PGN viewer, like ChessBase or HiArcs or the built-in chess viewer in VisualCQL.

Example explanations

The explanations of the examples discussed:
CQL fileThemefilters discussed
QQqq QQ v. qq piece designators

==
loneknightmate mate with knight mate
greekgiftGreek gift ―― ×
smotheredmate smothered mate not btm mate
mirrormate mirror mate filter values
rookleapcorners visits 4 corners in 3 moves square variables
focus
staircase-sort-annotated queen staircase sort up right piecepath
regular expressions in
likeinterference interference theme piece variables

chaining
turton Turton theme piece variables
from
chaining
dingstheme Ding's theme modelmate King's field