Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 26, 2017 12:27
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/924ed179efd75ed5662b875f3cf28070 to your computer and use it in GitHub Desktop.
Save deque-blog/924ed179efd75ed5662b875f3cf28070 to your computer and use it in GitHub Desktop.
(defn minimax-step
"One stage of the minimax algorithm:
* Apply the maximizing or mininizing step to all transitions of the turn
* Evaluate the lower level using the on-transition function"
[ai turn open-recur
& {:keys [max-fn min-fn]
:or {max-fn max, min-fn min}}]
(apply
(if (maximizing? ai turn) max-fn min-fn)
(map
(fn [[coord transition]] (open-recur coord transition))
(turn/transitions turn))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment