# Honors Programming Assignment 2

## Computer Science 102

Spring 2008 Using a GUI to display a maze and solving it by recursive back-tracking

Part A Due Date: WED MAR 26, 11:59 pm

Part B Due Date: SAT MAR 29, 11:59 pm

Part a

Use the maze in the following link to generate a maze with blue and white buttons, where the blue ones represent the walls and the white ones, the possible path.

• Place the maze on a panel in the CENTER of the BorderLayout. Place a panel on the NORTH of the BorderLayout with a Start button on the WEST of that panel, instructions on how to proceed displayed in the CENTER of the panel and Trace button on the EAST. Before the Start button is pushed, the orignal maze with blue and white button should be displayed, and instructions on how to proceed is displayed in the CENTER of the NORTH panel.
• After the Start button is clicked the maze should be solved recursively in a depth-first fashion as shown in class. Number the buttons consecutively as you numbered the cells in the first honors assignment. The only moves allowed are N, E, S, snd W. After the maze is solved, a Trace button should appear on the EAST side of the panel.
• Each time the Trace button is clicked it should drive the movement of the tile one unit on the direct path to the exit, coloring the tiles pink as you go. Or, if you wish, when the Trace button is clicked, the tiles on the path to the exit should turn pink, one at a time with a pause between the tiles being coloured.

Part b

• After the Start button is pushed, the maze display should be the same as in part a with the buttons used in the depth-first search numbered.
• When the trace button is clicked once, the buttons on the direct path to the exit should be colored pink with a 200 second pause between colorings. Use Thread.sleep() to do this. As this path is traversed, a doubly-linked list with the steps should be generated as in the second regular assignment (0 should represent a move north; 1, south, etc.) and the path should be displayed on the NORTH panel.
• When the exit is reached, your program should remove the trace button -- use remove(trace) dereferencing the NORTH panel to do this -- and insert a retrace button in its place. The message on the panel should now indicate what to do next. When the retrace button is pushed, the path to the entrance should be retraced using the same technique as in the previous step.

Use the same technique you used in the second regular assignment to pause as the maze is traversed. You have to have a separate thread for the trace process and one for the retrace process. Nest these in the if statements detecting an action in the actionPerformed() method.

Samuel Marateck
SAT MAR 8 22:23:14 EST 2008