Professional Documents
Culture Documents
Hridaya Kandel
hridayakandel@gmail.com
AI Lecturer
BScCSIT Vth
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
Iterative deepening search
**LIFO
space.
Best-First Search
Idea: use an evaluation function f(n) for each node
estimate of "desirability
Expand most desirable unexpanded node
Implementation:
Order nodes on the nodes list(fringe) by increasing value of an evaluation function,
f(n), that incorporates domain-specific information in some way.
Completeness:
While minimizing the value of heuristic
greedy may oscillate between two nodes.
Thus it is not complete.
Optimality: (fig)
Greedy search is not optimal. Same as DFS.
Time complexity
In worst case Greedy search is same as DFS
therefore its time complexity is O(bm).
Space Complexity:
Space complexity is O(bm). No nodes can be
deleted from memory.
Completeness:
Yes A* search always gives us solution
Optimality:
A* search gives optimal solution when the heuristic function is admissible
heuristic.
Time complexity:
Exponential with path length i.e. O(bd) where d is length of the goal node from
start node.
Space complexity:
It keeps all generated nodes in memory. Hence space is the major problem not
time
Drawback
An important drawback of local search is that if no
solution exists, a local search method will simply
continue to make local modification indefinitely.
Tabu search
Local search algorithms
To understand local search, consider the state space landscape(fig).
A landscape has both location (defined by the state) and the
elevation( defined by the value of the heuristic cost function or
objective function).
If elevation corresponds to cost then, the aim is to find lowest valley(
global minimum).
If elevation corresponds to an objective function, then the aim is to
find highest peak( global maximum).
A complete local search algorithm
always finds a goal if one exists
An optimal algorithm
always finds a global maximum/minimum
Location
Figure: One Dimensional State space Landscape
Platuex
The higher the temperature, the more likely it is that a bad move can be
made.
As T tends to zero, this probability tends to zero, and SA becomes
more like hill climbing
If T is lowered slowly enough, SA is complete and admissible.
Unpredictable opponent
Solution is a strategy
Specifying a move for every possible opponent
reply
Time limits
Unlikely to find the goalagent must
approximate
Draw 0
Tic-Tac toe
Figure below shows part of the game tree for tic-tac-toe
MINMAX-VALUE(n): =
A1 A3
A2
3 12 8 2 4 6 14 5 2
nodes are "MAX nodes," in which it is MAX'S turn to move, and the nodes are
"MIN nodes.
MAX'S best move at the root is A1, because it leads to the successor with the highest
minimax value, and MIN'S best reply is A11, because it leads to the successor with the
Hridaya Kandel (AI Lecturer) 93
lowest minimax value
An optimal procedure: The Min-Max
method
Designed to find the optimal strategy for Max and find best move:
The recursion proceeds all the way down to the leaves of the tree, and then
the minimax values are backed up through the tree as the recursion unwinds
Basic Algorithm
Let us assign the following values for the game: 1 for win by X, 0 for draw, -1
for loss by X.
Given the values of the terminal nodes (win for X (1), loss for X (-1), or draw
(0)), the values of the non-terminal nodes are computed as follows:
the value of a node where it is the turn of player X to move is the maximum
of the values of its successors (because X tries to maximize its outcome);
the value of a node where it is the turn of player O to move is the minimum
ofHridaya
theKandel
values of its successors (because
(AI Lecturer) 95 O tries to minimize the outcome of
X).
Min-Max Algorithm
A1 A3
A2
A11
A12 A13 A21 A22 A23 A31 A32 A33
3 12 8 2 4 6 14 5 2
Limitations
Not always feasible to traverse entire tree
Time limitations
Hridaya Kandel (AI Lecturer) 98
Alpha-Beta Pruning
The problem with minimax search is that the number of game states
it has to examine is exponential in the number of moves.
Is there some way we can search deeper in the same amount of time?
The first leaf below B has the value 3. Hence, B, which is a MIN
node, has a value of at most 3
The second leaf below B has a value of 12; MIN would avoid this
move, so the value of B is still at most 3
The third leaf below B has a value of 8; we have seen all B's
successors, so the value of B is exactly 3. Now, we can infer that the
value of the root is at least 3, because MAX has a choice worth 3 at
the root.
Hridaya Kandel (AI Lecturer) 103
Example: Alpha-Beta Pruning
The first leaf below C has the value 2. Hence, C, which is a MIN
node, has a value of at most 2. But we know that B is worth 3, so
MAX would never choose C. Therefore, there is no point in looking
at the other successors of C.
Hridaya Kandel (AI Lecturer) 104
Example: Alpha-Beta Pruning
The first leaf below D has the value 14, so D is worth at most 14.
This is still higher than MAX'S best alternative (i.e., 3), so we need
to keep exploring D's successors. Notice also that we now have
bounds on all of the successors of the root, so the root's value is also
Hridaya Kandel (AI Lecturer) 105
at most 14
Example: Alpha-Beta Pruning
[,+] A
3 12 8 2 14 5 2
[,+] A
3 12 8 2 14 5 2