I'm teaching myself the minimax algorithm and I just had a few questions I was hoping someone could answer.
Firstly on line 05 - what does :=
mean?
Also on line 08/14 I notice that the method max
or min
is called with two arguments, what would this method return? Would it return the maximum value or the minimum value found so far? Is there a pseudocode example of this or am I misunderstanding?
01 function minimax(node, depth, maximizingPlayer)
02 if depth = 0 or node is a terminal node
03 return the heuristic value of node
04 if maximizingPlayer
05 bestValue := −∞
06 for each child of node
07 v := minimax(child, depth − 1, FALSE)
08 bestValue := max(bestValue, v)
09 return bestValue
10 else (* minimizing player *)
11 bestValue := +∞
12 for each child of node
13 v := minimax(child, depth − 1, TRUE)
14 bestValue := min(bestValue, v)
15 return bestValue
bestValue := −∞
: Assign negative infinity (the lowest possible number) to bestValue
max(bestValue, v)
returns bestValue
or v
, whichever is biggermin(bestValue, v)
returns bestValue
or v
, whichever is smallerSince this is pseudocode, we can assume that any language you will use to implement it provides the functions max
and min
. If not, you can easily implement them yourself.