There are three kinds of
→filter: the binary form, the ternary form, and the n-ary form for
The ASCII form of
The binary form of the → filter denotes an attack by a piece on a square:
♖→d4 //♖ attacks d4
The ternary form deals with pins and simple interferences:
♖→♞→♚ //♞ pinned by ♖ ♕→♙→h8 //♙ is between ♕ and h8
The n-ary form, of which the ternary form is a special case, is less commonly used:
♕→♙→♙→h8means that there are two distinct white pawns preventing an attack of ♕ on
Each of these forms are discussed in more detail below.
yare set filters, then
x→ymatches the current position if a piece on
xattacks a piece on
A piece u is said to attack a square v if a king of different color than u would be in check from u if that king was on v.
For example, suppose that the current position is the chess start position. The following filters are all true:
d1→e2 ♕→e2 e2→d3 not ♕→d4 ♘g1→f3
Note that the check filter can be written in terms of →:
check ≡ △→♚ or ▲→♔ ≡ ⬓△→♚
Now suppose we remove all the pawns from the start position. Then the following filters are all true:
♕→d8 ♕→♛ ♗→g5
Value returned by →The value of
X→Yis the set of squares in
Ythat attack a square in
This is equivalent to
For example, suppose the current position is the start position in chess. Then
♙→f3 ≡ [g2,e2]and
△→f3 ≡ [g2,e2,g1]
←, binary caseThe filter
x←yis true exactly when
However, the value of
y←xis the set of squares in y that are attacked by a piece in x.
For example, if the current position is the start position, then
♙←♘ ≡ [e2,d2]
ternary →Suppose that
zare set filters each representing a single square in the current position. We will identify the set filter with the set of squares it represents as usual.
One can think of
x→y→zas being a sort of generalized pin. In fact, this matches a position exactly when
pin from x through y to zmatches the position.
The ternary → filter
matches a position if each of the following four conditions is true:
- There is a sliding piece on x which attacks y
- y is between x and z
- Any squares between x and y are empty
- Any squares between y and z are empty
The above discussion was limited to the case where
z denoted a single square.
In general there can be multiple squares denoted by each of these set filters. In the case, we say that
x→y→zmatches a position if there are squares X, Y, Z, in x, y, z respectively such that
Examples of ternary →
♖→▲→♚matches positions where a black piece is pinned by a white rook.
♕→△→♚matches positions where there is a single white piece between a ♕ and the ♚.
If the current position is the start position, then following are true:
The value of the ternary →The value of
x→y→zis the set of squares
Xin x such that
This can be written
ternary → versus nested binary →You can use parentheses to prevent ternary evaluation of →. For example,
♝→♖→♔is true if a white rook is pinned by a black bishop. But
♝→(♖→♔)is true if a black bishop is attacking a white rook which is itself attacking the white king.
n-ary →Chains with more than two → symbols are much rarer but are treated similarly (this section can be safely skipped unless necessary). More formally, consider a chain
x1→x2→x3→...→xnfor some integer n≥4.
First, suppose each
xi has only one square.
The the chain matches a position in that case that, if empty squares were placed on each square
xn. But if any one of those squares were occupied, then
x1would not attack
As before, in the general case where each
xi could hold more than one square, we say that
x1→x2→x3→...→xnif there are squares
X1 in x1, X2 in x2, ... , Xn in xnsuch that
X1→X2→X3→...→XnFor example, suppose the current position is the chess starting position. Then the following filters are all true:
♕→d2→d7→d8 h1→h2→h4→h7→h8 h1→g1→f1→e1However:
not ♕→d2→d7→e7 not h1→h3→h7→h8
The value returned by → chainsThe value of a filter returned by a chain
x1→x2→x3→...→xnis the set of squares
X in x1such that
For example, the set of white pieces pinning some black piece is:
z←y←zmatches a position if and only if
x→y→zmatches the position.
The value returned by
z←y←zis the set of squares Z in z such that
Z←y←xmatches the position.
x1→x2→x3→...→xnmatches a position if and only if
xn←xn-1←...←x1matches the position.
As before, the value of
xn←xn-1←...←x1is the set of X in xn such that
ExamplesThere are many examples of simple → denoting attacks in the examples, for example, in turton.cql.
There are also a number of examples of length-3 → chains
One use is to detect moves crossing a particular square.
⊢ ―― from→d4→tomatches positions where the next move is a sliding move that crosses the square
d4. That is because,
fromhere is the departing square and
tois the arriving square of the move matching