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 TypeMethodDescriptionvoidAdd 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.intgetSize()Get the board size.booleanisFreePosition(Position pos) Test if aposition is free.protected booleanisPossibleMove(Move move) Get a piece for a location.booleanTest if it is a solution.static voidMain for testing.booleanDo a move.voidRemove a PropertyChangeListener from the listener list.booleantakeback()Takeback a move.booleanTest 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:
getPossibleMovesin 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:
isSolutionin interfaceIBoard- Returns:
- True, if solution.
-
getMoves
Get all moves made so far. -
getLastMove
Get all moves made so far.- Specified by:
getLastMovein 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:
wasLastMoveWhitein interfaceIBoard- Returns:
- True, is last move was with white piece.
-
isFreePosition
Test if aposition is free.- Specified by:
isFreePositionin interfaceIBoard
-
isPossibleMove
Get a piece for a location. -
getSize
public int getSize()Get the board size. -
getCurrentPosition
Get the current board position.- Specified by:
getCurrentPositionin interfaceIBoard
-
addPropertyChangeListener
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Specified by:
addPropertyChangeListenerin 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:
removePropertyChangeListenerin interfaceIBoard- Parameters:
listener- The PropertyChangeListener to be removed.
-
main
Main for testing.
-