Skip to content

Commit

Permalink
Naive windowshade bot that wins over reserves-move on square even boa…
Browse files Browse the repository at this point in the history
…rds.
  • Loading branch information
timmc committed May 31, 2012
1 parent 12d8db8 commit 8401826
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/crosscram/samples/windowshade_rand.clj
Original file line number Diff line number Diff line change
@@ -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])))))

0 comments on commit 8401826

Please sign in to comment.