chesspresso.position
Class AbstractPosition

java.lang.Object
  |
  +--chesspresso.position.AbstractPosition
All Implemented Interfaces:
ImmutablePosition
Direct Known Subclasses:
AbstractMutablePosition, CompactPosition

public abstract class AbstractPosition
extends java.lang.Object
implements ImmutablePosition

Version:
$Revision: 1.1 $
Author:
Bernhard Seybold

Field Summary
protected static long HASH_ALL_MASK
           
protected static long HASH_TOPLAY_MASK
           
protected static long HASH_TOPLAY_MULT
           
protected static long[] s_hashCastleMod
           
protected static long[] s_hashEPMod
           
protected static long[][] s_hashMod
           
 
Fields inherited from interface chesspresso.position.ImmutablePosition
ALL_CASTLES, BLACK_CASTLE, BLACK_LONG_CASTLE, BLACK_SHORT_CASTLE, NO_CASTLES, WHITE_CASTLE, WHITE_LONG_CASTLE, WHITE_SHORT_CASTLE
 
Constructor Summary
AbstractPosition()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getFEN()
          Return the FEN representation of the current position FEN
 long getHashCode()
          Returns a 64bit hash code of the current position. 64bit should be enough to disnstinguish positions with almost no collisions.
protected static long getStartPositionHashCode()
           
 int hashCode()
          Returns a 32bit hash code of the current position. 32 bit is not enough to distinguish positions reliably, use only if collisions are handled.
 boolean isCastlePossible(int castle)
           
 boolean isLegal()
          Return whether the current position is legal.
 boolean isSquarePossibleEPSquare(int sqi)
           
 boolean isStartPosition()
          Returns whether the represented position is the startposition
static boolean isWhiteToPlay(long hashCode)
           
 java.lang.String toString()
           
 void validate()
          Validates the internal state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface chesspresso.position.ImmutablePosition
getCastles, getHalfMoveClock, getPlyNumber, getSqiEP, getStone, getToPlay
 

Field Detail

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 Detail

AbstractPosition

public AbstractPosition()
Method Detail

getStartPositionHashCode

protected static long getStartPositionHashCode()

isWhiteToPlay

public static boolean isWhiteToPlay(long hashCode)

getHashCode

public long getHashCode()
Description copied from interface: ImmutablePosition
Returns 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:
getHashCode in interface ImmutablePosition
Returns:
a 64bit hash code

hashCode

public final int hashCode()
Description copied from interface: ImmutablePosition
Returns 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:
hashCode in interface ImmutablePosition
Overrides:
hashCode in class java.lang.Object
Returns:
a 32bit hash code

isStartPosition

public final boolean isStartPosition()
Description copied from interface: ImmutablePosition
Returns whether the represented position is the startposition

Specified by:
isStartPosition in interface ImmutablePosition
Returns:
whether the represented position is the startposition

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getFEN

public java.lang.String getFEN()
Description copied from interface: ImmutablePosition
Return the FEN representation of the current position FEN

Specified by:
getFEN in interface ImmutablePosition
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: ImmutablePosition
Return whether the current position is legal.

Specified by:
isLegal in interface ImmutablePosition
Returns:
whether the current position is legal

validate

public void validate()
              throws IllegalPositionException
Description copied from interface: ImmutablePosition
Validates the internal state. Used for debugging and testing.

Specified by:
validate in interface ImmutablePosition
Throws:
IllegalPositionException - if the internal state is illegal

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object