Class ReadOnlySpinHexModelWrapper
java.lang.Object
spinhex.model.SpinHexModel
spinhex.model.ReadOnlySpinHexModelWrapper
- All Implemented Interfaces:
common.State<TwoPhaseActionState.TwoPhaseAction<AxialPosition, Rotation>>
,Cloneable
,puzzle.State<TwoPhaseActionState.TwoPhaseAction<AxialPosition, Rotation>>
,TwoPhaseActionState<AxialPosition, Rotation>
A read-only wrapper for the SpinHex model that provides access to the board
properties without allowing modifications.
This class extends the SpinHexModel and provides a read-only view of the board, allowing access to hex values at specific axial coordinates.
-
Nested Class Summary
Nested classes/interfaces inherited from interface spinhex.model.TwoPhaseActionState
TwoPhaseActionState.TwoPhaseAction<T,
U> -
Field Summary
Fields inherited from class spinhex.model.SpinHexModel
ADJACENT_DIRECTIONS, board
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a read-only wrapper for a SpinHex model with the default board.ReadOnlySpinHexModelWrapper
(byte[][] startingBoard, byte[][] targetBoard) Constructs a read-only wrapper for a SpinHex model with the specified starting and target boards. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyIntegerProperty
getHexProperty
(int q, int s) Returns a read-only property for the hex at the specified axial coordinates.void
makeMove
(TwoPhaseActionState.TwoPhaseAction<AxialPosition, Rotation> moveAction) Makes a move in the SpinHex model and updates the property model accordingly.Methods inherited from class spinhex.model.SpinHexModel
clone, equals, getBoard, getBoardSize, getHex, getLegalMoves, getNeighbors, getSolution, hashCode, isLegalMove, isLegalToMoveFrom, isSolved, toString
-
Constructor Details
-
ReadOnlySpinHexModelWrapper
public ReadOnlySpinHexModelWrapper()Constructs a read-only wrapper for a SpinHex model with the default board. Initializes the board properties to reflect the current state of the board. -
ReadOnlySpinHexModelWrapper
public ReadOnlySpinHexModelWrapper(byte[][] startingBoard, byte[][] targetBoard) Constructs a read-only wrapper for a SpinHex model with the specified starting and target boards.- Parameters:
startingBoard
- The initial state of the board as a 2D byte arraytargetBoard
- The target state of the board as a 2D byte array
-
-
Method Details
-
getHexProperty
public javafx.beans.property.ReadOnlyIntegerProperty getHexProperty(int q, int s) Returns a read-only property for the hex at the specified axial coordinates.- Parameters:
q
- The q-coordinate of the hexs
- The s-coordinate of the hex- Returns:
- A read-only integer property representing the hex value
-
makeMove
Makes a move in the SpinHex model and updates the property model accordingly.- Specified by:
makeMove
in interfacecommon.State<TwoPhaseActionState.TwoPhaseAction<AxialPosition, Rotation>>
- Overrides:
makeMove
in classSpinHexModel
- Parameters:
moveAction
- The move action to perform.
-