(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