GUI Maze Solver

Objectives

Overview

Prerequisite

You should use your source files from the maze creation assignment: Board.java, Cell.java, Direction.java, and Maze1.java. If you do not have them completed, then you can download compiled versions of those classes here: GUIMazeBaseClasses.zip. Just extract the class files into the same directory where you will be creating your graphical maze solver. The graphical maze solver must be named: GUIMaze.java

Source files (classes)

Maze1 changes

MazeCell

This will be a subclass of JLabel with additional support for coloring the cell and showing borders where there are walls present. It should get a reference to the Cell object it represents to set up the borders - but it does not need to retain that reference.

GUIMaze

This is the workhorse of today's project. It has to create the GUI interface and it also contains the thread that will be used to solve the maze. The suggested API is listed below:

GUIMaze GUI mockup

GUIMaze mockup

Solver class and algorithm

This class should have two constructors (one default and one which accepts a delay time). It should implement Runnable (act as a thread) with the run method using the following algorithm:

set all cells to unvisited
set the start cell to visited, color it as a terminal cell, and push it onto the stack
set solved to false
while not solved do the following
    get a list of the unvisited connected neighbors of the top cell on the stack
    if the list is empty then
        pop the cell from the stack and color it plain (not part of solution)
    otherwise
        pick one of the neighbors at random from the list
        push it onto the stack
        if it is not the start or end cell then
            color it as part of the solution
            set it to visited
        if it is the end cell then set solved to true
    delay