Class SearchNode
java.lang.Object
|
+--SearchNode
- All Implemented Interfaces:
- java.lang.Cloneable
- Direct Known Subclasses:
- LightsOutNode, 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).
Created: Fri Feb 2 10:37:23 2001
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 - see Main (pp. |
abstract boolean |
equals(java.lang.Object o)
equals - test for equality. |
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. |
void |
printSearchPath()
printSearchPath - Print the nodes on the path from
the initial search node to this node on separate lines. |
Methods inherited from class java.lang.Object |
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.
isGoal
public abstract boolean isGoal()
isGoal
- test whether or not the current node is a
goal node.
- Returns:
- a
boolean
value
expand
public abstract java.util.Vector expand()
expand
- return a (possibly empty) Vector of this
node's children.
- Returns:
- a
Vector
of SearchNodes
equals
public abstract boolean equals(java.lang.Object o)
equals
- test for equality. This can be
especially useful for repeated state checking in search.
- Overrides:
equals
in class java.lang.Object
- Parameters:
o
- an Object
value- Returns:
- a
boolean
value
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
printSearchPath
public void printSearchPath()
printSearchPath
- Print the nodes on the path from
the initial search node to this node on separate lines.
clone
public java.lang.Object clone()
clone
- see Main (pp. 76-80)
- Overrides:
clone
in class java.lang.Object
- Returns:
- an
Object
value