Package jadex.bdi.puzzle
Class Board
java.lang.Object
jadex.bdi.puzzle.Board
- All Implemented Interfaces:
IBoard
,Serializable
The board containing places, pieces and played moves.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a PropertyChangeListener to the listener list.Get the current board position.Get all moves made so far.getMoves()
Get all moves made so far.Get a piece for a location.Get possible moves.int
getSize()
Get the board size.boolean
isFreePosition
(Position pos) Test if aposition is free.protected boolean
isPossibleMove
(Move move) Get a piece for a location.boolean
Test if it is a solution.static void
Main for testing.boolean
Do a move.void
Remove a PropertyChangeListener from the listener list.boolean
takeback()
Takeback a move.boolean
Test if the last move was with a white piece.
-
Field Details
-
moves
The moves. -
pieces
The pieces. -
size
protected int sizeThe size. -
hole_pos
The hole position. -
pcs
The helper object for bean events.
-
-
Constructor Details
-
Board
public Board()Create a new board. -
Board
public Board(int size) Create a new board.
-
-
Method Details
-
getPiece
Get a piece for a location. -
getPossibleMoves
Get possible moves.- Specified by:
getPossibleMoves
in interfaceIBoard
- Returns:
- Get all possible move.
-
move
Do a move. -
takeback
public boolean takeback()Takeback a move. -
isSolution
public boolean isSolution()Test if it is a solution.- Specified by:
isSolution
in interfaceIBoard
- Returns:
- True, if solution.
-
getMoves
Get all moves made so far. -
getLastMove
Get all moves made so far.- Specified by:
getLastMove
in interfaceIBoard
-
wasLastMoveWhite
public boolean wasLastMoveWhite()Test if the last move was with a white piece. When no move was made, it return true.- Specified by:
wasLastMoveWhite
in interfaceIBoard
- Returns:
- True, is last move was with white piece.
-
isFreePosition
Test if aposition is free.- Specified by:
isFreePosition
in interfaceIBoard
-
isPossibleMove
Get a piece for a location. -
getSize
public int getSize()Get the board size. -
getCurrentPosition
Get the current board position.- Specified by:
getCurrentPosition
in interfaceIBoard
-
addPropertyChangeListener
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Specified by:
addPropertyChangeListener
in interfaceIBoard
- Parameters:
listener
- The PropertyChangeListener to be added.
-
removePropertyChangeListener
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Specified by:
removePropertyChangeListener
in interfaceIBoard
- Parameters:
listener
- The PropertyChangeListener to be removed.
-
main
Main for testing.
-