Created
March 18, 2017 17:00
-
-
Save deque-blog/f6a2eb257cbfe64c00fa0b5dbd2d6ad8 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
(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