Class PuzzleState
java.lang.Object
topics.branchandbound.utils.Node
topics.branchandbound.eightpuzzle.PuzzleState
- All Implemented Interfaces:
Comparable<Node>
Represents a distinct physical configuration of the board within the execution tree. It calculates heuristic bounds and generates topologically valid child states.
*Complexity
- Time Complexity:
O(bd)- Where b is the branching factor (average 3 valid moves) and d is the depth of the optimal solution. The heuristic severely prunes unpromising branches. - Space Complexity:
O(b × d)- Dictated by the nodes residing in the priority queue waiting to be evaluated.
-
Field Summary
Fields inherited from class Node
depth, heuristicValue, id, parentId -
Constructor Summary
ConstructorsConstructorDescriptionPuzzleState(int[] board, HeuristicType heuristicType, int depth, UUID parentID) Constructs a child node representing a subsequent move.PuzzleState(HeuristicType heuristicType, int[] board) Constructs the root node of the state space tree. -
Method Summary
Methods inherited from class Node
compareTo, equals, getDepth, getHeuristicValue, getId, getParentId, hashCode, initialValuePruneLimit
-
Constructor Details
-
PuzzleState
Constructs the root node of the state space tree.- Parameters:
heuristicType- The heuristic function applied to evaluate paths.board- The initial state of the puzzle.
-
PuzzleState
Constructs a child node representing a subsequent move.- Parameters:
board- The state of the board after the move.heuristicType- The heuristic function to evaluate the state.depth- The current depth level in the execution tree.parentID- The unique identifier of the preceding state.
-
-
Method Details
-
expand
-
calculateHeuristicValue
public void calculateHeuristicValue()Computes the lower-bound heuristic value. Applies mathematical pruning by evaluating inversion parity to instantly discard unsolvable configurations.- Specified by:
calculateHeuristicValuein classNode
-
isSolution
public boolean isSolution()Description copied from class:NodeDetermines whether the current node represents a fully resolved configuration satisfying all problem constraints.- Specified by:
isSolutionin classNode- Returns:
trueif the state is a complete mathematical solution;falseotherwise.
-
toString
-