(def animation-delay 500) | |
(def ai-move-delay 1000) | |
(defn ai-computation | |
"Run the computation of the AI asynchronously: | |
* Wait 500ms to start (animation might be frozen otherwise) | |
* Wait 1s to play the move (avoid moves being played too fast)" | |
[game] | |
(go | |
(<! (async/timeout animation-delay)) | |
(let [ai-chan (go (ai/find-best-move game))] | |
(<! (async/timeout ai-move-delay)) | |
(<! ai-chan)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment