com.editev.chess
Class Game

java.lang.Object
  |
  +--com.editev.chess.Chess
        |
        +--com.editev.chess.Board
              |
              +--com.editev.chess.GameState
                    |
                    +--com.editev.chess.Game
Direct Known Subclasses:
EnumeratedGame

public class Game
extends GameState

This class represents a single game of chess.
It comprises the board, which is the location of the pieces;
the game, containing all other information about the game, like castling, ep, 50 move rule, etc.
and a single instance of Move that can be used by Pieces, for example, when iterating.

Using this single instance of Move makes iterating over all moves VERY efficient but VERY
non-thread safe. If you need a new Move, make it yourself!

See Also:
the source here.

Inner classes inherited from class com.editev.chess.Chess
Chess.Black, Chess.White
 
Field Summary
 Boards history
          A list of all the Boards since the last reversible move.
(package private)  boolean isStalemate
           
 Move move
          a Move that is shared promiscuously amongst all the Pieces and inner classes.
 
Fields inherited from class com.editev.chess.GameState
epColumn, kingMoved, moves, NO_EP_COLUMN, reversibleMoves, rookMoved
 
Fields inherited from class com.editev.chess.Board
PIECE_NAMES, PIECES, squares
 
Fields inherited from class com.editev.chess.Chess
BLACK, NO_MOVE, NO_PIECE, WHITE
 
Constructor Summary
Game()
           
 
Method Summary
 byte applyMove(Move move)
          apply a Move to the Game -- in other words, to the board and to the game.
 boolean isIllegal(Move move)
           
 boolean isStalemate()
           
 boolean thirdTime()
          Is this board position appearing for the third time?
 
Methods inherited from class com.editev.chess.GameState
canBeCaptured, canMove, clearEP, getEP, getMoves, getReversibleMoves, incrementMoves, irreversibleMove, isWhiteMove, kingMoved, moveKing, moveRook, rookMoved, setEP
 
Methods inherited from class com.editev.chess.Board
clone, cloneBoard, copyFrom, equals, findPieceSquare, getPiece, getPiece, getPieceIndex, getPieceIndex, hasPiece, inCheck, isAttacked, resultsInCheck, setPieceIndex, toString
 
Methods inherited from class com.editev.chess.Chess
notColor, toColor, toColor, toColorName
 
Methods inherited from class java.lang.Object
, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

move

public final Move move
a Move that is shared promiscuously amongst all the Pieces and inner classes. use at own risk.

isStalemate

boolean isStalemate

history

public final Boards history
A list of all the Boards since the last reversible move.
Constructor Detail

Game

public Game()
Method Detail

isStalemate

public boolean isStalemate()

isIllegal

public boolean isIllegal(Move move)
Parameters:
move - the move to check for legality.
Returns:
true if this move is illegal for this Game. Checks a move for legality for this Game.

applyMove

public byte applyMove(Move move)
apply a Move to the Game -- in other words, to the board and to the game.

this is overridden by GameMoves to keep track of the list of legal next moves
at all times.
Parameters:
sq - the Move to apply.
Returns:
the index of the captured piece, if any (special case for ep).

thirdTime

public boolean thirdTime()
Is this board position appearing for the third time?