current position
At any given time when playing through a game, CQL has a concept of the current position . The current position is the position that CQL is currently examining. Any filter is always evaluated with respect to the current position.
The current position is the value of the currentposition
filter:
x=currentposition
Thus, CQL successively sets the current position to each position it examines.
Start=currentposition
For example, consider the pgn file
1. e4 e5 2. Nf3 Nc6 3. Bb5 a6When run on this game, the current position will be set successively to the start position, the position after
1. e4
, and so on, for
seven positions in total (the position after each of the six moves,
plus the initial position).
If the filter is say
Bb5Then that filter will match exactly two of those seven positions, namely the positions following White's third move.
filters that modify the current position
Most filters are evaluated in a way that does not change the current position. However, some filters temporarily modify the current position in order evaluate their arguments with respect to some new current position. Once such a filter is finished, of course, the current position returns to what it was before the filter was evaluated.The filters that (temporarily) modify the current position are:
In using these, it is sometimes helpful to save the current position is sometimes saved in a temporary variable so that it can be referred to later during the evaluation. For example, in excelsior-return.cql, the current position is saved in a variable Start
so that it can be referred to later.
current position and variations
If thevariations
parameter is not set in the CQL header, the current position will always be set to a mainline position. Otherwise, the current position will also include positions in variation.
Examples
Thecurrentposition
filter is used in bristol-universal.cql, clearance-delayed.cql, excelsior-return.cql, parallelpaths-simple.cql, platzwechseln1.cql, platzwechseln2.cql, and queentriangulation.cql.