clearance-delayed.cql

// Download clearance-delayed.cql
// PGN output when run on sample.pgn

/* Delayed clearance theme.
A white vacating piece (V) moves to an empty square.
Later, V is captured. A white exploiting piece E moves
so as to cross the square V was on originally.

There can be any number of moves by pieces other than V and E
intervening above.

The result is sorted by the number of moves by pieces other than
V and E. 
*/

cql(input hhdbvi.pgn)
V    // the Vacating piece
 EV  // the Exploiting piece
   sort "theme length" 
     capture VE max pathcountunfocused5
      V  ///"vacater moves"
      ×V   ///"vacater captured"
      E topathstart:Vfrom
            ///"exploiter moves, crossing the original location of V" pathstart:V