org.jscience.computing.game.chess
Class ChessGame

java.lang.Object
  extended by org.jscience.computing.game.AbstractGame
      extended by org.jscience.computing.game.chess.ChessGame
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, GamePlay

public class ChessGame
extends AbstractGame

ChessGame provides all external functions needed to play chess. It contains a ChessBoard which represents the game status. It overwrites equals() and hashCode() to properly support serialized games.

See Also:
Serialized Form

Constructor Summary
ChessGame()
          Creates a new ChessGame object.
ChessGame(java.lang.String name)
          Creates a new ChessGame object.
 
Method Summary
 java.lang.Object clone()
          DOCUMENT ME!
 boolean equals(java.lang.Object obj)
          This implementation of equals() does currently not care about the move history, it only considers the state of the board.
 boolean gameOver()
          Current limitations: gameOver() doesn't currently check for things like insufficient material for checkmate or 3rd repititions.
 org.jscience.computing.game.chess.ChessBoard getBoard()
          DOCUMENT ME!
 int[] getWinner()
          DOCUMENT ME!
 int hashCode()
          DOCUMENT ME!
 GameMove[] listLegalMoves()
          DOCUMENT ME!
 int nextPlayer()
          DOCUMENT ME!
protected  boolean popMove()
          DOCUMENT ME!
protected  boolean pushMove(GameMove move)
          DOCUMENT ME!
protected  void resetLists()
          overwritten to provide package access
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.game.AbstractGame
clearRedoList, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getRedoList, getResult, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, resetLegalMoves, saveToFile, spawnChild, undoLastMove, undoMoves
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChessGame

public ChessGame()
Creates a new ChessGame object.


ChessGame

public ChessGame(java.lang.String name)
Creates a new ChessGame object.

Parameters:
name - DOCUMENT ME!
Method Detail

resetLists

protected void resetLists()
overwritten to provide package access

Overrides:
resetLists in class AbstractGame

getWinner

public int[] getWinner()
DOCUMENT ME!

Returns:
DOCUMENT ME!

gameOver

public boolean gameOver()
Current limitations: gameOver() doesn't currently check for things like insufficient material for checkmate or 3rd repititions.

Overrides:
gameOver in class AbstractGame
Returns:
DOCUMENT ME!

nextPlayer

public int nextPlayer()
DOCUMENT ME!

Returns:
DOCUMENT ME!

listLegalMoves

public GameMove[] listLegalMoves()
DOCUMENT ME!

Specified by:
listLegalMoves in class AbstractGame
Returns:
DOCUMENT ME!

popMove

protected boolean popMove()
DOCUMENT ME!

Specified by:
popMove in class AbstractGame
Returns:
DOCUMENT ME!

pushMove

protected boolean pushMove(GameMove move)
DOCUMENT ME!

Specified by:
pushMove in class AbstractGame
Parameters:
move - DOCUMENT ME!
Returns:
DOCUMENT ME!

getBoard

public org.jscience.computing.game.chess.ChessBoard getBoard()
DOCUMENT ME!

Returns:
DOCUMENT ME!

equals

public boolean equals(java.lang.Object obj)
This implementation of equals() does currently not care about the move history, it only considers the state of the board. That means that a board may be considered equal even though in one case a castling or enpassant move is possible and not in the other.

Overrides:
equals in class java.lang.Object
Parameters:
obj - DOCUMENT ME!
Returns:
DOCUMENT ME!

hashCode

public int hashCode()
DOCUMENT ME!

Overrides:
hashCode in class java.lang.Object
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class AbstractGame
Returns:
DOCUMENT ME!

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
DOCUMENT ME!

Specified by:
clone in interface GamePlay
Overrides:
clone in class AbstractGame
Returns:
DOCUMENT ME!
Throws:
java.lang.CloneNotSupportedException - DOCUMENT ME!
See Also:
AbstractGame.spawnChild(GameMove)