edu.lhup.ai
Interface IBoard

All Known Implementing Classes:
Board

public interface IBoard

The abstract representation of a game. A board keeps track of a stack of moves and changes its internal state as moves are pushed and popped from the stack. The board is also responsible for keeping track of the players that are playing the game and the order in which they take turns.

This software is for educational purposes only.

Author:
Mark Cohen

Method Summary
 IPiece[][] getBoard()
           
 String getDescription()
           
 IPlayer[] getPlayers()
           
 String getShortDescription()
           
 int getState()
           
 IPlayer getWinner()
           
 Iterator moveIterator()
           
 void moves(Collection col)
          Populates the specified Collection with the set of all currently legal moves.
 IMove peekMove()
           
 Iterator playerIterator()
           
 IMove popMove()
          Removes the last move from this board's stack.
 void pushMove(IMove move)
          Adds the specified move to this board's stack.
 void pushMove(String strMove)
          Translates the specified String into a move and then adds that move onto this board's stack.
 void resetState()
          Returns this board to its initial state so it will be ready for a new game.
 void setPlayers(IPlayer[] players)
          Specifies the players that will be playing this game.
 

Method Detail

getBoard

public IPiece[][] getBoard()
Returns:
an array of pieces currently on this board.

pushMove

public void pushMove(String strMove)
              throws StateException
Translates the specified String into a move and then adds that move onto this board's stack.

Parameters:
strMove - a string representation of a move. A move is created based on this string, and that move will be added to the stack.
Throws:
StateException - if the specified move string could not be translated into an IMove object, or the move is illegal.

pushMove

public void pushMove(IMove move)
              throws StateException
Adds the specified move to this board's stack.

Throws:
StateException - if the specified move is illegal.

popMove

public IMove popMove()
              throws StateException
Removes the last move from this board's stack.

Returns:
the move that was removed from the stack.
Throws:
StateException - if the stack is empty.

peekMove

public IMove peekMove()
               throws StateException
Returns:
a reference to the last move that was added to this board's stack,
Throws:
StateException - if the stack is empty.

setPlayers

public void setPlayers(IPlayer[] players)
                throws StateException
Specifies the players that will be playing this game.

Parameters:
players - an array of players that will be playing the game.
Throws:
StateException - if the specified number of type of players cannot play this game.

getPlayers

public IPlayer[] getPlayers()
Returns:
the players currently playing this game.

playerIterator

public Iterator playerIterator()
Returns:
an Iterator of the players currently playing this game. The players will be iterated in the order in which they are allowed to take their turns. The iterator will be empty if this game has ended.

getWinner

public IPlayer getWinner()
Returns:
the player that has won this game, or null if there is currently no winner, or if this game has ended in a tie.

getState

public int getState()
Returns:
a integer representation of this games current state.

resetState

public void resetState()
Returns this board to its initial state so it will be ready for a new game.


moveIterator

public Iterator moveIterator()
Returns:
an Iterator of the set of all currently legal moves.

moves

public void moves(Collection col)
Populates the specified Collection with the set of all currently legal moves.

Parameters:
col - the Collection that will be populated with the set of all currently legal moves.

getDescription

public String getDescription()
Returns:
a description of this board.

getShortDescription

public String getShortDescription()
Returns:
a short description of this player.