forked from reiddraper/crosscram
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Naive windowshade bot that wins over reserves-move on square even boa…
…rds.
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]))))) |