Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created March 26, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/8c9b3bacdd2bcb10061bb53795917417 to your computer and use it in GitHub Desktop.
Save deque-blog/8c9b3bacdd2bcb10061bb53795917417 to your computer and use it in GitHub Desktop.
(defn minimax
"Implements the minimax recursion:
* Call the leaf node evaluation if the depth is zero
* Otherwise goes one level deeper"
[ai turn depth]
(if (or (zero? depth) (turn/game-over? turn))
(eval-turn ai turn)
(minimax-step ai turn
(fn [_ transition]
(minimax ai
(turn/next-turn turn transition)
(dec depth))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment