Artificial intelligence • Original RRTutors lesson
Game Trees, Minimax, and Alpha-Beta Pruning
Choose actions in competitive turn-based games by reasoning about an opponent’s best response.
Concept and explanation
Minimax alternates maximizing and minimizing turns in a game tree. A terminal utility assigns value to outcomes; when full search is too expensive, a depth limit and evaluation function approximate leaf value. Alpha-beta pruning skips branches that cannot change the final choice while preserving minimax results.
How to apply it
Define legal moves, terminal states, utility perspective, and depth; use move ordering to improve pruning.
Worked example
A board-game agent evaluates possible moves and assumes an informed opponent will choose a response that lowers its score.
Illustrative Python example
def minimax(state, depth, maximizing):
if depth == 0 or terminal(state):
return evaluate(state)
values = [minimax(next_state, depth - 1, not maximizing)
for next_state in successors(state)]
return max(values) if maximizing else min(values)
Expected result
The recursive value propagates the best achievable outcome under alternating play.
Limitations and cautions
Search cost grows rapidly with branching factor and depth; heuristic evaluation can be biased.
Practice exercise
Add alpha and beta bounds to the pseudocode and identify a branch that can be pruned.
Key takeaway: Adversarial search optimizes against an explicit opponent model.