Class AbstractPosition
java.lang.Object
chesspresso.position.AbstractPosition
- All Implemented Interfaces:
ImmutablePosition
- Direct Known Subclasses:
AbstractMutablePosition, CompactPosition
- Version:
- $Revision: 1.1 $
- Author:
- Bernhard Seybold
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static longprotected static longprotected static longprotected static long[]protected static long[]protected static long[][]Fields 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 TypeMethodDescriptionbooleangetFEN()Return the FEN representation of the current positionFENlongReturns a 64bit hash code of the current position. 64bit should be enough to disnstinguish positions with almost no collisions.protected static longfinal inthashCode()Returns a 32bit hash code of the current position. 32 bit is not enough to distinguish positions reliably, use only if collisions are handled.booleanisCastlePossible(int castle) booleanisLegal()Return whether the current position is legal.booleanisSquarePossibleEPSquare(int sqi) final booleanReturns whether the represented position is the startpositionstatic booleanisWhiteToPlay(long hashCode) toString()voidvalidate()Validates the internal state.Methods inherited from interface ImmutablePosition
getCastles, getHalfMoveClock, getPlyNumber, getSqiEP, getStone, getToPlay
-
Field Details
-
HASH_ALL_MASK
protected static long HASH_ALL_MASK -
HASH_TOPLAY_MASK
protected static long HASH_TOPLAY_MASK -
HASH_TOPLAY_MULT
protected static long HASH_TOPLAY_MULT -
s_hashMod
protected static long[][] s_hashMod -
s_hashCastleMod
protected static long[] s_hashCastleMod -
s_hashEPMod
protected static long[] s_hashEPMod
-
-
Constructor Details
-
AbstractPosition
public AbstractPosition()
-
-
Method Details
-
getStartPositionHashCode
protected static long getStartPositionHashCode() -
isWhiteToPlay
public static boolean isWhiteToPlay(long hashCode) -
getHashCode
public long getHashCode()Description copied from interface:ImmutablePositionReturns a 64bit hash code of the current position. 64bit should be enough to disnstinguish positions with almost no collisions. TODO: add reference to paper- Specified by:
getHashCodein interfaceImmutablePosition- Returns:
- a 64bit hash code
-
hashCode
public final int hashCode()Description copied from interface:ImmutablePositionReturns a 32bit hash code of the current position. 32 bit is not enough to distinguish positions reliably, use only if collisions are handled.- Specified by:
hashCodein interfaceImmutablePosition- Overrides:
hashCodein classObject- Returns:
- a 32bit hash code
-
isStartPosition
public final boolean isStartPosition()Description copied from interface:ImmutablePositionReturns whether the represented position is the startposition- Specified by:
isStartPositionin interfaceImmutablePosition- Returns:
- whether the represented position is the startposition
-
equals
-
getFEN
Description copied from interface:ImmutablePositionReturn the FEN representation of the current positionFEN- Specified by:
getFENin interfaceImmutablePosition- Returns:
- the FEN representation of the current position
-
isCastlePossible
public boolean isCastlePossible(int castle) -
isSquarePossibleEPSquare
public boolean isSquarePossibleEPSquare(int sqi) -
isLegal
public boolean isLegal()Description copied from interface:ImmutablePositionReturn whether the current position is legal.- Specified by:
isLegalin interfaceImmutablePosition- Returns:
- whether the current position is legal
-
validate
Description copied from interface:ImmutablePositionValidates the internal state. Used for debugging and testing.- Specified by:
validatein interfaceImmutablePosition- Throws:
IllegalPositionException- if the internal state is illegal
-
toString
-