de.java_chess.javaChess.bitboard
Class BitBoardImpl

java.lang.Object
  |
  +--de.java_chess.javaChess.bitboard.BitBoardImpl

public class BitBoardImpl
extends java.lang.Object
implements BitBoard

This class stores a chess board as a couple of overlayed longs (64-Bit wide).


Fields inherited from interface de.java_chess.javaChess.bitboard.BitBoard
_LINE_A, _LINE_B, _LINE_C, _LINE_D, _LINE_E, _LINE_F, _LINE_G, _LINE_H, _NOT_LINE_A, _NOT_LINE_B, _NOT_LINE_C, _NOT_LINE_D, _NOT_LINE_E, _NOT_LINE_F, _NOT_LINE_G, _NOT_LINE_H, _NOT_ROW_1, _NOT_ROW_2, _NOT_ROW_3, _NOT_ROW_4, _NOT_ROW_5, _NOT_ROW_6, _NOT_ROW_7, _NOT_ROW_8, _ROW_1, _ROW_2, _ROW_3, _ROW_4, _ROW_5, _ROW_6, _ROW_7, _ROW_8
 
Constructor Summary
BitBoardImpl()
          Create a new instance of a chess board with pieces on their initial positions.
 
Method Summary
protected  java.lang.Object clone()
          Create a clone of this board.
 void doPly(Ply ply)
          Move a piece from one square to another.
 void emptyBoard()
          Remove all the pieces from the board.
 long getAllPiecesForColor(boolean white)
          Get all white or black pieces.
 Board getBoardAfterPly(Ply ply)
          Return a new board, that results from a given ply.
 long getEmptySquares()
          Get a bitmask with all the free squares.
 Piece getPiece(Position position)
          Get the piece of a given position, or null of the square is empty.
 long getPositionOfPieces(int pieceTypeColor)
          Get the positions of some pieces as a long (64 bit wide) bitmask.
 void initialPosition()
          Set all the pieces to their initial positions.
 void setPiece(Piece piece, Position position)
          Set a piece on a given square.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitBoardImpl

public BitBoardImpl()
Create a new instance of a chess board with pieces on their initial positions.
Method Detail

clone

protected final java.lang.Object clone()
Create a clone of this board.
Overrides:
clone in class java.lang.Object
Returns:
A clone of this board.

emptyBoard

public final void emptyBoard()
Remove all the pieces from the board.

initialPosition

public final void initialPosition()
Set all the pieces to their initial positions.

getPiece

public final Piece getPiece(Position position)
Get the piece of a given position, or null of the square is empty.
Parameters:
position - The position of the piece.
Returns:
The piece of the square or null, of the square is empty.

setPiece

public final void setPiece(Piece piece,
                           Position position)
Set a piece on a given square.
Parameters:
piece - The piece to set, or null to empty the square.
position - The position of the square.

doPly

public final void doPly(Ply ply)
Move a piece from one square to another.
Parameters:
ply - The ply to perform.

getBoardAfterPly

public final Board getBoardAfterPly(Ply ply)
Return a new board, that results from a given ply.
Parameters:
ply - The ply to perform.
Returns:
A new board with the game position after the ply.

getPositionOfPieces

public final long getPositionOfPieces(int pieceTypeColor)
Get the positions of some pieces as a long (64 bit wide) bitmask.
Specified by:
getPositionOfPieces in interface BitBoard
Parameters:
pieceTypeColor - The color and type of the pieces.

getEmptySquares

public final long getEmptySquares()
Get a bitmask with all the free squares.
Specified by:
getEmptySquares in interface BitBoard
Returns:
A bitmask with all the empty squares marked by a 1 bit.

getAllPiecesForColor

public final long getAllPiecesForColor(boolean white)
Get all white or black pieces.
Specified by:
getAllPiecesForColor in interface BitBoard
Parameters:
white - true, if the white pieces are requested, false for the black pieces.