Minimax(board, depth, type)
; If we reached the depth limit, use the heuristic
function
; to rank the board.
if
depth=0 then
return(evaluate(board))
else
; If it is our turn now, make the choice that
will
; give us the maximum result
if
type=max then
cur-max -infinity
loop for b in succ(board)
b-val minimax(b, depth-1,
min)
cur-max max(b-val, cur-max)
end
loop
return cur-max
; If it is the enemy turn, choose the best
board for him.
else
(type=min)
cur-min infinity
loop for b in succ(board)
b-val minimax(b, depth-1,
max)
cur-min
min(b-val,cur-min)
end
loop
return cur-min
אבל הוא עדיין לא נפתח...