AI Lec03 Adversarial Search
AI Lec03 Adversarial Search
AI Lec03 Adversarial Search
Semester 3, 2024
Artificial Intelligence
Adversarial Search
Minimax search
Uniform-cost (UCS): Priority Q ordered by g(n), complete (if b is limited and step
cost is positive), optimal
Iterative deepening (IDS): LIFO Q, complete (if b is finite), optimal (if step cost is
identical)
Bi-directional (BDS): complete (if b is finite and both directions are BFS), optimal (if
step cost is identical and both directions are BFS)
Greedy: Priority Q ordered by h(n), complete (if graph search in finite spaces), non-
optimal
A*: Priority Q ordered by g(n) + h(n), complete (if b is finite and step cost is positive),
optimal (if h(n) is admissible for tree search or consistent for graph search)
Properties of Heuristic Functions
Admissibility
h(n) admissible if it never overestimates the cost from n to reach the goal.
This means that A* search approaches the optimal cost C* from below.
Every node with f(n) < C* will be expanded.
Consistency
h(n) <= c(n, a, n’) + h(n’), n’ is any successor of n
Informedness
h2(n) is more informed than h1(n) if h2(n) ≥ h1(n).
Why is h2(n) better than h1(n)?
Heuristics allow us to prune the search space: if h2(n) ≥ h1(n) then h2(n) will
make us to search only a subset of the nodes searched by h1(n).
Games
Games as Adversarial Search
8-puzzle problems involve only one player. A game usually have two or more
players, such as chess, tic-tac-toe, checker, Othello, etc.
Adversarial search if the goals of
Can we formulate game playing as search problems? YES different players are conflict!
Can we build a search tree to represent a game from the very beginning to every
possible ending scenario of the game? YES, such as the tree for tic-tac-toe:
My Possible Moves
Opponent's
Possible Moves How many nodes on this level?
Ending States
-1 0 1
Games as Adversarial Search (cont’d)
It is almost impossible (and also unnecessary) to build a search tree
to represent the entire search space for even a simple game like tic-
tac-toe.
A realistic search method is to find the “best” next move based on the
current state of the game. This move should ideally maximize the
chance of winning.
The opponent will reply against our move. Then we perform the search
again based on the new state to find the next “best” move.
Utility(s, p): utility value for a game ending at a terminal state s for a
player p
e.g., utility value for chess is:-1, 0 or 1 (zero-sum game)
Minimax Game
Two players: MAX and MIN
Calculate Minimax(s)
Utility(s) if Terminal-test(s)
Maxa Minimax(Result(s, a)) if Player(s) = MAX
Mina Minimax(Result(s, a)) if Player(s) = MIN
Calculate in the depth-first manner
Minimax Game Example
Ply
▲ is a “MAX node”. It is MAX ’s turn to move (to find the max value).
▼ is a “MIN node”. It is MIN ’s turn to move (to find the min value).
The bottom nodes are leave nodes on which utility function applies.
The highest current value of any MAX node along the path
to the root is alpha.
The lowest current value of any MIN node along the path to
the root is beta.
Alpha-Beta Pruning (cont’d)
α=3 A
The search outcome is not affected by the utility values of the terminal
nodes led by c2 and c3.
The outcome of this alpha-beta pruning is same with that from minimax. Less
Calculate H-Minimax(s)
Eval(s) if Cutoff-test(s, d)
Computationally efficient
Perfect Imperfect
Information Information
Backgammon:
Deterministic moves, but which ones are legal are
determined by two dices
Draughts: Chinook, using alpha-beta search, beat human master in 1990; Now plays
perfectly with a vast endgame database
Go: Humans still ahead (branch factor 361 …); Monte Carlo methods used
Conclusions
Revision of classic search strategies
Alpha-beta pruning
Cutting off search
Heuristic evaluation functions