Professional Documents
Culture Documents
(lecture # 7)
• Heuristic in AI
• No of Missing Tiles, Manhattan Distance
• Best First Search
• Greedy Best Search
Artificial Intelligence 3
Heuristic in AI
Artificial Intelligence 4
Heuristic in AI
Problem-Solving:
Heuristics are commonly used in problem-solving tasks,
allowing AI systems to explore solution spaces more
effectively.
The trade-off with Accuracy:
While heuristics provide quick solutions, they may not
guarantee the most accurate result. There's often a trade-off
between speed and accuracy.
- good solution but not optimal always.
Artificial Intelligence 5
How? Euclidean distance
Euclidean distance is a measure of the straight-line distance between two points in Euclidean
space. In two-dimensional space, it is the length of the shortest path between two points, forming
a right-angled triangle. The formula for calculating Euclidean distance between two points
(x1,y1) and (x2,y2) in a two-dimensional space is given by:
Euclidean Distance = √
Artificial Intelligence 6
How?
Artificial Intelligence 7
Example: 8-puzzle
1 2 3 1 2 3
4 6 5 4 5 6
8 7 7 8
1 2 3
4 6 5 no ono of Misplaced tiles=4
8 7 f Misplaced tiles=4
1 2 3 1 2 3
4 6 4 6 5
no of Mino of Misplaced tiles=4 nMino of Misplaced tiles=4
8 7 5 8 7 o of Misplaced tiles=4
splaced tiles=4
Artificial Intelligence 9
Example: 8-puzzle
• Heuristic: no of Misplaced tiles
1 2 3
4 6 5 no of Misplaced tiles=4
8 7
1 2 3 1 2 3
4 6 4 6 5
no of Misplaced tiles=4 no of Misplaced tiles=4
8 7 5 8 7
1 2 3 1 2 3
no of Misplaced tiles=3 4 6 4 6
8 7 5 8 7 5
Artificial Intelligence 10
How? Manhattan distance
Artificial Intelligence 11
Example: 8-puzzle
1 2 3 1 2 3
4 6 5 4 5 6
8 7 7 8
Artificial Intelligence 12
Example: 8-puzzle
1 2 3
4 6 5 distance = 0+0+0+0+1+1+1+1=4
8 7
1 2 3 1 2 3
4 6 4 6 5
distance = 0+0+0+0+1+1+1+2=5 distance = 0+0+0+0+1+1+1+2=5
8 7 5 8 7
Artificial Intelligence 14
Best First Search
Artificial Intelligence 15
Algorithm
Algorithm: Best-First-Search(Graph g, Node start)
1. Create an empty PriorityQueue
PriorityQueue pq;
2. Insert "start" in pq.
pq.insert(start);
3. Until PriorityQueue is empty
u = pq.deleteMin;
If u is the goal
Exit
Else
For each neighbor v of u
If v is "Unvisited"
Mark v "Visited"
pq.insert(v)
Mark u "Examined"
End Algorithm
Artificial Intelligence 16
Romania - Step Costs in KM
Artificial Intelligence 17
Greedy Best-First Search
Artificial Intelligence
Greedy Best-First search example
Artificial Intelligence
Greedy Best-First search example
Artificial Intelligence
Greedy Best-First search example
• Optimal? No.
Artificial Intelligence
THANKS