Base code ready for copying | Mon, Oct 20 | Should be ready by 6:00 pm |
Phase B "donut-ready" checkin | Mon, Oct 27 | Electronic turnin by 11:00pm |
Phase B Writeup | Wed, Oct 29 | Beginning of Lecture; see printing guidelines |
For the second phase of this project, we are providing code to read the input maze given as a text file, parse it, and build a Maze class object from it, which your algorithm will operate on. We are also providing the code for a simple maze runner, RandomMazeRunner, that picks the direction to explore in a random fashion. Your own MazeRunner classes should inherit from the abstract MazeRunner class. You may modify the provided code if you wish, but very little (if any) should be necessary, and you should justify any modifications in your README.
The provided code is located in the directory /cse/courses/cse326/03au/projects/project2/code-phaseB/. You can copy these files when logged on to the instructional unix server attu. You will want to add to it all of the code from Phase A, including your changes.
Further documentation on the Maze code architecture and how to get
started can be found here. If you find
the large codebase a bit overwhelming, this is good place to start.
Note: for the basic requirements of the project, you should
not have to read every line of the code, particularly the parts
that parse the input or perform visual displaying or implement the
details of a MazeCell.
VIII. Maze Input and Output
INPUT: The SquareCellMazeFactory class reads a maze
from a text file specified on the command prompt. The file format is
a picture of the maze. There is also some header information at the
front that gives the dimensions of the maze (height, then width). In
the maze, '-
' and '|
' are used for walls,
'
' for rooms and unblocked passages, '+
'
for the corners of the rooms, '*
' for the entrance, and
'X
' for the exit. For example, the following is a legal
maze:
7 5 +-+-+-+-+-+-+-+ |*| | | | | + +-+ + + +-+ + | | | | + + + +-+ +-+ + | | | | | + +-+-+ +-+-+ + | | | +-+ + +-+-+ +-+ | | X| +-+-+-+-+-+-+-+
There are some sample input files in the course project directory mentioned above that you can use to test your program. You are highly encouraged to write (and share with your classmates!) other test mazes to run your MazeRunner on. Send them to us or to the class discussion list.
OUTPUT: After solving a maze, your MazeRunner should output a solution path calculated by the search. The path should be given on a single line and should consist of the printed locations (using the built-in print method) from the start to the exit, separated by single spaces. On the next line should be the length of the solution path, and on the following line should be the number of nodes visited and expanded in the search. The solution should be preceeded by a line giving the name of the search algorithm used. For example, the output for the above maze might be:
Random Search (0,0) (0,1) (0,2) (0,3) (1,3) (2,3) (2,4) (3,4) (4,4) (4,5) (4,6) 10 15
The solution displayed above corresponds to the solution path shown below with dots:
+-+-+-+-+-+-+-+ |*| | | | | +.+-+ + + +-+ + |. | | | +.+ + +-+ +-+ + |.| | | | +.+-+-+ +-+-+ + |..... | | +-+ +.+-+-+ +-+ | |........X| +-+-+-+-+-+-+-+Note that your MazeRunner does not need to output a text-graphical solution such as the one displayed above.
Note also that a search very likely involves visiting many nodes
that are not on the final solution path. You will have to explore
ways of extracting the path from the collection of nodes you visited.
RandomMazeRunner gives an example of how this might be done.
You will need to modify this technique to work for your algorithms.
IX. Getting Started
After combining your code from Phase A and the new provided code for Phase B, compile everything and try to run the provided random mazeRunner from the launcher class as follows:
% java MazeRunnerLauncher -r maze0.txtThe "-r" option invokes the random maze runner. Take a look at RandomMazeRunner.java to get a general idea of how things work. After understanding this file, make a copy (say BFSMazeRunner.java) and try implementing a better algorithm.
% java MazeRunnerLauncher -r -v -t -p 800 mazefile
The "-v" option turns on the visualizer, "-t" prints out some tracing information, and "-p" tells the algorithm to wait for a specified time after processing each step. You can choose any (or no) options to use, but you must provide them in this order. For your maze runners and any Above and Beyond stuff you implement, add more options to MazeRunnerLauncher.java to invoke the appropriate code.
Try using the visualizer with the random solver so you can see how it works. In your own MazeRunner, you will need to call setCellState() in MazeCell to make the colors change. There may be some flexibility in when exactly to change the colors relative to the algorithm's progress; you can make the exact determination of how to do this provided you follow the basic algorithm.
You can run the visualizer either under Windows or from UNIX. If
running under UNIX, make sure ReflectionX is running and that your
display is set up properly. If you can start emacs in a separate
window (i.e., run emacs & successfully), that is good enough.
XI. Detailed Requirements
You are expected to turn in all your code by 11:00 pm on the
deadline mentioned at the top of this page. Use the turnin
utility to submit your project. This
project is called "project2B" in the turnin system.
Required Above and Beyond Extension
For ths assignment, beyond the basic requirements, you must
implement one Above and Beyond extension. You may choose any of the
listed extensions or try to come up with one yourself (please contact
the course staff first to make sure your extension is within the
workload we are expecting you to have in this assignment).
Electronic Turnin
Include the following files plus any others you find necessary:
Your README should contain the following information:
Answer the following questions:
The amount of code required for this project is actually very
small. A significant part of your grade will be based on your program
design and your README. Be sure to review the grading
guidelines and devote appropriate portion of your effort on
correctness (40%), architecture and documentation (30%), and README
(30%).
XIII. Going Above and Beyond
The following suggestions are meant for you to try if you finish the requirements early. They will be worth a nominal amount of extra credit. Be sure to clearly describe what you did and how to run it in your README.
Only one person from each team should submit. The same person who submitted Phase A should submit Phase B. Follow the normal turnin procedures, using the name "project2B" for this turn-in. You should submit:
For the hardcopy, please place the README file in front, and include any code that you have written or modified. You do not have to hand in printouts of files that we provided that you did not modify (eg. MazeRunner.java). Also, please be sure to follow the printing instructions as this ensures a consistent style for the TAs to grade.