In this lab you will implement the Expand algorithm that is required by the state space Search algorithm described in State Space Search.

The results of this lab can be incorporated into Assignment 5, which requires an implementation of Search.

Here is a zipped NetBeans project to use for this lab: CS_2511_State_Space_Search.zip.

Unzip this file and open the resulting CS_2511_State_Space_Search NetBeans project.

Three source packages are used by this lab: Verify this code by running the farmer.FarmerConsole class and solving the FWGC problem.

The only class you will modify is framework.Problem.

You will test your modifications by running the ProblemTest class in JUnit.

Your job is to implement and test the Expand algorithm:
   Expand(u)
      children = {}
      for each move ∈ moves do
         child = move.doMove(u)
         if child ≠ null and
            not OccursOnPath(child, u)
            then d[child] = d[u] + 1
                 pred[child] = u
                 add child to children
      return children
        
Expanding a vertex for state space search will be the responsibility of the framework's Problem class.

Since the Expand algorithm requires the OccursOnPath check, implementing and testing Expand is done in two steps:

  1. The OccursOnPath algorithm:
    • Write the Problem.occursOnPath method
    • Comment out the ProblemTest.testExpand method
    • Run the ProblemTest class (which runs the testOccursOnPath method) and hope for no errors
  2. The Expand algorithm:
    • Write the Problem.expand method
    • Uncomment the ProblemTest.testExpand method
    • Run the ProblemTest class (which runs the testOccursOnPath and testExpand methods) and hope for no errors
When finished, zip your project folder as your-login-LEX9.zip.

Email the zip file to your TA.

Successful execution of: