Chapter4 - Heuristic Search
Chapter4 - Heuristic Search
Chapter4 - Heuristic Search
(n) = g
(n) + h
(n), where
g
(n) : Actual cost of optimal path from the start node to goal node through
n state.
Notes:-
If the best first search algorithm apply the f
.
2. g is a reasonable estimate of g
(n).
Admissible heuristic can reach non goal state a long sub optimal path.
It is admissible because it reaches each state a long shortest path from its
ancestors.
When the best first search algorithm applies monotone heuristic, It will be
able to find the shortest path to any state, therefore there is no need to
check the open nor the close lists.
Any monotone heuristic is admissible.
Proof
Assume that any path on space is S
1
, S
2
, S
3
, . . . S
g
, where S
1
is the start
state and S
g
is the goal state.
S
1
to S
2
: h(S
1
) h(S
2
) cost(S
1
, S
2
)
11
S
2
to S
3
: h(S
2
) h(S
3
) cost(S
2
, S
3
)
S
3
to S
4
: h(S
3
) h(S
4
) cost(S
3
, S
4
)
.
.
S
g1
to S
g
: h(S
g
1
) h(S
g
) cost(S
g1
, S
g
)
Sum all the columns the h(S
1
) cost(S
1
, S
g
)
Informedness
For two A
heuristic algorithm h
1
and h
2
, if h
1
(n) h
2
(n) n in space search
h, then heuristic h
2
is said to be more informed than h
1
.
Examples:-
Breadth-first search algorithm is A
: h(x) = 0 x, so h
1
< h
.
number of tiles out of place h
2
< h
h
1
h
2
.
4 Game playing
Classical application for heuristic search
1. Simple game: Exhaustively searchable.
2. Complex games: Only partial search possible.
3. Additional problem: playing against opponent.
Two persons adversarial games (win, lose or tie).
Assume that both player extract the same knowledge from the configuration
board and they do apply it consistently to win the game.
MiniMax Search
Game between two opponents, MIN and MAX means
MAX tries to win.
MIN tries to minimize MAXs score.
12
MiniMax procedure:
1. Label each level according to players move.
2. Leaves get a value of 1 or 0 (win for MAX or MIN).
3. Propagate this value up:
If parent=MAX, give it max value of children.
If parent=MIN, give it min value of children.
Nim Game
Rules
1. Two players start with a pile of tokens.
2. Legal move: Split (any) existing pile into two non-empty differently-
sized piles.
3. Game ends when no pile can be unevenly split.
4. Player who cannot make his move loses the game.
Search strategy: Existing heuristic search methods do not work.
Label nodes as MIN or MAX, alternating for each level.
Define utility function (payoff function).
Do full search on tree (expand all nodes until game is over for each branch).
Label leaves according to outcome.
Propagate result up the tree with:
M(n) = max( child nodes ) for a MAX node.
M(m) = min( child nodes ) for a MIN node.
Best next move for MAX is the one leading to the child with the highest
value (and vice versa for MIN).
13
14
MiniMAx with Heuristic
Exhaustive search for interesting games is rarely feasible.
Search only to predefined level.
It is called n-ply look-ahead where n is number of levels.
No exhaustive search (why)
Nodes evaluated with heuristics and not win/loss.
It indicates best state that can be reached.
Horizon effect.
simple strategy: try to maximize difference between players.
Figure 3: MiniMax with Fixed Ply Depth
15
Applying MiniMax to tic-tac-toe
Heuristic tries to measure conflict in game.
How to evaluate a state?
Count all winning lines open to MAX.
Subtract all winning lines open to MIN.
Forced win for MAX as +
Forced win for MIN as
Search attempts to maximize this difference.
16
Figure 4: MiniMax to tic-tac-toe
Alpha-beta search
Search algorithm design for 2-player games.
Unlike MiniMax, does not search entire depth.
Ignore (cut off, prune) entire branches of the tree that cannot possibly lead
to a better solution.
Reduces branching factor.
Allows deeper search with same effort.
It starts with depth-first search down to n-ply depth.
It applies heuristic to a state and its siblings.
Propagate result to parent as in minimax.
It deals with two values:
alpha value is attached to MAX nodes: The best (highest) choice for
MAX on path (never decreases).
beta is associated with MIN nodes: The best (lowest) choice for MIN
on path (never increases).
It prunes search tree by using:
alpha cutoff: Prune tree below MIN node, if value alpha.
beta cutoff: Prune tree below MAX node, if value beta.
17
Figure 5: Alpha Beta Search
18