Package rushhour
Class BoardNode
java.lang.Object
rushhour.BoardNode
- All Implemented Interfaces:
KnowsOwnCost
,SearchTreeNode<BoardNode,BoardState>
public class BoardNode extends Object implements SearchTreeNode<BoardNode,BoardState>, KnowsOwnCost
Search tree node for building RushHour solution move sequences.
-
Constructor Summary
Constructors Constructor Description BoardNode(double cost, BoardState board, Move move, BoardNode parent)
Primary constructor.BoardNode(BoardState board)
Convenience constructor for a root tree node. -
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
Iterable<BoardNode>
expand()
Expands the search node into successor nodes.ArrayList<Move>
fillPath()
double
getCost()
Move
getMove()
BoardNode
getParent()
BoardState
getState()
Returns the search state underlying this node.boolean
hasGoalState()
int
hashCode()
String
toString()
-
Constructor Details
-
BoardNode
Convenience constructor for a root tree node. The parent is taken to be null, the last move isNONE
, and the sunk cost is zero.- Parameters:
board
-BoardState
associated with this tree node
-
BoardNode
Primary constructor.- Parameters:
cost
- Sunk cost for reaching this state from the rootboard
-BoardState
associated with this tree nodemove
-Move
used to arrive in this state from the parent tree's stateparent
- Parent node in the search tree
-
-
Method Details
-
getCost
public double getCost()- Specified by:
getCost
in interfaceKnowsOwnCost
- Returns:
- The cost of reaching the state in this node.
-
getState
Description copied from interface:SearchTreeNode
Returns the search state underlying this node.- Specified by:
getState
in interfaceSearchTreeNode<BoardNode,BoardState>
-
hasGoalState
public boolean hasGoalState() -
getMove
-
getParent
-
fillPath
-
expand
Description copied from interface:SearchTreeNode
Expands the search node into successor nodes.- Specified by:
expand
in interfaceSearchTreeNode<BoardNode,BoardState>
- Returns:
- An
Iterable
instance of the successor nodes.
-
toString
-
hashCode
public int hashCode() -
equals
-