Professional Documents
Culture Documents
CS-216
Institute of Southern Punjab
Multan
Last Discussion
Last Discussion
In Today’s Lecture
• Hill Climbing Algorithm
• Adversarial search
Today’s Discussion
Today’s Discussion
• Euclidean: Take the square root of the sum of the squares of the differences of
the coordinates.
• For example, if x=(a,b)x=(a,b) and y=(c,d), the Euclidean distance between xx and yy
is
• Manhattan: Take the sum of the absolute values of the differences of the
coordinates.
|a−c|+|b−d|
Finding Distance
Finding Distance
• To use A* a heuristic function must be used that never overestimates the
number of steps to the goal
• h2=the sum of the Manhattan distances of the tiles from their goal positions
Heuristic Function
Heuristic Function
• A problem with fewer restrictions on the actions is called a relaxed problem
• The cost of an optimal solution to a relaxed problem is an admissible
heuristic for the original problem
• If the rules of the 8-puzzle are relaxed so that a tile can move anywhere,
then h1(n) gives the shortest solution
• If the rules are relaxed so that a tile can move to any adjacent square, then
h2(n) gives the shortest solution
Relaxed problems
Relaxed problems
• They are useful for solving optimization problems
• Aim is to find a best state according to an objective function
• Many optimization problems do not fit the standard search model
6 7 6 7 6 7 8
3 1 2 3 1 2 1 2
4 5 h=2 4 5 h=1 3 4 5 h=0
6 7 8 6 7 8 6 7 8 Goal
4 1 2 4 1 2 1 2
3 5 h=2 3 5 h=2 3 4 5 h=0
6 7 8 6 7 8 6 7 8 Goal
Adversarial Search
Adversarial Search
Questions
Questions Session
Questions Session