Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 20, 2017 19:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save deque-blog/8930b3db173bd82592308d33bab3cee5 to your computer and use it in GitHub Desktop.
(defn- start-game-loop
"Manage transitions between player moves, ai moves, and generic game events"
[]
(let [play-events (chan 1 (filter #(not @store/ai-player?)))
game-events (chan 1)]
(go
(while true
(let [play-chan (if @store/ai-player?
(ai-computation @store/game)
play-events)]
(alt!
game-events ([msg] (handle-menu-event! msg))
play-chan ([coord] (store/swap-game! game/play-at coord))
))))
{:play-events play-events
:game-events game-events}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment