Arithmetic operatorsNumeric filters can be added, multiplied, and compared using standard arithmetic operators:
gamenumber * movenumber + ply == 24The following are the allowed arithmetic operations on numeric filters:
matching the positioneach such comparison or arithmetic operator is its own filter. For example, the CQL expression
power A + power ais a
+filter whose two arguments are
power a. which can either match or not match the current position. Each such binary operator only matches the position if each of its two arguments also matches the position. (In addition,
%will not match when their right hand arguments are zero).
For example, the following expression is equal to the number of white pieces in the previous position:
If the current position is the initial position, then the filter does not match. Thus,
0<1 + parent:#A
will match only if the current position is not the initial position.
ExamplesArithmetic operators are used throughout the CQL examples. They are used extensively in averagedistance.cql, where we see computations like:
sqrt(drank*drank + dfile*dfile)
This computes the square root (as an integer) of the sum of the squares of
dfile, which is used to compute the distance between two squares.