# Honors Programming Assignment 3

## Computer Science 102

Spring 2009 Using a GUI to generate a maze and solving it by recursive back-tracking and finding the shortest path to the exit

Due Date: WED April 22, 11:59 pm

Introduction

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. Note now there are four exits and thus four possible solutions; however, your progrm should be written to solve a maze with any number of exits. Solve the maze in a depth-first fashion as shown in class. Number the buttons consecutively as you numbered the cells in the second honors assignment; but now, since you don't know how many exits there are, each cell in the maze should be numbered. The only moves allowed are N, E, S, snd W.

The assignment

• 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 and instructions on how to proceed displayed in the CENTER of the panel. Before the Start button is pushed, the orignal maze with blue and white button should be displayed.
• After the Start button is pushed, the maze display should be the same as described in the Introduction with all the white tiles now coloured yellow and numbered; but now a trace button appears on the EAST of the NORTH panel and instructions on how to proceed is displayed in the CENTER.
• When the trace button is pushed, the tiles on each of the direct paths from the exits to the entrance should be colored with a 200 second pause between colourings. Each path should be displayed in a different colour. These colours should be chosen by a random number generator. Use Thread.sleep() to generate the pause. As each path is traversed, a separate 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 using N, E, S, and W to indicate the directions. I used the API LinkedList class to generate these linked lists.
• As each path is completed, the first node of the linked list describing the path should become the info field of a singly-linked list.
• When all the paths have been coloured, the lengths of each path should be displayed on the NORTH panel and then after a pause, the shortest path(s) from the entrance to the exit(s) should be coloured white, again with a pause between colourings.

Getting the pause to work is tricky. You have to have a separate thread for the trace process. Nest this in the if statement detecting an action in the actionPerformed() method.

Samuel Marateck
SAT MAR 29 22:23:14 EST 2009