chesspresso.position
Interface ImmutablePosition

All Known Subinterfaces:
MoveablePosition, MutablePosition
All Known Implementing Classes:
AbstractMoveablePosition, AbstractMutablePosition, AbstractPosition

public interface ImmutablePosition

Version:
$Revision: 1.1 $
Author:
Bernhard Seybold

Field Summary
static int ALL_CASTLES
           
static int BLACK_CASTLE
           
static int BLACK_LONG_CASTLE
           
static int BLACK_SHORT_CASTLE
           
static int NO_CASTLES
           
static int WHITE_CASTLE
           
static int WHITE_LONG_CASTLE
           
static int WHITE_SHORT_CASTLE
           
 
Method Summary
 int getCastles()
          Return the still allowed castles as mask.
 java.lang.String getFEN()
          Return the FEN representation of the current position FEN
 int getHalfMoveClock()
          Return the number of moves since the last capture and the last pawn move.
 long getHashCode()
          Returns a 64bit hash code of the current position. 64bit should be enough to disnstinguish positions with almost no collisions.
 int getPlyNumber()
          Return the current ply number.
 int getSqiEP()
          Return the current en passant square.
 int getStone(int sqi)
          Return the stone currently on the given square.
 int getToPlay()
          Return the player whose turn it is.
 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 isLegal()
          Return whether the current position is legal.
 boolean isStartPosition()
          Returns whether the represented position is the startposition
 void validate()
          Validates the internal state.
 

Field Detail

NO_CASTLES

public static final int NO_CASTLES
See Also:
Constant Field Values

WHITE_LONG_CASTLE

public static final int WHITE_LONG_CASTLE
See Also:
Constant Field Values

WHITE_SHORT_CASTLE

public static final int WHITE_SHORT_CASTLE
See Also:
Constant Field Values

BLACK_LONG_CASTLE

public static final int BLACK_LONG_CASTLE
See Also:
Constant Field Values

BLACK_SHORT_CASTLE

public static final int BLACK_SHORT_CASTLE
See Also:
Constant Field Values

WHITE_CASTLE

public static final int WHITE_CASTLE
See Also:
Constant Field Values

BLACK_CASTLE

public static final int BLACK_CASTLE
See Also:
Constant Field Values

ALL_CASTLES

public static final int ALL_CASTLES
See Also:
Constant Field Values
Method Detail

getStone

public int getStone(int sqi)
Return the stone currently on the given square.

Parameters:
sqi - the square
Returns:
the stone of the given square

getSqiEP

public int getSqiEP()
Return the current en passant square.

Returns:
the current en passant square, NO_SQUARE if none

getCastles

public int getCastles()
Return the still allowed castles as mask.

Returns:
the still allowed castles as mask.

getToPlay

public int getToPlay()
Return the player whose turn it is.

Returns:
the player whose turn it is

getPlyNumber

public int getPlyNumber()
Return the current ply number.

Returns:
the current ply number, starting at play no. 0

getHalfMoveClock

public int getHalfMoveClock()
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

isLegal

public boolean isLegal()
Return whether the current position is legal.

Returns:
whether the current position is legal

getFEN

public java.lang.String getFEN()
Return the FEN representation of the current position FEN

Returns:
the FEN representation of the current position

isStartPosition

public boolean isStartPosition()
Returns whether the represented position is the startposition

Returns:
whether the represented position is the startposition

getHashCode

public long getHashCode()
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

Returns:
a 64bit hash code

hashCode

public 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.

Overrides:
hashCode in class java.lang.Object
Returns:
a 32bit hash code

validate

public void validate()
              throws IllegalPositionException
Validates the internal state. Used for debugging and testing.

Throws:
IllegalPositionException - if the internal state is illegal