AI-Lecture 6 (Adversarial Search)
AI-Lecture 6 (Adversarial Search)
AI-Lecture 6 (Adversarial Search)
Lecture 6
Search – no adversary
●
Solution is (heuristic) method for finding goal
●
Heuristics technique can find optimal solution
●
Evaluation function: estimate of cost from start to goal through given node
●
Examples: path planning, scheduling activities
Games – adversary
●
Solution is strategy (strategy specifies move for every possible opponent
reply).
●
Time limits force an approximate solution
●
Evaluation function: evaluate “goodness” of game position
●
Examples: chess, checkers, Othello, backgammon
Types of Games
Problem Formulation:
Initial state: board configurations and the player to
move.
Successor function: list of pairs (move, state)
specifying legal moves and their resulting states.
(moves + initial state = game tree)
A terminal test: decide if the game has finished.
A utility function: produces a numerical value for
(only) the terminal states. Example: In chess, outcome
= win/loss/draw, with values +1, -1, 0 respectively.
Criterion Minimax
Complete? Yes
Time O(bm)
Space O(bm)
Optimal? Yes
Minimax Algorithm
Minimax algorithm
Perfect for deterministic, 2-player game
One opponent tries to maximize score (Max)
One opponent tries to minimize score (Min)
Goal: move to position of highest minimax
value
Identify best achievable payoff against best
play
Multiplayer games
>=2
• We don’t need to compute
=2 <=1 the value at this node.
• No matter what it is, it can’t
affect the value of the root
node.
2 7 1 ?
Alpha-Beta Example
[-∞,+∞]
[-∞, +∞]
Alpha-Beta Example (continued)
[-∞,+∞]
[-∞,3]
Alpha-Beta Example (continued)
[-∞,+∞]
[-∞,3]
Alpha-Beta Example (continued)
[3,+∞]
[3,3]
Alpha-Beta Example (continued)
[3,+∞]
This node is worse
for MAX
[3,3] [-∞,2]
Alpha-Beta Example (continued)
[3,14] ,
[3,5] ,
[3,3]
[3,3]
Consider a node n
somewhere in the tree
If player has a better choice
at
●
Parent node of n
●
Or any choice point further up
n will never be reached in
actual play.
Hence when enough is
known about n, it can be
pruned.
Final Comments about Alpha-Beta
Pruning
Change:
if TERMINAL-TEST(state) then return UTILITY(state)
into
if CUTOFF-TEST(state,depth) then return EVAL(state)
For Tic-Tac-Toe:
f(s) = [# of 3-lengths open for me] - [# of 3-lengths open for you]
where a 3-length is a complete row, column, or diagonal.
Addition assumes
independence
Eval(s) = w1 f1(s) + w2 f2(s) + … + wnfn(s)
End