org.vizzini.game.boardgame.chess
Class AbstractChessToken

java.lang.Object
  extended by org.vizzini.game.AbstractToken
      extended by org.vizzini.game.boardgame.chess.AbstractChessToken
All Implemented Interfaces:
Serializable, Cloneable, IChessToken, IBoardGameToken, IToken
Direct Known Subclasses:
Bishop, King, Knight, Mace, Pawn, Queen, Rook

public abstract class AbstractChessToken
extends AbstractToken
implements IChessToken

Provides base functionality for 2D and 3D chess tokens.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Field Summary
protected static BitSet _emptyBitSet
          An empty bit set.
protected static int[] ONES
          Delta array used for possible position generation.
protected static int[] TWOS
          Delta array used for possible position generation.
protected static int[] ZERO
          Delta array used for possible position generation.
 
Fields inherited from class org.vizzini.game.AbstractToken
UNKNOWN_NAME
 
Fields inherited from interface org.vizzini.game.IToken
AGENT_PROPERTY, NAME_PROPERTY, POSITION_PROPERTY, TEAM_PROPERTY
 
Constructor Summary
AbstractChessToken()
          TEMP: implement counters.
 
Method Summary
protected  void addCastleActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition kingFromPosition, BitSet toBits)
          Add castle actions using the given parameters.
protected  void addEnPassantCaptureActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition fromPosition, BitSet toBits)
          Add en passant capture actions using the given parameters.
protected  void addMoveActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition fromPosition, BitSet toBits)
          Add move actions using the given parameters.
protected  void addMoveCaptureActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition fromPosition, BitSet toBits)
          Add move capture actions using the given parameters.
protected  void addPawnPromotionActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition fromPosition, BitSet toBits, Class tokenClass)
          Add pawn promotion actions using the given parameters.
protected  void addPawnPromotionCaptureActions(List list, IChessEnvironment board, IChessAgent agent, IChessAdjudicator adjudicator, IntegerPosition fromPosition, BitSet toBits, Class tokenClass)
          Add pawn promotion capture actions using the given parameters.
protected static void addPossiblePosition(IChessEnvironment board, BitSet bitSet, int x, int y, int z, int dx, int dy, int dz)
          Add the positions generated by the deltas to the possible positions list.
protected static void addPossiblePositions(IChessEnvironment board, BitSet bitSet, int x, int y, int z, int[] dx, int[] dy, int[] dz)
          Add the positions generated by the deltas to the possible positions list.
 void configure(Properties properties, int index)
          Configure this token.
 void copy(IToken token)
          Copy data from the given instance.
protected  IAction createCastleAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition kingFromPosition, IntegerPosition kingToPosition, IntegerPosition rookFromPosition, IntegerPosition rookToPosition)
          Create a castle action for the given parameters.
protected  IAction createEnPassantCaptureAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition capturePosition, IntegerPosition toPosition)
          Create an en passant capture action for the given parameters.
protected  IAction createMoveAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Create a move action for the given parameters.
protected  IAction createMoveCaptureAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Create a move capture action for the given parameters.
protected  IAction createPawnPromotionAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, Class tokenClass)
          Create a pawn promotion action for the given parameters.
protected  IAction createPawnPromotionCaptureAction(IChessEnvironment board, IChessAdjudicator adjudicator, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, Class tokenClass)
          Create a pawn promotion capture action for the given parameters.
static int[] getCounters()
          TEMP: return counters.
protected static BitSet getEmptyBitSet(IChessEnvironment board)
          Return an empty bit set.
 List getPossibleActions(IAgent agent0, IEnvironment environment, IAdjudicator adjudicator)
          Return a list of possible legal agent actions.
 BitSet getPossibleCastlePositions(IChessEnvironment board)
          Return a list of the possible castle positions this token could take.
 BitSet getPossibleEnPassantCapturePositions(IChessEnvironment board)
          Return a list of the possible en passant capture positions this token could take.
 BitSet getPossiblePawnPromotionCapturePositions(IChessEnvironment board)
          Return a list of the possible pawn promotion capture positions this token could take.
 BitSet getPossiblePawnPromotionPositions(IChessEnvironment board)
          Return a list of the possible pawn promotion positions this token could take.
 boolean isPossibleCastlePosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isPossibleEnPassantCapturePosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isPossibleMoveCapturePosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isPossibleMovePosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isPossiblePawnPromotionCapturePosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isPossiblePawnPromotionPosition(IChessEnvironment board, IntegerPosition position)
          Return true if the given position is possible for this token.
 boolean isWhite()
          Return true if this token's team is white.
 void setTeam(ITeam team)
          Set the associated team.
 
Methods inherited from class org.vizzini.game.AbstractToken
addPropertyChangeListener, clone, equals, getAgent, getIndex, getName, getPosition, getPropertyChangeManager, getTeam, getValue, hashCode, isFiringPositionChanges, removePropertyChangeListener, setAgent, setFiringPositionChanges, setIndex, setName, setPosition, setValue, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.boardgame.chess.IChessToken
getPossibleMoveCapturePositions, getPossibleMovePositions
 
Methods inherited from interface org.vizzini.game.IToken
addPropertyChangeListener, clone, getAgent, getIndex, getName, getPosition, getTeam, getValue, removePropertyChangeListener, setAgent, setName, setPosition, setValue
 

Field Detail

ONES

protected static final int[] ONES
Delta array used for possible position generation.


ZERO

protected static final int[] ZERO
Delta array used for possible position generation.


TWOS

protected static final int[] TWOS
Delta array used for possible position generation.


_emptyBitSet

protected static BitSet _emptyBitSet
An empty bit set.

Constructor Detail

AbstractChessToken

public AbstractChessToken()
TEMP: implement counters.

Since:
v0.3
Method Detail

getCounters

public static int[] getCounters()
TEMP: return counters.

Since:
v0.3

configure

public void configure(Properties properties,
                      int index)
Configure this token.

Specified by:
configure in interface IToken
Overrides:
configure in class AbstractToken
Parameters:
properties - Source of configuration information.
index - Index of this token's properties.
Since:
v0.3

copy

public void copy(IToken token)
Copy data from the given instance.

Overrides:
copy in class AbstractToken
Since:
v0.3

getPossibleActions

public List getPossibleActions(IAgent agent0,
                               IEnvironment environment,
                               IAdjudicator adjudicator)
Return a list of possible legal agent actions.

Specified by:
getPossibleActions in interface IBoardGameToken
Parameters:
agent0 - Agent.
environment - The current environment.
adjudicator - Adjudicator for determining legal actions.
Since:
v0.3

getPossibleCastlePositions

public BitSet getPossibleCastlePositions(IChessEnvironment board)
Return a list of the possible castle positions this token could take.

Parameters:
board - Chess board.
Since:
v0.3

getPossibleEnPassantCapturePositions

public BitSet getPossibleEnPassantCapturePositions(IChessEnvironment board)
Return a list of the possible en passant capture positions this token could take.

Parameters:
board - Chess board.
Since:
v0.3

getPossiblePawnPromotionCapturePositions

public BitSet getPossiblePawnPromotionCapturePositions(IChessEnvironment board)
Return a list of the possible pawn promotion capture positions this token could take.

Parameters:
board - Chess board.
Since:
v0.3

getPossiblePawnPromotionPositions

public BitSet getPossiblePawnPromotionPositions(IChessEnvironment board)
Return a list of the possible pawn promotion positions this token could take.

Parameters:
board - Chess board.
Since:
v0.3

isPossibleCastlePosition

public boolean isPossibleCastlePosition(IChessEnvironment board,
                                        IntegerPosition position)
Return true if the given position is possible for this token.

Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isPossibleEnPassantCapturePosition

public boolean isPossibleEnPassantCapturePosition(IChessEnvironment board,
                                                  IntegerPosition position)
Return true if the given position is possible for this token.

Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isPossibleMoveCapturePosition

public boolean isPossibleMoveCapturePosition(IChessEnvironment board,
                                             IntegerPosition position)
Return true if the given position is possible for this token.

Specified by:
isPossibleMoveCapturePosition in interface IChessToken
Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isPossibleMovePosition

public boolean isPossibleMovePosition(IChessEnvironment board,
                                      IntegerPosition position)
Return true if the given position is possible for this token.

Specified by:
isPossibleMovePosition in interface IChessToken
Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isPossiblePawnPromotionCapturePosition

public boolean isPossiblePawnPromotionCapturePosition(IChessEnvironment board,
                                                      IntegerPosition position)
Return true if the given position is possible for this token.

Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isPossiblePawnPromotionPosition

public boolean isPossiblePawnPromotionPosition(IChessEnvironment board,
                                               IntegerPosition position)
Return true if the given position is possible for this token.

Parameters:
board - Chess board.
position - Position.
Since:
v0.3

isWhite

public boolean isWhite()
Return true if this token's team is white.

Specified by:
isWhite in interface IChessToken
Since:
v0.3

setTeam

public void setTeam(ITeam team)
Set the associated team. Extend the super method to set the _isWhite flag.

Specified by:
setTeam in interface IToken
Overrides:
setTeam in class AbstractToken
Parameters:
team - The associated team. Can be null.
Since:
v0.3

addPossiblePosition

protected static void addPossiblePosition(IChessEnvironment board,
                                          BitSet bitSet,
                                          int x,
                                          int y,
                                          int z,
                                          int dx,
                                          int dy,
                                          int dz)
Add the positions generated by the deltas to the possible positions list.

Since:
v0.3

addPossiblePositions

protected static void addPossiblePositions(IChessEnvironment board,
                                           BitSet bitSet,
                                           int x,
                                           int y,
                                           int z,
                                           int[] dx,
                                           int[] dy,
                                           int[] dz)
Add the positions generated by the deltas to the possible positions list.

Since:
v0.3

getEmptyBitSet

protected static final BitSet getEmptyBitSet(IChessEnvironment board)
Return an empty bit set.

Parameters:
board - Chess board.
Since:
v0.3

addCastleActions

protected void addCastleActions(List list,
                                IChessEnvironment board,
                                IChessAgent agent,
                                IChessAdjudicator adjudicator,
                                IntegerPosition kingFromPosition,
                                BitSet toBits)
Add castle actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
kingFromPosition - King from position.
toBits - To positions bit set.
Since:
v0.3

addEnPassantCaptureActions

protected void addEnPassantCaptureActions(List list,
                                          IChessEnvironment board,
                                          IChessAgent agent,
                                          IChessAdjudicator adjudicator,
                                          IntegerPosition fromPosition,
                                          BitSet toBits)
Add en passant capture actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
fromPosition - From position.
toBits - To positions bit set.
Since:
v0.3

addMoveActions

protected void addMoveActions(List list,
                              IChessEnvironment board,
                              IChessAgent agent,
                              IChessAdjudicator adjudicator,
                              IntegerPosition fromPosition,
                              BitSet toBits)
Add move actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
fromPosition - From position.
toBits - To positions bit set.
Since:
v0.3

addMoveCaptureActions

protected void addMoveCaptureActions(List list,
                                     IChessEnvironment board,
                                     IChessAgent agent,
                                     IChessAdjudicator adjudicator,
                                     IntegerPosition fromPosition,
                                     BitSet toBits)
Add move capture actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
fromPosition - From position.
toBits - To positions bit set.
Since:
v0.3

addPawnPromotionActions

protected void addPawnPromotionActions(List list,
                                       IChessEnvironment board,
                                       IChessAgent agent,
                                       IChessAdjudicator adjudicator,
                                       IntegerPosition fromPosition,
                                       BitSet toBits,
                                       Class tokenClass)
Add pawn promotion actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
fromPosition - From position.
toBits - To positions bit set.
tokenClass - Promotion token class.
Since:
v0.3

addPawnPromotionCaptureActions

protected void addPawnPromotionCaptureActions(List list,
                                              IChessEnvironment board,
                                              IChessAgent agent,
                                              IChessAdjudicator adjudicator,
                                              IntegerPosition fromPosition,
                                              BitSet toBits,
                                              Class tokenClass)
Add pawn promotion capture actions using the given parameters.

Parameters:
list - Actions list.
board - Chess board.
agent - Chess agent.
adjudicator - Chess adjudicator.
fromPosition - From position.
toBits - To positions bit set.
tokenClass - Promotion token class.
Since:
v0.3

createCastleAction

protected IAction createCastleAction(IChessEnvironment board,
                                     IChessAdjudicator adjudicator,
                                     IChessAgent agent,
                                     IntegerPosition kingFromPosition,
                                     IntegerPosition kingToPosition,
                                     IntegerPosition rookFromPosition,
                                     IntegerPosition rookToPosition)
Create a castle action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
kingFromPosition - King from position.
kingToPosition - King to position.
rookFromPosition - Rook from position.
rookToPosition - Rook to position.
Since:
v0.3

createEnPassantCaptureAction

protected IAction createEnPassantCaptureAction(IChessEnvironment board,
                                               IChessAdjudicator adjudicator,
                                               IChessAgent agent,
                                               IntegerPosition fromPosition,
                                               IntegerPosition capturePosition,
                                               IntegerPosition toPosition)
Create an en passant capture action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Since:
v0.3

createMoveAction

protected IAction createMoveAction(IChessEnvironment board,
                                   IChessAdjudicator adjudicator,
                                   IChessAgent agent,
                                   IntegerPosition fromPosition,
                                   IntegerPosition toPosition)
Create a move action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Since:
v0.3

createMoveCaptureAction

protected IAction createMoveCaptureAction(IChessEnvironment board,
                                          IChessAdjudicator adjudicator,
                                          IChessAgent agent,
                                          IntegerPosition fromPosition,
                                          IntegerPosition toPosition)
Create a move capture action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Since:
v0.3

createPawnPromotionAction

protected IAction createPawnPromotionAction(IChessEnvironment board,
                                            IChessAdjudicator adjudicator,
                                            IChessAgent agent,
                                            IntegerPosition fromPosition,
                                            IntegerPosition toPosition,
                                            Class tokenClass)
Create a pawn promotion action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
tokenClass - Promotion token class.
Since:
v0.3

createPawnPromotionCaptureAction

protected IAction createPawnPromotionCaptureAction(IChessEnvironment board,
                                                   IChessAdjudicator adjudicator,
                                                   IChessAgent agent,
                                                   IntegerPosition fromPosition,
                                                   IntegerPosition toPosition,
                                                   Class tokenClass)
Create a pawn promotion capture action for the given parameters.

Parameters:
board - Chess environment.
adjudicator - Chess adjudicator.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
tokenClass - Promotion token class.
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02