UNIHIVE

Study Hub UNIPORT CSC 494

CSC 494 · Introduction to Artificial Intelligence

Game playing and adversarial search

Games as search problems, the minimax algorithm, alpha-beta pruning and evaluation functions.

Our notes

2 min read

Games as search

Two-player, turn-taking, zero-sum games with perfect information (chess, draughts, tic-tac-toe, ayo/oware in its standard form). Define: initial state, players, actions, result, terminal test, and utility (win +1, loss −1, draw 0).

Minimax

MAX tries to maximise the utility, MIN to minimise it. Values are backed up from the leaves:

  • MAX node: the maximum of its children's values.
  • MIN node: the minimum.

Minimax gives optimal play against an optimal opponent. Time O(b^m), space O(bm).

Worked example

MAX at the root has two moves leading to MIN nodes L and R.

  • L's leaves: 3, 12, 8 → MIN value 3.
  • R's leaves: 2, 4, 6 → MIN value 2.
  • Root (MAX) = max(3, 2) = 3: MAX should play towards L.

Alpha-beta pruning

Gives the same answer as minimax but skips branches that cannot change the decision.

  • α = best value MAX can guarantee so far; β = best value MIN can guarantee so far.
  • Prune when α ≥ β.

In the example: after L, α = 3 at the root. At R the first leaf is 2, so R's value is at most 2, already worse for MAX than 3: the leaves 4 and 6 are pruned.
With perfect move ordering, alpha-beta examines about O(b^(m/2)) nodes: it can search about twice as deep in the same time.

Evaluation functions

Real games are too big to search to the end (chess has about 35 moves per position). Search to a depth limit and score positions with an evaluation function, such as a weighted sum of features: material (pawn 1, knight 3, bishop 3, rook 5, queen 9), mobility, king safety. Problems: the horizon effect (a bad event just beyond the depth limit); quiescence search helps.

Beyond minimax

  • Games of chance (backgammon, ludo): expectiminimax adds chance nodes with probability-weighted averages.
  • Monte Carlo tree search with learned neural networks (AlphaGo, AlphaZero) plays Go and chess at superhuman level.

Exams usually ask

  • Apply minimax to a game tree and give the root value and best move.
  • Show which branches alpha-beta prunes.
  • Explain evaluation functions and the horizon effect.

Common mistake

Thinking alpha-beta can change the minimax value. Pruning only saves work; the chosen move and value are the same.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 494 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.