Question: import data as d # A* shortest path # frontier and visited nodes have the form: # [location, previous, g_value(location), g_value(location)] # index constants for

 import data as d # A* shortest path # frontier and

import data as d # A* shortest path # frontier and visited nodes have the form: # [location, previous, g_value(location), g_value(location)] # index constants for nodes: LOCATION = 0 PREVIOUS = 1 G_VAL = 2 F_VAL = 3 #======================================== def enqueue(pq, new_node): i = 0 while i  pq[i][F_VAL]: i += 1 if i == len(pq): pq.append(new_node) else: pq.insert(i, new_node) #======================================== def index_in_visited(visited, location): i = 0 while i   Problem 6 (20 pts) Write the function A_Star_Search(graph, h, start, goal, show). This takes a graph, a heuristic function h, and the start and goal vertices (locations). Use the A* search algorithm to find the least-cost (shortest) path from start to goal. To do so, you will create frontier and visited lists. You can use the given enqueue method to enqueue nodes into frontier. To dequeue the node with the smallest f-value, use frontier.pop (). Nodes in both will have the form: [location, previous location, g_value(location), f_value(location)] You may (but don't have to) use the function index_in_visited(visited, location), which returns the index in visited of the node with the given location, or 1 if that location has not yet been visited. As in Problem 5, the parameter show is a boolean. If it is true, display the frontier and visited lists, as well as the node that is popped off of the frontier. (See output file). For all test cases, it is possible to get from the source to the destination

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!