pin
Thepin
filter matches a position if the position has any pins that match the pin
filter.
Any pin has three distinguished features:
- The pinning piece. This must be a sliding piece (rook, bishop or queen).
- The pinned piece. This must be a piece of a different color than the color of the pinning piece.
- The to square. This can be any square, but if it is nonempty it must hold a piece of the same color as that of the pinned piece.
The pin
filter has three optional parameters: from
, through
, and to
. Each parameter is specified by its associated keyword followed by a set filter:
pin pin through ♖ pin from ♕ pin to ♛ pin from ♕ through ♜ to ♚
Each parameter has specific defaults according to the following table:
parameter | default | corresponding piece |
---|---|---|
from | ◭ | pinning piece |
through | ◭ | pinned piece |
to | ♔♚ | to square |
Thus,
pinis the same as
pin through ◭ from ◭ to ♔♚
Similarly,
pin from ♕
is the same as
pin from ♕ through ◭ to ♔♚
A pin matches a pin filter if
- The pinning piece of the pin lies within the set represented by the
from
parameter of thepin
filter - The the pinned piece of the pin lies within the set represented by the
through
parameter of thepin
filter - The to square of the pin lies within the set represented by the
to
parameter of thepin
filter.
Thus,
pinmatches a position where some piece is pinned against its own king.
pin from ♕
matches a position in which a white queen pins a black piece against the black king.
pin through amatches a position in which a black piece is pinned against its own king.
The set represented by a pin filter
Apin
filter is a set filter. The squares that it represents depends on which parameter is the first parameter that follows the keyword pin
(this is similar to how the move filter determines which set it represents).
- If the first parameter is
from
then thepin
filter represents the squares of the pinning pieces of the pins that match thepin
filter. - If the first parameter is
to
then thepin
filter represents the to squares of the pins that match thepin
filter. - If the first parameter is
through
then thepin
filter represents the pinned pieces of the pins that match thepin
filter.
The first parameter following a pin
filter without any explicitly given parameters is taken to be through
.
Therefore,
pinrepresents the set of squares on which there are pinned pieces.
pin>4matches positions with more than 4 pins (of a piece against its own king).
To find positions with more than 2 pinned white pieces, use
pin through △>2
Examples
As discussed above,
pin through △
is the set of squares on which there is a white piece pinned by black against the white king. Thus,
pin through △≥3is true in a position if there are at least 3 pinned white pieces (due to the conversion of set operands to their cardinality). Likewise,
comment ("pinned pieces: " pin through △)
will output a comment of the squares of the pinned pieces.
These concepts are combined to find games with the most pins in the file pins.cql, which sorts the output by the number of pins. Note the key filters:
sort "number of pinned pieces"{ comment ("Pinned pieces: " pin through △) pin through △≥3
This CQL finds the following stalemate from a 2014 Melnichenko study:
(found from CQL file: pins.cql)
Note how the location of the pinned pieces is output as a comment to Black's 7...R:h6
. This is because of the set value of the pin
filter here.
Also, note that only the one comment is printed for the position with the maximum number of pins, even though earlier positions in the study had 3 pins and could have matched. This is because of smart comments, which only print the maximal comments in a sort.