Class Board

java.lang.Object
jadex.bdi.puzzle.Board
All Implemented Interfaces:
IBoard, Serializable

public class Board extends Object implements IBoard, Serializable
The board containing places, pieces and played moves.
See Also:
  • Field Details

    • moves

      protected ArrayList moves
      The moves.
    • pieces

      protected HashMap pieces
      The pieces.
    • size

      protected int size
      The size.
    • hole_pos

      protected Position 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

      public Piece getPiece(Position pos)
      Get a piece for a location.
      Specified by:
      getPiece in interface IBoard
    • getPossibleMoves

      public List getPossibleMoves()
      Get possible moves.
      Specified by:
      getPossibleMoves in interface IBoard
      Returns:
      Get all possible move.
    • move

      public boolean move(Move move)
      Do a move.
      Specified by:
      move in interface IBoard
      Parameters:
      move - The move.
    • takeback

      public boolean takeback()
      Takeback a move.
      Specified by:
      takeback in interface IBoard
    • isSolution

      public boolean isSolution()
      Test if it is a solution.
      Specified by:
      isSolution in interface IBoard
      Returns:
      True, if solution.
    • getMoves

      public List getMoves()
      Get all moves made so far.
      Specified by:
      getMoves in interface IBoard
    • getLastMove

      public Move getLastMove()
      Get all moves made so far.
      Specified by:
      getLastMove in interface IBoard
    • 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 interface IBoard
      Returns:
      True, is last move was with white piece.
    • isFreePosition

      public boolean isFreePosition(Position pos)
      Test if aposition is free.
      Specified by:
      isFreePosition in interface IBoard
    • isPossibleMove

      protected boolean isPossibleMove(Move move)
      Get a piece for a location.
    • getSize

      public int getSize()
      Get the board size.
      Specified by:
      getSize in interface IBoard
    • getCurrentPosition

      public List getCurrentPosition()
      Get the current board position.
      Specified by:
      getCurrentPosition in interface IBoard
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a PropertyChangeListener to the listener list. The listener is registered for all properties.
      Specified by:
      addPropertyChangeListener in interface IBoard
      Parameters:
      listener - The PropertyChangeListener to be added.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
      Specified by:
      removePropertyChangeListener in interface IBoard
      Parameters:
      listener - The PropertyChangeListener to be removed.
    • main

      public static void main(String[] args)
      Main for testing.