Class CompactPosition

java.lang.Object
chesspresso.position.AbstractPosition
chesspresso.position.CompactPosition
All Implemented Interfaces:
ImmutablePosition

public class CompactPosition extends AbstractPosition
An implementation of the position interface.

The class is optimized for memory footprint. Each instance uses only 36 bytes for internal representation (plus some overhead for java internals).

Version:
$Revision: 1.1 $
Author:
Bernhard Seybold
  • Constructor Details

    • CompactPosition

      public CompactPosition()
    • CompactPosition

      public CompactPosition(ImmutablePosition position)
  • Method Details

    • getStone

      public int getStone(int sqi)
      Description copied from interface: ImmutablePosition
      Return the stone currently on the given square.
      Parameters:
      sqi - the square
      Returns:
      the stone of the given square
    • getSqiEP

      public int getSqiEP()
      Description copied from interface: ImmutablePosition
      Return the current en passant square.
      Returns:
      the current en passant square, NO_SQUARE if none
    • getCastles

      public int getCastles()
      Description copied from interface: ImmutablePosition
      Return the still allowed castles as mask.
      Returns:
      the still allowed castles as mask.
    • getToPlay

      public int getToPlay()
      Description copied from interface: ImmutablePosition
      Return the player whose turn it is.
      Returns:
      the player whose turn it is
    • getPlyNumber

      public int getPlyNumber()
      Description copied from interface: ImmutablePosition
      Return the current ply number.
      Returns:
      the current ply number, starting at play no. 0
    • getHalfMoveClock

      public int getHalfMoveClock()
      Description copied from interface: ImmutablePosition
      Return the number of moves since the last capture and the last pawn move. This number is used for the 50-move rule.
      Returns:
      the number of moves since the last capture and the last pawn move