An html version of kozirev2.cql

; kozirev2.cql can be downloaded here.
; This CQL file illustrates another way to search for echoes (shifted or flipped) 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 to non-pawn pieces
; Find games in which there are two 
; positions P1 and P2, such that P2 is reached by a flip or transform from P1
; with the same side to move, such that P1 is a stalemate, 
; at most 1 non-empty square is the same
; among the non-pawn pieces of P1 and P2


(match
; :pgn kozirev.pgn
 :pgn heijden.pgn
 :output out.pgn
 (position
  :stalemate
  :markall	
  :piececount [KkRrQqNnBb] 4 100	; Make sure the position is reasonably interesting
  [KkRrQqNnBb]                          ; the pattern
  :relation (:shift			; allow shifts
	     :pattern                   ; ignore pawns
	     :samesidetomove		; same side to move in P1 and P2
	     :originalsamecount 0 1	; P1 and P2 cannot coincide in more than 2 nonempty squares
	     :flip)			; allow flips
  :variations				; search in variations

  )
 )