persistent
Thepersistent
filter is used to indicate that a numeric variable is persistent. The persistent
filter consists of the word persistent
followed by
an assignent to a numeric variable:
persistent x = 3 persistent y += 1The variable must not have been used prior to the persistent assignment.
The persistent
filter indicates that its variable is persistent, which means that:
- the variable is initialized to 0 and
- the variable retains its value between games.
The values of all persistent variables are output to standard output after CQL has concluded processing all the games in the input PGN database.
Since version 6.0.2 of CQL, a persistent variable may also be declared without an assignment, e.g.:
persistent x x=20
Examples
Persistent variables are used in the persistent.cql example. That example matches no game, but when run on the Heijden database database, it produces output like this:NumberGames: 85619 NumberStalemates: 12879 NumberUnderpromotions: 10599 NumberRookPromotions: 2192 NumberBishopPromotions: 1686 NumberKnightPromotions: 6721 NumberQueenPromotions: 41436 NumberPromotions: 52035 NumberEnpassants: 631 NumberCastles: 229 NumberMates: 14399 NumberWins: 54786 NumberWhiteWins: 54786 NumberDraws: 30833 NumberBlackWins: 0 NumberPositions: 1549476