currentmove

Any chess move represented in the PGN file of a game is determined uniquely by its tail , the position that making that move leads to.

Therefore, CQL conceptually identifies a position with the unique move leading up to that position. The move leading up to the currentposition is called the current move .

The current move is used conceptually in three ways:

  1. Some filters provide information about the current move, like to and from;
  2. the currentmove filter provides direct information about the current move; and
  3. some CQL programming techniques, as illustrated in the example file lacny.cql identify the current position with the current move.

We discuss the first two aspects of the current move below.

current move information filters

Certain filters query specific information about the current move, that is, the move that led to the current position. Such current move filters include from,to,enpassant,enpassantsquare,nullmove, primary, secondary, castle,o-o,o-o-o.

Each of these filters takes zero arguments:
filter namevalue
fromOrigin square(s) of moving piece(s) in current move, if any (see below for more information)
toDestination square of moving piece in current move (see below for more information)
enpassanttrue if current move was enpassant
enpassantsquareenpassant capture square of current move, if any. If the current move was not enpassant, then the empty set
nullmovecurrent move is a null move
primarycurrent move was a primary move, the first appearing move in the PGN file from the parent of the current position
secondaryprevious move, if any, was not a primary move
o-okingside castle
o-o-oqueenside castle
castlecastling

The currentmove filter

The currentmove filter can be used with the ―― filter to determine more general information about the current move. It has the syntax
    currentmove x
where x is any ―― filter.

The filter is true if the given ―― filter matches the current move. For example:

    currentmove ――
is true if the current move was by a white piece. In this case, the current position would be black to move (thus, btm would be true in the current position) but the current move would be of a white piece.

The currentmove filter is often used to determine if the current move was not of a particular type:

    not currentmove ――=

is true if the current move (the move leading up the current position) is not a promotion.

The reason currentmove is usually used with not is that ordinarily, for instance, a simple ――= at the parent position would check if the current move was a promotion.

    not currentmove ×(check)
means that the current move is not a capture of a black pawn by a white rook giving check.

from and to under castling

When the current move is castling, the value of the from filter is the orgin squares of each of the two moving pieces. For example, if the current move is white kingside castling, then from has the value [h1,e1].

Similarly, when the current move is castling, the value of the to filter is the destination squares of each of the two moving pieces.

However, when a from or to filter is evaluated in the scope of another ―― then the from or to filter respects the left and right restrictions of that ――. Contextual castling is discussed in more detail here.