An html version of kozirev.cql

; kozirev.cql can be downloaded here.
; This CQL file illustrates how to search for echoes in which there is some "give"; that is, it is not a perfect echo.
; The motivation for this example was to search for studies similar to the beautiful 1995 study by Kozirev in which a stalemate configuration with 
; Kd1, Bd2, kd3, bd4 and Qe5 recurs rotated 90 degrees but without a pawn elsewhere on the board
;
; To do this we limit the search 
; Find games in which there are two 
; positions P1 and P2, such that P2 is reached by a flip or transform from P1 (except for a couple of pawns at most)
; with the same side to move, such that P1 is a stalemate, and such that 
; at least 3 squares differ between P1 and P2, and such that at most 2 non-empty squares are the same
; between P1 and P2


(match
 :pgn heijden.pgn
 :output out.pgn
 (position
  :stalemate
  :markall	
  :piececount [KkRrQqNnBb] 4 100	; Make sure the position is reasonably interesting
  :relation (:shift			; allow shifts
	     :missingpiececount [Pp] 0 2
	     :newpiececount [Pp] 0 2
	     :samesidetomove		; same side to move in P1 and P2
	     :originaldifferentcount 3 100 ; P1 and P2 must differ in at least three squares
	     :originalsamecount 0 2	; P1 and P2 cannot coincide in more than 2 nonempty squares
	     :flip)			; allow flips
  :variations				; search in variations

  )
 )