Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn new-game []
(list (turn/new-init-turn)))
(defn current-turn
"Return the current state of the game:
* Board (cells and owners)
* Player score
* Next player to play"
(first game))
(defn play-at
"Play a move, adding a new turn into the game"
[game coord]
(let [curr-turn (current-turn game)]
(if-let [transition (get (turn/transitions curr-turn) coord)]
(conj game (turn/next-turn curr-turn transition))
(defn undo-player-move
"Cancel the last player move, getting back to the previous player move"
(let [new-game (drop-while (comp player/is-ai? :player) (drop 1 game))]
(if (empty? new-game)
(take-last 1 game)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.