Artificial Intelligence & Neural Networks β Problem Solving and Searching Techniques, NEC licence examination syllabus (Nepal Engineering Council).
Mini-max Search
The algorithm that defines what the correct move is.
π Where this lives: minimax is the reason a chess engine will not fall for a trap that looks good for one move. It assumes the opponent will find the best reply, so any line that depends on the opponent blundering gets discarded. That pessimism is exactly what you want from a system playing for money or safety β and it is also why minimax players can look unimaginative against weak opponents, refusing risky lines that would work. Search "minimax worst case guarantee game tree".
The algorithm
MINIMAX computes the MINIMAX VALUE of each state β the utility of
being in that state, assuming BOTH PLAYERS PLAY OPTIMALLY to the
end of the game.
MINIMAX(s) =
UTILITY(s) if TERMINAL-TEST(s)
max_{a β ACTIONS(s)} MINIMAX(RESULT(s,a)) if PLAYER(s)=MAX
min_{a β ACTIONS(s)} MINIMAX(RESULT(s,a)) if PLAYER(s)=MIN
THE ALGORITHM, as usually written:
function MINIMAX-DECISION(state) returns an action
return argmax over a in ACTIONS(state) of
MIN-VALUE(RESULT(state, a))
function MAX-VALUE(state) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v β ββ
for each a in ACTIONS(state) do
v β MAX(v, MIN-VALUE(RESULT(state, a)))
return v
function MIN-VALUE(state) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v β +β
for each a in ACTIONS(state) do
v β MIN(v, MAX-VALUE(RESULT(state, a)))
return v
IT IS A COMPLETE DEPTH-FIRST EXPLORATION of the game tree. The
values propagate UP from the leaves: utilities are known at the
terminal states, and each internal node takes the max or min of
its children according to whose turn it is.
PROPERTIES:
COMPLETE yes, if the tree is finite
OPTIMAL yes, against an optimal opponent
TIME O(b^m) where m is the maximum depth
SPACE O(bm) if all actions are generated at once, or
O(m) if generated one at a time
β the space is linear because it is depth-first; the TIME is
the problem, and it is the reason for the next topic.
WORKED EXAMPLE β the standard three-branch tree. MAX moves first;
each of MAX's three moves leads to a MIN node with three
terminal children.
leaf utilities:
branch A: 3, 12, 8
branch B: 2, 4, 6
branch C: 14, 5, 2
MAX
ββββββββΌβββββββ
A B C
MIN MIN MIN
/ | \ / | \ / | \
3 12 8 2 4 6 14 5 2
STEP 1 β evaluate the MIN nodes. MIN picks the SMALLEST child,
because MIN is trying to minimise MAX's utility:
MIN(A) = min(3, 12, 8) = 3
MIN(B) = min(2, 4, 6) = 2
MIN(C) = min(14, 5, 2) = 2
STEP 2 β evaluate the MAX node. MAX picks the LARGEST:
MAX = max(3, 2, 2) = 3
THE MINIMAX DECISION IS MOVE A, with a guaranteed value of 3.
READ WHAT THAT MEANS CAREFULLY, because it is the point of the
algorithm: branch C contains the best leaf in the whole tree
(14), and MAX does not choose it. MAX cannot reach the 14
because MIN chooses at that node and will play the 2 instead.
THE 14 IS UNREACHABLE AGAINST A COMPETENT OPPONENT, so
choosing C on the strength of it would be wishful thinking.
Minimax values what you can FORCE, not what you can hope for.
9 leaves were evaluated. Note that number β the next topic
shows how many were actually necessary.
A FOUR-PLY EXAMPLE, because exam questions use them and the
alternation is where mistakes happen.
MAX (root)
βββ MIN b1
β βββ MAX c1 β leaves 8, 7
β βββ MAX c2 β leaves 3, 9
βββ MIN b2
β βββ MAX c3 β leaves 9, 8
β βββ MAX c4 β leaves 2, 4
βββ MIN b3
βββ MAX c5 β leaves 1, 8
βββ MAX c6 β leaves 8, 9
WORK FROM THE LEAVES UPWARD. The level above the leaves is MAX,
so take maxima:
c1 = max(8, 7) = 8
c2 = max(3, 9) = 9
c3 = max(9, 8) = 9
c4 = max(2, 4) = 4
c5 = max(1, 8) = 8
c6 = max(8, 9) = 9
The next level up is MIN, so take minima:
b1 = min(c1, c2) = min(8, 9) = 8
b2 = min(c3, c4) = min(9, 4) = 4
b3 = min(c5, c6) = min(8, 9) = 8
The root is MAX:
root = max(8, 4, 8) = 8
THE MINIMAX VALUE IS 8, achieved by moving to b1 (or b3 β both
give 8, so either is optimal and a tie-break rule decides).
THE COMMON MISTAKES, worth naming because they are what loses
marks:
Β· applying max at the wrong level. COUNT PLY FROM THE ROOT:
the root is MAX, so odd-numbered levels below it are MIN
and even-numbered ones are MAX.
Β· taking the max over the leaves of a MIN node. MIN chooses
among its children; the leaves under c4 belong to c4's
MAX decision, not to b2's.
Β· reporting the VALUE when the question asks for the MOVE,
or the reverse. The minimax DECISION is the action; the
minimax VALUE is the number.
A USEFUL CHECK: the root value must appear somewhere in the leaf
set, because every internal value is copied up from some leaf.
Here 8 appears among the leaves, which is consistent. If your
computed root value is not a leaf value, you have made an
arithmetic error.
16 LEAVES WERE EVALUATED HERE. With b = 2 and d = 4 that is
2^4 = 16, the full tree β minimax always examines every leaf.
The next topic removes that, and the saving is the difference
between a program that searches 8 ply and one that searches 16.
The unreachable 14 is the idea to carry: minimax values what you can force, not what you can hope for. Branch C holds the best leaf in the tree and is not chosen, because the opponent decides at that node and will never hand it over. Every line that depends on an opponent blunder is discarded by construction.
π Go further: the amplification of evaluation error under deeper minimax search is a genuinely counter-intuitive result known as search pathology or minimax pathology. Because a max over several noisy estimates preferentially selects whichever happened to be overestimated, and that bias compounds with depth, in certain artificial game trees deeper search provably plays worse. Real games do not usually exhibit it β deeper search helps in chess β but understanding why it can happen is what stops you assuming more search is automatically better. Search "minimax pathology deeper search worse decisions".
π‘ Exam angle: give the minimax recurrence and the MAX-VALUE/MIN-VALUE pseudocode, and state the complexities β time O(b^m), space O(bm). The guaranteed question is to compute the minimax value of a given tree and state the optimal move: work upward from the leaves, alternate max and min by ply counted from the root, and report both the value and the move. Explain why the largest leaf may be unreachable. Know the multiplayer extension with utility vectors and that alliances emerge. State minimax's assumptions β an optimal opponent, exact utilities, zero-sum, a searchable tree β and where each fails.
Syllabus points
Minimax algorithm (numerical)
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Related topics in Problem Solving and Searching Techniques