# attack

The`attack`

filter consists of the single word `attack`

followed by an optional range followed by two set filters enclosed in parentheses:
As a set filter, theattack-filter:= 'attack'opt-range'('set-filter1set-filter2')'set-filter1:=set-filterset-filter2:=set-filteropt-range:=range|empty

`attack`

filter is associated with the set of squares in the set associated with its second argument in a position. The filter is only a set filter if no *range*is present.

If a *range* is present then the `attack`

filter can be sorted and has the count of the number of attacks by pieces on squares in the set associated with its first argument to squares associated to its second argument.

We say a piece *x* on a particular square *attacks* a square *t* in a position if a King of the opposite color of *x* on the square *t* (possibly replacing a piece already on *t*) would be in check from *x*. In particular, a piece can attack a square even if the piece could not move to that square: for example, a pawn can attack an empty square; a piece can attack a square on which there is a piece of the same color; a pinned piece can attack a square moving to which would be illegal due to the pin.

## examples of the attack filter

Y. Bazlov1/2 prize

Chorus 70, 2008

`mate `

attack 1 (N k)

power 3 A

This finds studies where white mates with a single knight, as shown in the study above.

Some more examples:

attack (A k)will be true in a position in which Black is in check. The associated set will be empty if the black king is not in check, and will contain the single square where the black king is if black is in check.

attack 0 (A k)will be true in a position in which the black king is not in check. It is not a set. However,

not attack (A k)will also be true in a position in which the black king is not in check, but is a set: all squares other than the black king if black is in check, and all squares otherwise.

attack 2 (a K)will be true in a position in which the white king is in double check.

attack 0 (A (attack k _))will be true in a position in which no empty square in the black king's field is attacked by a white piece.

{attack (A .)} 40 64will be true when white is attacking at least 40 squares. Here, the range of

`40 64`

is not a range parameter of the attack filter. Rather, the attack filter here is forming a set, the set of all squares attacked by a white piece, and the range simply is counting that set (any set followed by a range counts the elements of that set). This number is quite different from
attack 40 64 (A .)which means the total number of attacks by any white piece to any square is between 40 and 64. Examples