Created
March 18, 2017 17:00
Star
You must be signed in to star a gist
This file contains 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
(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