Class SearchNode
java.lang.Object
|
+--SearchNode
- All Implemented Interfaces:
- java.lang.Cloneable
- Direct Known Subclasses:
- BucketsNode, PegSolitaireNode
- public abstract class SearchNode
- extends java.lang.Object
- implements java.lang.Cloneable
SearchNode.java - a simple node for uninformed AI search (assuming
cost equals depth).
Field Summary |
int |
depth
variable depth - search depth; 0 at the root
search node; a child node has its parent node depth + 1. |
SearchNode |
parent
variable parent - parent search node; null if and
only if node is the root of the search tree. |
Constructor Summary |
SearchNode()
Creates an SearchNode instance and sets it to an
initial search state. |
Method Summary |
SearchNode |
childClone()
childClone - returns a clone of this node that has
been made a child of this node and has a depth one greater than
this. |
java.lang.Object |
clone()
clone - performs a DEEP clone (copy) of this
node. |
abstract java.util.Vector |
expand()
expand - return a (possibly empty) Vector of this
node's children. |
abstract boolean |
isGoal()
isGoal - test whether or not the current node is a
goal node. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parent
public SearchNode parent
- variable
parent
- parent search node; null if and
only if node is the root of the search tree.
depth
public int depth
- variable
depth
- search depth; 0 at the root
search node; a child node has its parent node depth + 1.
SearchNode
public SearchNode()
- Creates an
SearchNode
instance and sets it to an
initial search state. One will generally want to override this
constructor to initialize a root node for search.
isGoal
public abstract boolean isGoal()
isGoal
- test whether or not the current node is a
goal node.
- Returns:
- a
boolean
value - whether or not the
current node is a goal node
expand
public abstract java.util.Vector expand()
expand
- return a (possibly empty) Vector of this
node's children. A new child is created by calling
childClone
and appropriately modifying the state
of the returned node.
- Returns:
- a
Vector
of SearchNodes that are children
of this node
childClone
public SearchNode childClone()
childClone
- returns a clone of this node that has
been made a child of this node and has a depth one greater than
this.
- Returns:
- a
SearchNode
value
clone
public java.lang.Object clone()
clone
- performs a DEEP clone (copy) of this
node. That is, any change to the original/cloned node should
have no side-effect on the other. For example, when the node's
state is described using an array, you must create a new array
for the cloned node and copy the contents of the original node
array.
- Overrides:
clone
in class java.lang.Object
- Returns:
- an
Object
value