com.editev.chess
Class Counts

java.lang.Object
  |
  +--com.editev.chess.Counts

public class Counts
extends java.lang.Object

This class associates a count with each square on a chess board. If we are choosing a piece to move, the count represents how many legal moves a Piece on that square would have. If we have chosen a piece to move and are displaying the target squares, then we are assigning indices to the possible target moves.

!
See Also:
the source here.

Field Summary
 short[][] counts
          Contains one byte of count for each piece on a chess board.
 
Constructor Summary
Counts()
           
 
Method Summary
 void clearCount(Square sq)
          Clears the count for a specific Square.
 void clearCounts()
          Clears all 64 counts.
 void computePieceMoves(GameMoves game)
          Computes the starting move index for each Piece that has legal moves.
 void computePieceTargets(GameMoves game, short startMove)
          Count NO_PIECE on the square of the piece that's moving, and the move index on all valid target squares.
 short getCount(Square sq)
           
 void incCount(Square sq)
          Increments the count for a specific Square.
 void markStart(Square sq)
          Sets the count for a specific Square to indicate that it's the start piece for a move.
 void setMove(Square sq, short move)
          Sets the count for a square to be a specific move number.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

counts

public final short[][] counts
Contains one byte of count for each piece on a chess board.
Constructor Detail

Counts

public Counts()
Method Detail

getCount

public short getCount(Square sq)
Returns:
the count for a specific Square.

clearCount

public void clearCount(Square sq)
Clears the count for a specific Square.

incCount

public void incCount(Square sq)
Increments the count for a specific Square.

markStart

public void markStart(Square sq)
Sets the count for a specific Square to indicate that it's the start piece for a move.

setMove

public void setMove(Square sq,
                    short move)
Sets the count for a square to be a specific move number.

clearCounts

public void clearCounts()
Clears all 64 counts.

computePieceMoves

public void computePieceMoves(GameMoves game)
Computes the starting move index for each Piece that has legal moves.

computePieceTargets

public void computePieceTargets(GameMoves game,
                                short startMove)
Count NO_PIECE on the square of the piece that's moving, and the move index on all valid target squares. Used when we are displaying a board with possible targets for a Piece move.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A String description of the Counts.