diff --git a/src/crosscram/samples/windowshade_rand.clj b/src/crosscram/samples/windowshade_rand.clj new file mode 100644 index 0000000..3df04e7 --- /dev/null +++ b/src/crosscram/samples/windowshade_rand.clj @@ -0,0 +1,15 @@ +(ns crosscram.samples.windowshade-rand + "Algorithm by J. Hunter Heinlen: Strongly prefer even-index rows +and weakly prefer even-index columns. If played by iteself, this bot will +fill in alternating rows (leaving space for itself) and then play the +remaining rows." + (:require [crosscram.board :as board])) + +(def separate (juxt filter remove)) + +(defn make-move [game] + (let [all (board/available-moves game) + [e_ o_] (separate (comp even? ffirst) all) + [ee eo] (separate #(even? (second (first %))) e_) + [oe oo] (separate #(even? (second (first %))) o_)] + (rand-nth (first (drop-while empty? [ee eo oe oo])))))