CompSci 307
Fall 2021
Software Design and Implementation

Programming Exercise: Maze Solver

This exercise is intended for you to practice building an inheritance hierarchy and to start learning about organizing OpenJFX's interaction components into different layouts.

It will not be explicitly graded but, instead, serve as a starting point for us to see your coding strengths and weaknesses (and how well you follow directions). Thus, you will get the most out of this assignment by putting in a good faith effort.

Submission

You will be provided a GIT repository, maze_NETID, hosted in the course's Gitlab group to work on this project.

As your submission for this project, use GIT to add, commit, and push the following to your repository:

Your code is expected to follow the course coding conventions and be reasonably commented.

Specifications

Individually, build on the lab exercise to remove as much duplicate code from the SearchAlgorithm subclasses as you believe possible, then add some additional behaviors to the abstraction, and finally provide additional ways to interact with the visualization.

Firstly, as you hopefully noticed, there is a bug in the given code that causes the Magic algorithm to go into an infinite loop when trying to mark the path it followed to solve the maze. Fix the bug and document what you think the problem was (or maybe it was fixed "naturally" through your refactoring during lab) in the README file.

In your quest to factor out the common code in the solvers package classes, you may create additional private or protected methods, levels in the inheritance hierarchy (i.e, more abstract classes), or utility classes that can be used to support multiple search algorithms. Note, an algorithm's data structure is essential to why it works (i.e., a Stack organizes its data completely differently than a Queue or PriorityQueue), so you will not be able to use a single concrete data structure for all the algorithms. However, Java does have a Collection abstraction (of which they are all concrete instances) that may help in storing the data structures in a common variable but, at some point, you will need to call the Stack's push() or pop() method (but, perhaps ideally, that may be the only distinguishing feature of some subclasses).

You are strongly encouraged to write many small methods that clearly identify the general steps of a search algorithm and that can be overridden or shared as needed.

Currently, the SearchAlgorithm abstraction only has one behavior — take a step towards solving the maze. Add public methods for the following behaviors and implement them for all search algorithms without duplicating the code (which may involve adding code only to a superclass, only to concrete subclass(es), or both):

Additionally, the version of the OpenJFX display given in view package of your exercise repository differs from the lab version in that it uses buttons instead of keyboard input to make the possible actions clearly visible to the user. Update the display further to provide buttons for all the actions currently available using keys (i.e., complete the selection of algorithms in the top panel and add pause and step actions in the bottom panel).

After that, add as many of the following interactive elements as you can part depending on your experience, interest, and time (it will not affect your grade):

Keep the display code as clean as possible, rather than assuming that it has to have long methods because "OpenJFX has to be that way" or the code can be repetitious because "it is only called once". The example code in MazeDisplay provides one such way to keep your methods small (but, unless you are careful, it may also encourage you to write duplicated code as you add features).

Resources