Last active
May 18, 2016 16:04
-
-
Save 7hoenix/e05b27154576be6059e843b0eb50eb2a 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
(defn minimax [board func] | |
(if (game-is-over? board) | |
(score board func) | |
(let [available (find-available board) | |
states (map #(make-move board player %))] | |
(reduce func states)))) | |
(defn maxi [board] | |
(apply max (map minimax board mini))) | |
(defn mini [board] | |
(apply min (map minimax board mini))) | |
(defn game-is-over? returns true if the current board is a game over) | |
(defn score returns the score of the board (which will depend on who is invoking minimax the first time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment