CSC220 Lab Number 7
Due: 11:59PM, Tuesday, October 27
The goal of this lab is to develop a program that solves a maze. The program takes as input the dimension of the maze, randomly generates a maze of the given dimension, and shows the trace of search. If the maze is threadable then it shows the direction of the path using characters '^', '>', 'v', and '<' for N, E, S, and W, respectively. The wall on the maze is specified using 'o' while the cell that can be stepped in using the space character. If a cell turns out to be a dead end during the search, it is shown as '@'.
Download a java file 'SimpleMaze.java'.
The basic infrastructure
is there but the method solve has to be written, which attempts
solves the maze. Each row of the maze is represented using a character
array and the maze itself using an ArrayList
The program must return whether the maze is threadable or not and record on the maze itself, what the path is and which cells are found to be dead end. The program must be written using recursive calls. In designing recursive calls, you must use the "left-hand rule", which is to keep your left hand always on the wall.
A sample program is lab07.jar.
To run the program, open a console window and type
java -jar lab07.jar