Suppose one wants to find:

  1. A list of games where White/Black gave each other check more than 10 times.
  1. A list of games where there were Black and White gave each other check in consecutive steps
  1. A list of games where the king crossed the middle rank and still won

And so on.

Is there a software I can input these generic statements and find a list of games which have these conditions satisfied

  • 1
    in almost any game that leads to the endgame you will find a king that crossed the middle of the board. In fact, I think that most games will lead to that... (assuming that it isn’t bullet, cuz there the game usually ends with a timeout)
    – fartgeek
    Commented Dec 9, 2020 at 2:37

2 Answers 2


As Brian mentioned, CQL (Chess Query Language) is the most capable tool for the job. The current version of CQL at the time of this writing is 6.0.5 and the current website is http://www.gadycosteff.com/cql/. The site provides lots of examples and comprehensive documentation. Below are queries that will find games matching your three examples to give you an idea of what CQL looks like in practice.

More than 10 checks in a game

initial sort "total checks" find all check > 10

This will find all games where check was delivered (by both sides) more than 10 times in a game. The matching games will be sorted in descending order by the number of checks delivered (the first game in the output will be the one with the most checks) and will contain a start-of-game comment with the number of checks that appeared in the game. For example, here is a game from lichess.org that was found using this query with 81 checks. By default, the query will also add a comment to each move that matching the find filter (i.e. each move that is a check). The find filter is described in detail here.

Consecutive checks

The CQL website provides many examples. The consecutive-checks.cql example finds games with 5 or more consecutive checks. The query provided there is:

cql(input heijden.pgn)
sort "number of consecutive checks"
  line 5 100 nestban
    --> check+

The sort filter will again cause the games to be sorted by the number of most consecutive checks. A comment will be inserted for each checking move in the longest line of checks for each matching game. Documentation for the line filter used in this query is found here.

Winning side has King crossing middle rank

The following query will find all decisive games where the winning side's King moved to the opponent's side of the board at some point. The first time the King crossed into enemy territory will be commented. The query is written from the perspective of White (the filter result 1-0 means White won and Ka-h5-8 matches a position where the White king is present on ranks 5-8) but matches for both White and Black using the flipcolor query (the flipcolor query is described here).

flipcolor { result 1-0 find Ka-h5-8 }
  • 1
    Wow!!Thanks a ton !! Its gonna be a huge blessing to witness and experience the power of this epic software!
    – Rahul Shah
    Commented Dec 11, 2020 at 16:16

Is there a software I can input these generic statements and find a list of games which have these conditions satisfied

Of course not! Natural language interrogation of databases has a long way to go before it reaches this stage. Engines require queries to be formatted in some suitable way.

What there is is something called Chess Query Language (CQL). In the same way that SQL (Structured Query Language) allows you to interrogate a relational database to extract useful information, so CQL allows you to interrogate the chess equivalent, a PGN file containing chess games.

The original website supporting CQL died but was preserved by the Archive project and is available here. The associated old version of the software can be downloaded here.

The latest version is available here.

As the introduction from the old version makes clear CQL is a very powerful tool for interrogating chess databases:

Chess Query Language (CQL) was designed to allow researchers, authors, and players to search for games, problems, and studies that match specific themes. You specify the theme you are looking for, and the database to look for them, in CQL. Then you run this CQL file using cql.exe . This creates a new PGN file that has all the games matching your theme.

CQL specifies a small but powerful set of primitives to define chess themes. CQL can find much more complex themes than any other chess program. Users have searched for themes like stalemates with multiple pins; games in which the same position recurs but with the winning side missing just one piece; Nowotny and Grimshaw themes, games with some number of captures on a single square, games with a certain number of black and white passed pawns, and many more.

  • thanks for the old link too. I got the chance to see more archived pages and found out that earlier they also made a GUI friendly version too.
    – Rahul Shah
    Commented Dec 11, 2020 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.