I would like to generalise What are examples of grandmaster games where both Black and White castle opposite sides and the queenside players loses?

Question: Is there a way I can search this up myself?

Like perhaps in the chessgames, chesstempo, lichess or chessdotcom database or perhaps youtube via chessvision (You can select the theme 'opposite site castling'), I plug in parameters like

  1. Title/rating parameter: both (or at least 1 of the) players, say, Alice and Bob, obtained the title of GM or have a certain rating (either at the time of the game or later on in life)

  2. Some middlegame parameter: Alice castled queenside while Bob castled kingside

  3. Winning parameter: Alice lost.

  4. Date parameter: games from date t to date t+X

  5. Perhaps also some endgame parameter: Like they reached a rook endgame or a bishop vs knight endgame.

Ideal answer: I'm asking if there's a readily available way to do this. Like someone's already made this kind of thing where we can plug in these themes/parameters.

Next best thing/s: Well I suppose there's manually downloading perhaps some grandmaster database and then we write script in python or something that searches O-O vs O-O-O and then use the same way lichess or chessvision identifies 'rook endgame' or 'bishop vs knight endgame'. In this case, please give whatever suggestions you can.

1 Answer 1


Question: Is there a way I can search this up myself?

Yes. There is a tool called CQL (Chess Query Language) which allows you to search a PGN file database of games for games that match some set of criteria in the same way that SQL allows you to search a relational database for records which match a set of criteria.

The CQL User Guide describes what CQL does, how to download and install CQL, how to use it and gives example CQL queries to get you started.

Tim Krabbe also has a useful page on his website describing how he has used the tool to find interesting positions and games.

  • 3
    Just a further note. Of the "Big Two" commercial databases, Chess Assistant supports CQL directly while ChessBase, as of v15, does not (though if you hit the "Advanced" button under "Search Games" you get to set search parameters that should fit your needs).
    – Arlen
    Commented Dec 13, 2021 at 23:03

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.