|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
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 |
public double heuristic()
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.
public double distFromStart()
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.
public void setDistFromStart(double d)
d - New value for the cost-from-start function
(g(s)) for this node.public boolean goalP()
true if this state is a goal state, else
false.public java.util.Iterator children()
false for hasNext(). The returned
iterator may or may not produce the "parent" state of the current
node, at the designer's choice.
public PuzState parent()
null
null for the
root node.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||