Professional Documents
Culture Documents
Game AI
Game AI
Game AI
Minimax Algorithm
2
1
2
2
7 1
Static evaluator
value
7 1
7 1
MAX
MIN
7 1
Minimax Tree
MAX node
MIN node
f value
value computed
by minimax
Minimax Principle
Minimax Principle
you (the computer) assume that the opponent will
choose the minimizing move next (after your move)
so you now choose the best move under this
assumption
i.e., the maximum (highest-value) option considering
both your move and the opponents optimal move.
we can generalize this argument more than 2 moves
Complexity of Minimax
Algorithm
The O(bd) time complexity is a major problem since the computer typically only has a
finite amount of time to make a move,
e.g., in chess, 2 minute time-limit, but b=35, d=50 !
So
An Evaluation Function:
provide an estimate of how good the current board
configuration is for the computer.
think of it as the expected utility averaged over all
possible game outcomes from that position
it reflects the computers chances of winning from that
node
but it must be easy to calculate, i.e., cannot involve
searching the tree below the depth-limit node
thus, we use various easily calculated heuristics, e.g.,
Chess: Value of all white pieces - Value of all black
pieces
Typically, one figures how good it is for the computer,
and how good it is for the opponent, and subtracts the
opponents score from the computers
Alpha-beta pruning
We can improve on the performance
of the minimax algorithm through
alpha-beta pruning
Basic idea: If you have an idea that
is surely bad, don't take the time to
see how>=2
truly awful it is. -- Pat
MAX
We dont need to
Winston
compute the value at
MIN
=2
<=1
MAX
2
this node.
No matter what it is, it
cant affect the value
of the root node.
-8
Opponents Moves
(min of evaluations)
3 4
2 0
-8
X
Pruning
When Maximizing,
do not expand any more sibling nodes once a node has
been seen whose evaluation is smaller than Alpha
When Minimizing,
do not expand any sibling nodes once a node has been
seen whose evaluation is greater than Beta
alpha () = the value of the best choice at any node for the MAX
algorithm
beta () = the value of the best choice at any node for the MIN
algorithm
The Alpha-Beta
Procedure
Alpha-beta pruning is a procedure
to reduce the amount of computation
and searching during minimax.
Minimax is a two-pass search, one
pass is used to assign heuristic values
to the nodes at the ply depth and the
second is used to propagate the values
up the tree.