(defquery king-jumps [from] [int? => [... {landing int? captures int?}]] {find [?landing ?captures] where [[?game ] [?game turn ?color] [?game next ?next] [?piece color ?color] [?piece rank "king"] [?piece square ?from] [?from number from] [?from row ?r0] [?from col ?c0] [?victim1 color ?next] [?victim1 square ?over] [?over row ?mr1] [?over col ?mc1] [?first ] [?first row ?r1] [?first col ?c1] (= (math/abs (- ?mr1 ?r0)) 1) (= (math/abs (- ?mc1 ?c0)) 1) (= (- ?r1 ?mr1) (- ?mr1 ?r0)) (= (- ?c1 ?mc1) (- ?mc1 ?c0)) [?over number ?captures] [?first number ?landing]] order-by [?landing]}) (defmutation double-jump [from via to] [int? int? int? => map?] {query {find [?game ?piece ?from ?first ?last ?victim1 ?victim2 ?over ?over2 ?next ?color] where [[?game ] [?game turn ?color] [?game next ?next] [?piece color ?color] [?piece rank "king"] [?piece square ?from] [?from number from] [?from row ?r0] [?from col ?c0] [?victim1 color ?next] [?victim1 square ?over] [?over row ?mr1] [?over col ?mc1] [?first ] [?first row ?r1] [?first col ?c1] (= (math/abs (- ?mr1 ?r0)) 1) (= (math/abs (- ?mc1 ?c0)) 1) (= (- ?r1 ?mr1) (- ?mr1 ?r0)) (= (- ?c1 ?mc1) (- ?mc1 ?c0)) [?victim2 color ?next] [?victim2 square ?over2] [?over2 row ?mr2] [?over2 col ?mc2] [?last ] [?last row ?r2] [?last col ?c2] (= (math/abs (- ?mr2 ?r1)) 1) (= (math/abs (- ?mc2 ?c1)) 1) (= (- ?r2 ?mr2) (- ?mr2 ?r1)) (= (- ?c2 ?mc2) (- ?mc2 ?c1)) [?first number via] [?last number to] (!= ?victim1 ?victim2)]} patch {?piece {square #link ?last} ?victim1 {square null} ?victim2 {square null} ?from {} ?over {} ?over2 {} ?last {} ?game {turn ?next next ?color}}})