126k views
2 votes
Write a program that uses a graph-based path planning algorithm (i.e., A*) to guide the driverless ar for traveling between two city halls.

Write the function PathFinder where the input arguments to the function are the name of two cities and the search algorithm.
a. Example: when you call the function PathFinder (VA, LA, A_Star), it returns the optimal path between Vancouver and Langley using A* algorithm.
b. (required) the function should implement the A* algorithm
c. (optional/bonus) extend your code to include Grassfire and Dijsktra's algorithms as well.

User Oblomov
by
8.5k points

1 Answer

1 vote

Final answer:

To find the optimal path between two city halls using the A* algorithm, one must implement the A* algorithm's process of pathfinding in a grid-like city map, consider heuristics, and iteratively evaluate nodes until the goal is reached. Optionally, the code could include Grassfire and Dijkstra's algorithms as alternative pathfinding methods.

Step-by-step explanation:

The PathFinder function requires implementation of the A* path planning algorithm to find the optimal path between two city halls. In this context, assume we have a grid-like map of a city with start (VA) and goal (LA) points. The A* algorithm efficiently finds the shortest path by using a heuristic to estimate the cost from the current node to the end node combined with the cost from the start node to the current node. The pseudocode for the A* algorithm is as follows:

  • Initialize the open list (priority queue) with the starting node.
  • Initialize the closed list (nodes already evaluated).
  • Loop until the open list is empty:
  • Return the path once the goal is reached, or indicate failure if no path is found.

Furthermore, if we extend the code to include other algorithms like Grassfire and Dijkstra's, we'd have alternative methods for pathfinding which may be suitable in different scenarios or for comparison purposes.

User Alfwatt
by
8.6k points