In this assignment you will extend your ProblemSolver framework for automated problem solving. You will proceed in two general stages, corresponding to the framework's Model and its View: There also will be extra credit available.
First, be sure that your ProblemSolver framework is up to date with all of the additions required by Assignment 4 on Graphical User Interfaces and the Lab Exercises 8 and 9 on Graphs. The assignment and labs are accessible from the menu at left.

If your ProblemSolver meets their requirements, you can continue with the following steps.

For extra credit, implement the 15-Puzzle and successfully pass its eight benchmarks (these are discussed in the State Space Search and Informed Search lectures.

Here is a GUI showing the eighth benchmark, a 54-move problem solved optimally in 55 seconds on an Intel i5 CPU @ 2.20GHz × 4:

Now that your problem solver works correctly, you will add these controls and their requirements to your current graphical user interface (GUI): Below is a possible layout for the FWGC problem. Note: You need not copy this layout exactly; you can style and position the controls however you like.

This section describes the behavior of the new controls.
Clicking Solve causes the following: In the example below the user has clicked Solve in the problem's start state:

Clicking Next causes the following: In the example below the user has stepped through the solution by clicking Next seven times:

The Reset button is always enabled. Clicking Reset causes the following: In the example below the user has clicked Reset after stepping through a generated solution:

Below is a GUI for the 8-puzzle. Note that benchmark options are visible. The options are labeled with the benchmark name and minimum number of moves required.

The benchmark names and minimum solution lengths are obtained from the Problem object for the GUI.

Here the user has partially (manually) solved benchmark "8-Puz 1" and is about to select the benchmark "8-Puz 7":

When the user changes benchmarks: Here the user has completed the selection of benchmark "8-Puz 7":

Here the user has switched to A* search and clicked Solve. Note that benchmark selection is disabled while the user steps through the solution.

This step requires you to provide the constructor for the AStarSolver class. However, this constructor is just a slight modification of the BestFirstSolver constructor, as described in the Informed Search lecture.

The files are available under Files in the menu.

After adding these, your Source Packages and Test Packages should look as shown here:

     

Complete the AStarSolver constructor and run the AStarSolverTest.java file. You should get the results shown below.

This step does not require any new code. The files are available under Files in the menu. After adding these, your Source Packages and Test Packages should look as shown here:

     

Run the BestFirstSolverTest.java file. You should get results similar to those shown below.

Add the code below to your PuzzleState class and complete the tilesOutOfPlace and sumManhattan methods.

8-puzzle heuristics are discussed in the Informed Search lecture under 8-Puzzle Heuristic and Comparing Heuristics.

To test your 8-puzzle heuristics, add the PuzzleHeuristicTest.java class, available under Files in the menu, to the domains.puzzle class under Test Packages:

Running the PuzzleHeuristicTest.java class should produce:

The expand method in Solver.java is abstract. GraphSolver, which extends Solver, provides an implementation of expand that simply returns a vertex's adjacency list in a graph representation of the problem.

In general, expand(u) simply returns a list of vertices that are one move away from u in the problem's state space.

In this step, you will extend Solver with a StateSpaceSolver class that implements expand without a graph representation.

Add the StateSpaceSolver.java class, available under Files in the menu, to your framework.solution package:

StateSpaceSolver requires that you implement the expand method, which you should do now.

The lecture on State Space Search describes how to use the problem's Mover object to accomplish this.

StateSpaceSolver, like GraphSolver, is an abstract class with two subclasses, BFSStateSpaceSolver and DFSStateSpaceSolver, that perform breadth-first and depth-first searches of the problem state space, respectively.

Add these subclasses, which are complete and available from the menu, to framework.solution:

The test of the state space solver is similar to that for the graph solver.

Add the StateSpaceSolverTest.java class, available from the menu, to your Test Packages:

Run the StateSpaceSolverTest.java class, which is similar to the GraphSolverTest.java class and will get similar results. However, since it does not have to create graphs, it is faster:

In testing your search, you may encounter Out of Memory errors. Here are some possible causes:
Add the Statistics.java class (available under Files in the menu) to your framework.solution package:

Statistics.java is complete.

Add the abstract Solver.java class (available under Files in the menu) to your framework.solution package:

Solver.java is complete except for the search method, which you should implement now.

The search method and the algorithm it implements are described in detail in the State Space Search lecture.

Test your search method by extending Solver for graph search. This involves adding the files below to your framework. They are complete and available under Files in the menu. After adding these, your Source Packages and Test Packages should look as shown here:

     

Run the GraphSolverTest.java file. You should get the results shown below. Since the tests run through the 8-puzzle benchmarks, the test could take 10-20 seconds.

BestFirstSolverTest.java should be added to the framework.solution package under Test Packages.

AStarSolverTest.java should be added to the framework.solution package under Test Packages.

PuzzleHeuristicTest.java should be added to the domains.puzzle package under Test Packages.

The lecture presentations on State Space Search and Informed State Space Search, in the menu at left, are directly relevant to this assignment.
The previous assignment on Graphical User Interfaces, in the menu at left, is directly relevant to this assignment.
The previous labs exercises on Graphs, in the menu at left, are directly relevant to this assignment.
As with the previous assignment, Note the general Submission Policy in the menu at left.

Your project will be inspected, tested, and run by the lab instructor. Grading criteria: