Interface PuzState


public interface PuzState

Interface for a generic "state" node for use by a heuristic search routine. This interface is intended to represent a PUZZLE STATE along with all of its cost and heuristic information. The model is that to implement different heuristics, it's simply necessary to override heuristic(). In one architecture, then, an implementing PUZZLE would provide an abstract class that implements the core functionality of the puzzle mechanics, state, rules, next state function, etc. and then a series of concrete sub-classes that actually instantiate different heuristics.

This class provides direct access to the parent state that generated a particular node; the designer may also wish to provide access to some representation of the move that generated this state.


Method Summary
 java.util.Iterator children()
          Return an iterator over the children of the current node.
 double distFromStart()
          Return the distance from the start state.
 boolean goalP()
          Tests whether the current node is a goal state or not.
 double heuristic()
          Return heuristic estimate of the value of this node.
 PuzState parent()
          Retrieve the parent of the current node.
 void setDistFromStart(double d)
          Set or reset the cost-from-start value for the current node.
 

Method Detail

heuristic

public double heuristic()
Return heuristic estimate of the value of this node. This function should provide the combined "cost-so-far" function with the "estimated cost-to-goal" function, h(). That is, this represents the complete function f(s)=g(s)+h(s) from the lecture's notation.

To provide different search strategies, override this function with different heuristic estimates.

Returns:
The total function representing cost-from-start plus estimated cost-to-goal.

distFromStart

public double distFromStart()
Return the distance from the start state. Required to be non-negative and identically 0 for a start state. May be 0 if unimplemented in some deriving class. This is g(s) from the lectures's notation.

Note that this represents only the distance along the path by which this particular instance node was generated; it's possible to generate the same node along different paths, all of which may have different cost-from-start's.

Returns:
The recorded cost-from-start function for this node, along the path that generated it.

setDistFromStart

public void setDistFromStart(double d)
Set or reset the cost-from-start value for the current node. This is intended to be used when re-ordering a previously existing node.

Parameters:
d - New value for the cost-from-start function (g(s)) for this node.

goalP

public boolean goalP()
Tests whether the current node is a goal state or not.

Returns:
true if this state is a goal state, else false.

children

public java.util.Iterator children()
Return an iterator over the children of the current node. If no children are available, the iterator should simply return false for hasNext(). The returned iterator may or may not produce the "parent" state of the current node, at the designer's choice.

Returns:
Iterator over the children state of this node.

parent

public PuzState parent()
Retrieve the parent of the current node. This should return a reference to the node that created this node via some action. If this node is parentless (e.g., is the START node), this should return null

Returns:
parent pointer for this node, or null for the root node.