n
nMinmax algorithm
Minimax is an algorithm used to determine thescore in a zero- sum game after a certain number of moves, with best play according to an evaluation function.
The algorithm can be explained like this: In aone-ply search, where only move sequences with length one are examined, the side to move (max player) can simply look at the evaluation after playing all possible moves . The move with the best evaluation is chosen. But for a two-ply search, when the opponent also moves, things become more complicated. The opponent (min player) also chooses the move that gets the best score. Therefore, the score of each move is now the score of the worst that the opponent can do.
Minimax is an algorithm used to determine the
The algorithm can be explained like this: In a
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)
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)
No comments:
Post a Comment