mirrormate.cql
The file mirrormate.cql matches positions with a mirror mate: the mated King is surrounded by 8 empty squares.mirrormate.cql line-by-line
The body of mirrormate.cql consists of a single ⬓ filter. This filter a single argument, which in this case is the compound filter:{btm mate □←♚==8}This compound filter is true only if each of its three constituent filters are true; together, these three filters describe a black mirror mate. The
btm
means black to move; mate
means black is in mate.
The key filter in the compound filter tests that the ♚ attacks 8 empty squares. Here, the filter
□←♚is true if the ♚ attacks some empty square (□ is the set of empty squares; ← means attacked by).
But this filter has a value.
The value of □←♚
is the set of empty squares attacked by the ♚.
To test that this set has 8 elements, we use ==
to compare it to 8
, just like we did for the piece designators in explain-QQqq.cql.
Thus, the compound filter in the body of the cql file matches any black mirrored mate.
The effect of ⬓
When ⬓
is placed in front of a filter, it matches positions that match either the original filter or the original filter with all its colors reversed. For instance, btm
would be changed to wtm
and a2
would be changed to a7
. Here, the compound filter with reversed colors is:
{wtm mate □←♔==8}This new compound filter matches a white mirror mate. Thus, the full CQL body now matches either a black mirror mate (the original compound filter) or a white mirror mate (the reverse color compound filter). That is, it matches a mirror mate.