Chess - Play & Learn


FREE - In Google Play

FREE - in Win Phone Store


Combination Searching (CQL)

Apr 28, 2014, 6:32 PM 4

A Combination Puzzle

Combinations give Chess its beauty in my opinion. Above you will see a combination puzzle from one of my own games. It combines a tactical motif and a classical mating pattern for a mate in four moves for Black. See if you can discover it on your own or skip ahead to the rest of the post if you prefer.

  • "What is a combination? A combination is a blend of ideas – pins, forks, discovered checks, double attacks – which endow the pieces with magical power. It is a series of staggering blows before the knockout. It is the climatic scene in the play appearing on the board. It is the touch of enchantment that gives life to inanimate pieces. It is all this and more – A combination is the heart of chess (Chernev 1960)."

The Combination Explained (Spoilers)

I combined the Attraction Motif with the classical Lolli's Mate pattern to win this game. White actually resigned after Rh1+, but this ending intrigued me enough to wonder if I could find other examples of this combination in Megabase. Using Chess Query Language (CQL), I was able to find 8 such games where this combination was played out to checkmate. I will post about these games in the near future.

The Script

Explanation of Keywords and Tags Used

The first two tags are standard 
:pgn is the source of the games I searched
:output is the pgn CQL created to hold the results.

There is only one position to match in this script which consists of a gapped sequence of three sub positions. The three sub positions we are searching for can occur at any point in the game but all must be found and they must be in this order for the game to match.

:check and :wtm together ask CQL to look for a position where the White King is in check. WTM stands for White To Move. I wrote this script from Black's perspective, as I played this combination as Black in my game.

:attackcount looks for instances of a specified piece type attacking another piece type for a certain number of times. This number can be a range.
:flip will allow us to find the positions mirrored to the other corners. We don't use :shift here because the mating pattern is dependent on being in the corner.
:flipcolor will allow us to find our gapped sequence from either color

Explanation of the Sub Positions

The :gappedsequence is the heart of the script, as such the logic behind the sub positions deserves its own section.

Sub Position #1 looks for the requisite pawn structure and that a Rook is giving check from the corner square to the opponent King which is somewhere on the board. 

I am assuming that if the next sub position is a match that the King in check is close enough to be forced to take the checking Rook in the corner, so I don't actually tell CQL a specific square for the King.

Sub Position #2 again looks for the requisite pawn structure and that the King is now in the corner and in check from a Queen somewhere on the board.

I don't actually care which square the Queen is giving check from as long as the next sub position is a match. If the next sub position is a match, I can safely assume that the winning side didn't blunder the Queen to give check in this sub position. This means I don't need to add more information to filter out those cases because the next sub position will filter out those games. Also, if the King is in the corner after the previous sub position, we can safely assume the Rook has been taken.

Sub Position #3 again looks for the requisite pawn structure and that the Queen is giving checkmate diagonally adjacent from the corner.

I believe I can safely assume that the King is adjacent to the corner square on g1 or h2 if position 2 was a match and we now have checkmate in this position with the winning side's Queen diagonally adjacent to the corner.

Summary of the Script

Using a gapped sequence, we look for a Rook sacrifice (#1), which then draws the opposing King to the corner where it is checked by the Queen (#2), which is then followed by a classic Lolli's Mate position (#3). I leave out as much information as I can to grab the widest range of games while still finding the combination sequence of a Rook sacrifice in the corner (Attraction Motif) and Lolli's Mate. Having written the script this way, I found 8 games with this tactical sequence and I will include these games in a future blog post about this combination.

Online Now