com.editev.chess
Class GameMoves

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

public class GameMoves
extends EnumeratedGame

A GameMoves is an EnumeratedGame with a list of legal Moves for that Game.

See Also:
the source here.

Inner classes inherited from class com.editev.chess.EnumeratedGame
EnumeratedGame.AcceptLegalMoves, EnumeratedGame.AcceptSquaresOnTheMove, EnumeratedGame.AllMovesForPieceMoving, EnumeratedGame.ConstructMovesFromPieces, EnumeratedGame.SquareToPiece
 
Inner classes inherited from class com.editev.chess.Chess
Chess.Black, Chess.White
 
Field Summary
(package private)  Moves allMoves
          Store all the legal next moves from this board position.
static short MAX_MOVES
          Estimate of max legal moves per position: max ever actually recorded in a random game is 71.
private  java.util.Enumeration moveEnumeration
          An enumeration of all the legal moves, might be null or partially consumed.
protected  boolean movesCompleted
          Have we enumerated ALL the next moves for this position yet?
protected  boolean movesEnumerated
          Have we enumerated the next moves for this position yet?
 
Fields inherited from class com.editev.chess.EnumeratedGame
acceptLegalMoves, acceptSquaresOnTheMove, constructMovesFromPieces
 
Fields inherited from class com.editev.chess.Game
history, isStalemate, move
 
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
GameMoves()
           
 
Method Summary
 byte applyMove(Move move)
          Apply a specific move to this Game.
protected  void computeMoves()
          Compute all the legal moves.
protected  void computeMoves(short moveNeeded)
          Computes all next legal moves up to a certain move index.
 Move getMove(short move)
           
 short getMoveCount()
          Count all the the possible legal moves -- don't call this if you want to avoid enumerating all possible legal moves for efficiency reasons, go right to getMove().
protected  java.util.Enumeration getMoveEnumeration()
          Retrieves or creates an enumeration of all the legal moves.
 
Methods inherited from class com.editev.chess.EnumeratedGame
enumerateAllLegalMoves
 
Methods inherited from class com.editev.chess.Game
isIllegal, isStalemate, thirdTime
 
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

MAX_MOVES

public static final short MAX_MOVES
Estimate of max legal moves per position: max ever actually recorded in a random game is 71.

allMoves

final Moves allMoves
Store all the legal next moves from this board position.

movesEnumerated

protected boolean movesEnumerated
Have we enumerated the next moves for this position yet?

movesCompleted

protected boolean movesCompleted
Have we enumerated ALL the next moves for this position yet?

moveEnumeration

private java.util.Enumeration moveEnumeration
An enumeration of all the legal moves, might be null or partially consumed.
Constructor Detail

GameMoves

public GameMoves()
Method Detail

getMoveCount

public short getMoveCount()
Count all the the possible legal moves -- don't call this if you want to avoid enumerating all possible legal moves for efficiency reasons, go right to getMove().
Returns:
count of the number of legal next Moves for this Game.

getMove

public Move getMove(short move)
Parameters:
move - the index of the legal move we're locating.
Returns:
the legal move at this location -- only computes legal moves up to this point for efficiency.

getMoveEnumeration

protected java.util.Enumeration getMoveEnumeration()
Retrieves or creates an enumeration of all the legal moves.
Returns:
an Enumeration of all the legal moves.

computeMoves

protected void computeMoves(short moveNeeded)
Computes all next legal moves up to a certain move index.
Parameters:
moveNeeded - the index of the last legal move we need (or Short.MAX_SHORT for all!)

computeMoves

protected void computeMoves()
Compute all the legal moves.

applyMove

public byte applyMove(Move move)
Apply a specific move to this Game. Apply the move to the parent class -- but then invalidate the stored list of legal moves.
Overrides:
applyMove in class Game
Returns:
the index of the captured piece, if any (special case for ep).
See Also:
com.editev.chess.Game.