Class CompactPosition
java.lang.Object
chesspresso.position.AbstractPosition
chesspresso.position.CompactPosition
- All Implemented Interfaces:
ImmutablePosition
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
-
Field Summary
Fields inherited from class AbstractPosition
HASH_ALL_MASK, HASH_TOPLAY_MASK, HASH_TOPLAY_MULT, s_hashCastleMod, s_hashEPMod, s_hashModFields inherited from interface ImmutablePosition
ALL_CASTLES, BLACK_CASTLE, BLACK_LONG_CASTLE, BLACK_SHORT_CASTLE, NO_CASTLES, WHITE_CASTLE, WHITE_LONG_CASTLE, WHITE_SHORT_CASTLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturn the still allowed castles as mask.intReturn the number of moves since the last capture and the last pawn move.intReturn the current ply number.intgetSqiEP()Return the current en passant square.intgetStone(int sqi) Return the stone currently on the given square.intReturn the player whose turn it is.Methods inherited from class AbstractPosition
equals, getFEN, getHashCode, getStartPositionHashCode, hashCode, isCastlePossible, isLegal, isSquarePossibleEPSquare, isStartPosition, isWhiteToPlay, toString, validate
-
Constructor Details
-
CompactPosition
public CompactPosition() -
CompactPosition
-
-
Method Details
-
getStone
public int getStone(int sqi) Description copied from interface:ImmutablePositionReturn 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:ImmutablePositionReturn the current en passant square.- Returns:
- the current en passant square, NO_SQUARE if none
-
getCastles
public int getCastles()Description copied from interface:ImmutablePositionReturn the still allowed castles as mask.- Returns:
- the still allowed castles as mask.
-
getToPlay
public int getToPlay()Description copied from interface:ImmutablePositionReturn the player whose turn it is.- Returns:
- the player whose turn it is
-
getPlyNumber
public int getPlyNumber()Description copied from interface:ImmutablePositionReturn the current ply number.- Returns:
- the current ply number, starting at play no. 0
-
getHalfMoveClock
public int getHalfMoveClock()Description copied from interface:ImmutablePositionReturn 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
-