public class Board extends java.lang.Object implements IBoard, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
Position |
hole_pos
The hole position.
|
protected java.util.ArrayList |
moves
The moves.
|
jadex.commons.SimplePropertyChangeSupport |
pcs
The helper object for bean events.
|
protected java.util.HashMap |
pieces
The pieces.
|
protected int |
size
The size.
|
| Constructor and Description |
|---|
Board()
Create a new board.
|
Board(int size)
Create a new board.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
|
java.util.List |
getCurrentPosition()
Get the current board position.
|
Move |
getLastMove()
Get all moves made so far.
|
java.util.List |
getMoves()
Get all moves made so far.
|
Piece |
getPiece(Position pos)
Get a piece for a location.
|
java.util.List |
getPossibleMoves()
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 |
isSolution()
Test if it is a solution.
|
static void |
main(java.lang.String[] args)
Main for testing.
|
boolean |
move(Move move)
Do a move.
|
void |
removePropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
|
boolean |
takeback()
Takeback a move.
|
boolean |
wasLastMoveWhite()
Test if the last move was with a white piece.
|
protected java.util.ArrayList moves
protected java.util.HashMap pieces
protected int size
public Position hole_pos
public jadex.commons.SimplePropertyChangeSupport pcs
public Board()
public Board(int size)
public java.util.List getPossibleMoves()
getPossibleMoves in interface IBoardpublic boolean move(Move move)
public boolean isSolution()
isSolution in interface IBoardpublic java.util.List getMoves()
public Move getLastMove()
getLastMove in interface IBoardpublic boolean wasLastMoveWhite()
wasLastMoveWhite in interface IBoardpublic boolean isFreePosition(Position pos)
isFreePosition in interface IBoardprotected boolean isPossibleMove(Move move)
public java.util.List getCurrentPosition()
getCurrentPosition in interface IBoardpublic void addPropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface IBoardlistener - The PropertyChangeListener to be added.public void removePropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface IBoardlistener - The PropertyChangeListener to be removed.public static void main(java.lang.String[] args)