Created
March 31, 2014 13:55
-
-
Save mberberoglu/9892765 to your computer and use it in GitHub Desktop.
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
function minimax(node, depth, maximizingPlayer) | |
if depth = 0 or node is a terminal node | |
return the heuristic value of node | |
if maximizingPlayer | |
bestValue := -∞ | |
for each child of node | |
val := minimax(child, depth - 1, FALSE)) | |
bestValue := max(bestValue, val); | |
return bestValue | |
else | |
bestValue := +∞ | |
for each child of node | |
val := minimax(child, depth - 1, TRUE)) | |
bestValue := min(bestValue, val); | |
return bestValue | |
(* Initial call for maximizing player *) | |
minimax(origin, depth, TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment