MazeSolver. Its constructor should take
a Maze object and a stack, a queue, or a
heap as parameters. The second parameter is where the open list
will be stored. You will need to create an interface to represent open
lists, and this second parameter should have this interface as its type.
Once you have created this interface, you will create three classes that
implement this interface: a stack, a queue, and a heap.
The MazeSolver
should have a method entitled nextStep() that performs one step of
a search algorithm. The MazeSolver will require the following:
Path objects
Path object most
recently retrieved from the open list
Path objects that
have been retrieved from the open list
Path objects that
have been added to the open list
true if the most recently retrieved
Path object reaches the exit of the Maze.
true in the event that no path can be
found. This is the case if the open list is empty.
true if the search is finished. The
search is finished if a path has been found to the exit, or if no such
path exists.
Path consisting
of the entrance square only.
The nextStep() method should do the following:
Path:
Path object with this cell as the final cell in the path.
Then add it to the open list.
main() method for the MazeSolver class.
It should take two command-line arguments: a file containing a
Maze, and the designation of the open list data structure.
Once the Maze and OpenList are
created, create a MazeSolver. Then write a loop that calls
nextStep() repeatedly until the search is finished.
Once the loop finishes, print out whether the search succeeded or failed.
Then print out the Path that was most recently removed from
the open list. Also report the number of nodes retrieved from the open list,
the number of nodes created during the search, and the total length of
the displayed path.
Path nodes in the
heap requires additional effort to specify. Design your heap so that the top
element is the minimum (a "min-heap"). Each element's value is the sum of the
path length and the Manhattan Distance from the end of
the Path to the maze exit.
The Manhattan Distance is the sum of the differences of the x and y coordinates
of two locations. Since this distance precludes the possibility of diagonal
movement, it is named as an analogy for navigating a downtown area.
Write a text document in which you answer the following questions: