likeinterference.cql
The CQL file likeinterference.cql, which was a theme suggested by the endgame study composer Steffen Slumstrup Nielsen, seeks a position where the following three moves happen in order:- A white queen checks
- A black rook or bishop interposes
- A white rook or bishop interposes between the black interposing piece and the king, giving check
(found from CQL file: likeinterference.cql)S. Didukh 2013, before 7.Qc8+
In the next move, white checks with 7.♕c8+
. Then (2) the black rook interposes 7.♜f8
. Finally, (3), a white rook interposes 8.♖g8+
. This results in the position
(found from CQL file: likeinterference.cql)S.Didukh 2013, after 8.Rg8+
Note how all the thematic pieces in steps (1), (2), and (3) are aligned.
likeinterference.cql line by line
Since there are three thematic pieces in this theme, we assign start by assigning each piece a name:◭T1∊♕ ◭T2∊♜♝ ◭T3∊♖♗
CQL will execute the following filter (a ⊢
) with all possible assignments of a ♕
to the variable T1
; a ♜
or ♝
to T2
; and a ♖
or ♗
to T3
. If any of these assignments make the ⊢
filter true, the overall filter will be true and the current position will match.
The T1
and the other variables are piece variables. Each is tied to the identity of a particular piece. As the game progresses and as the current position changes, the square that such a variable represents will change as well. In the start position above, the value of
the T1
, the ♕
, will be b7
. But at the end of the sequence, the value of T1
will be c8
because that is where the ♕
is.
Now, we are only interested in what happens to these three pieces. Therefore, we focus using ◎
on these three:
⊢◎T1∪T2∪T3When the current position is the position before white's move 7 in the diagram above,
T1
will have value b7
; T2
will have value f7
and T3
will have value g7
. Their union will be the three squares [b7,f7,g7]
. The ◎
will only consider moves by the pieces originally on those three squares.
The next three line requires that T1
moves
T1――
After T1
moves, a position will be reached in which T1
must be attacking the ♚
:
T1→♚This is the same as saying that the white queen gives check, except that discovered check is not allowed.
Next, a black piece interposes, which also attacks its king
T2―― T2→♚Finally, the third thematic piece interposes, giving check
T3―― T3→♚
Finally, we make sure that after the move by T3
, the three thematic pieces and the ♚
are all lined up along the same ray, like in the second diagram above:
T1→T2→T3→♚
Substituting in the values of the variables, we get:
c8→f8→g8→h8When there is more than → like this, we say that the
→
symbols are chained. The first filter in the
chain, (T1
) attacks the last filter in the chain (♚
) but the
attack is interfered with by the other filters in the chain (T2
and T3
).
When we draw the arrow from T1
to the ♚
as in the above diagram, this arrow must cross each of the other filters in order.
It is important that we introduced the variable T1
with the ◭
symbol:
◭T1∊♕
If we had omitted the ◭
and just used T1∊♕
, then T1
would have been a set variable instead of a piece variable. Since the value of T1
in the initial position is b7
, that same value would be fixed, and also be used in the final position, which is not what we want. Then the final chain would be
b7→T2→T3→♚which would be false. For one thing,
b7
is empty.
summary
We've shown a snippet of code illustrating how to search for geometric patterns among pieces with piece variables and⊢◎
. As a warning, in practice such code can get a bit tricky because one has to be very clear on what the current position is in the middle of a complex ⊢
. We encourage users to contact us at CQL support rather than trying to code such ⊢
filters yourself.
Be that as it may, the final code version represents a concise and we hope fairly clear exposition of the theme.