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 booleanequals(Object o)Iterable<BoardNode>expand()Expands the search node into successor nodes.ArrayList<Move>fillPath()doublegetCost()MovegetMove()BoardNodegetParent()BoardStategetState()Returns the search state underlying this node.booleanhasGoalState()inthashCode()StringtoString()
-
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-BoardStateassociated with this tree node
-
BoardNode
Primary constructor.- Parameters:
cost- Sunk cost for reaching this state from the rootboard-BoardStateassociated with this tree nodemove-Moveused 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:
getCostin interfaceKnowsOwnCost- Returns:
- The cost of reaching the state in this node.
-
getState
Description copied from interface:SearchTreeNodeReturns the search state underlying this node.- Specified by:
getStatein interfaceSearchTreeNode<BoardNode,BoardState>
-
hasGoalState
public boolean hasGoalState() -
getMove
-
getParent
-
fillPath
-
expand
Description copied from interface:SearchTreeNodeExpands the search node into successor nodes.- Specified by:
expandin interfaceSearchTreeNode<BoardNode,BoardState>- Returns:
- An
Iterableinstance of the successor nodes.
-
toString
-
hashCode
public int hashCode() -
equals
-