Professional Documents
Culture Documents
Informed Search
Informed Search
Informed Search
AIM:
programming language.
ALGORITHM:
a. Find the node with the lowest f cost in the open list (f = g + h, where g is the
cost of the path from the starting node to the current node, and h is the heuristic
estimate of the cost from the current node to the goal node)
i. Calculate the successor's g cost (the cost of the path from the starting node
to the successor)
ii. Calculate the successor's h cost (the heuristic estimate of the cost from the
iv. If the successor is already in the closed list and the new f cost is higher
v. If the successor is already in the open list and the new f cost is higher than
vi. Otherwise, add the successor to the open list and update its f cost
4. If the open list is empty and the goal node has not been reached, there is nosolution
5.Stop.
PROGRAM:
frontier = PriorityQueue()
frontier.put(start, 0)
came_from = {}
cost_so_far = {}
came_from[start] = None
cost_so_far[start] = 0
current = frontier.get()
if current == goal:
break
cost_so_far[next_node] = new_cost
frontier.put(next_node, priority)
came_from[next_node] = current
graph = {
start = (0,0)
goal = (1,1)
path = [goal]
node = goal
node = came_from[node]
path.append(node)
path.reverse()
OUTPUT:
RESULT:
Thus the python program to implement informed search was executed successfully and output was
verified.