Question: 2 0 . 1 1 Project 3 : A Wavefront Path Finder v 4 . 1 Project 3 : A Wavefront Path Finder ( The
Project : A Wavefront Path Finder v
Project : A Wavefront Path Finder
The project details are finished I have not completed the scoringtesting procedures.
NOTE:
Main will call your function:
distance wavefrontfilenamestartrow,startcol,endrow,endcol,ouput;
Return the distance and write the solution map to output. All other printing should go to std::cout only write the map to output the checker will read this map and anything else will confuse it
But you can write to std::cout all you want.
END NOTE
You will read in a text file as a map Here is an example:
#################### #### ###### ##### ###### ###### ###### ###### ####### ###### ### ####################
In the map file the pound character # will be used to represent an obstaclewall And a period will be used to represent an open square.
From any open square you can move to an adjacent square no diagonal
Given a starting squarerowcol and an endingtarget squarerowcol you will find the shortest path from the start to the target or report that no path exists.
You will also print one path the shortest path may not be unique using a single quote to retrace the steps. eg:
#################### #### ###### ##### #@##### ###### ###### ###### ####### #####$# ### #################### Shortest Path:
There is simple wellknown algorithm wavefront to follow that uses a queue. The algorithm works as follows:
Initialize a queue with the starting square recording the distance as zero
Repeat until the queue is empty or the target has been reached:
Dequeue a square and recover the distance of that square distance matrixEnqueue unvisited adjacent open squares with distance this will be the minimum distance to the square
Once the target has been found one can retrace the steps back to the start.
From the target find any adjacent square that has distance and repeat until you are at distance zero the start cell
You have to work out some bookkeeping. You will have an array of strings to represent a map. A matrix of integers can be used to track visited squares and the distances. You might initialize all cells of this matrix with as unvisited and then as you enqueue the cell you can update the value with a distance.
When you find the target this will matrix allow you to find the path back to the starting cell. Just follow the bread crumbs.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
