chesspresso.position
Class LightWeightPosition

java.lang.Object
  |
  +--chesspresso.position.AbstractPosition
        |
        +--chesspresso.position.AbstractMutablePosition
              |
              +--chesspresso.position.LightWeightPosition
All Implemented Interfaces:
ImmutablePosition, MutablePosition

public class LightWeightPosition
extends AbstractMutablePosition

A light-weight implementation of the position interface. This class is optimized for simplicity of the underlying data structure, not for speed of accessors nor for memory footprint. Use this class if you do not care about performance.

Version:
$Revision: 1.1 $
Author:
BerniMan

Field Summary
 
Fields inherited from class chesspresso.position.AbstractMutablePosition
m_changeListeners, m_listeners, m_notifyListeners, m_notifyPositionChanged
 
Fields inherited from class chesspresso.position.AbstractPosition
HASH_ALL_MASK, HASH_TOPLAY_MASK, HASH_TOPLAY_MULT, s_hashCastleMod, s_hashEPMod, 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
LightWeightPosition()
           
LightWeightPosition(ImmutablePosition position)
           
 
Method Summary
 boolean canRedoMove()
           
 boolean canUndoMove()
           
 void doMove(short move)
           
 int getCastles()
          Return the still allowed castles as mask.
 int getHalfMoveClock()
          Return the number of moves since the last capture and the last pawn move.
 Move getLastMove()
           
 short getLastShortMove()
           
 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.
 boolean redoMove()
           
 void setCastles(int castles)
           
 void setHalfMoveClock(int halfMoveClock)
           
 void setPlyNumber(int plyNumber)
           
 void setSqiEP(int sqiEP)
           
 void setStone(int sqi, int stone)
           
 void setToPlay(int toPlay)
           
 boolean undoMove()
           
 
Methods inherited from class chesspresso.position.AbstractMutablePosition
addPositionChangeListener, addPositionListener, clear, excludeCastles, fireCastlesChanged, fireHalfMoveClockChanged, fireMoveDone, fireMoveUndone, firePlyNumberChanged, firePositionChanged, fireSqiEPChanged, fireSquareChanged, fireToPlayChanged, getColor, getPiece, incHalfMoveClock, includeCastles, inverse, isSquareEmpty, removePositionChangeListener, removePositionListener, resetHalfMoveClock, set, setNotifyListeners, setStart, toggleToPlay
 
Methods inherited from class chesspresso.position.AbstractPosition
equals, getFEN, getHashCode, getStartPositionHashCode, hashCode, isCastlePossible, isLegal, isSquarePossibleEPSquare, isStartPosition, isWhiteToPlay, toString, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface chesspresso.position.ImmutablePosition
getFEN, getHashCode, hashCode, isLegal, isStartPosition, validate
 

Constructor Detail

LightWeightPosition

public LightWeightPosition()

LightWeightPosition

public LightWeightPosition(ImmutablePosition position)
Method Detail

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

getToPlay

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

Returns:
the player whose turn it is

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.

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

setStone

public void setStone(int sqi,
                     int stone)

setCastles

public void setCastles(int castles)

setSqiEP

public void setSqiEP(int sqiEP)

setToPlay

public void setToPlay(int toPlay)

setPlyNumber

public void setPlyNumber(int plyNumber)

setHalfMoveClock

public void setHalfMoveClock(int halfMoveClock)

doMove

public void doMove(short move)
            throws IllegalMoveException
IllegalMoveException

canUndoMove

public boolean canUndoMove()

undoMove

public boolean undoMove()

getLastShortMove

public short getLastShortMove()
                       throws IllegalMoveException
IllegalMoveException

getLastMove

public Move getLastMove()
                 throws IllegalMoveException
IllegalMoveException

canRedoMove

public boolean canRedoMove()

redoMove

public boolean redoMove()