An html version of differentsquares.cql

; differentsquares.cql can be downloaded here.
; Find games in which some knight has visited at least twenty different squares.
; This works by counting positions such that the knight will not again visit
; the square on which it currently sits. Squares visited by a pawn that promotes to 
; a knight are not included in the count.
;


(match :pgn heijden.pgn
       :output out.pgn
       :forany knight [Nn] ; loop for each possible knight
       (position
	:tagmatch knight [Nn]d4 ; Tagged piece is actually a knight on d4, not a pawn
	:and         ; make sure this is the last such occurrence
	((position :not :gappedsequence 
		   ((position) (position $knight[d4]))))
	:shift       ; now repeat, with other squares instead of d4
	:matchcount 20 65 ; match when at least 20 distinct squares found
	:noannotate  ; do not print "MATCH" when a match is found
	))