Last active
March 20, 2017 19:19
-
-
Save deque-blog/8930b3db173bd82592308d33bab3cee5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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