org.vizzini.game.boardgame.chess.standardtoken
Class King

java.lang.Object
  extended by org.vizzini.game.AbstractToken
      extended by org.vizzini.game.boardgame.chess.AbstractChessToken
          extended by org.vizzini.game.boardgame.chess.standardtoken.King
All Implemented Interfaces:
Serializable, Cloneable, IChessToken, IKing, IBoardGameToken, IToken

public class King
extends AbstractChessToken
implements IKing

Provides a King for 3D chess. This token travels in the directions of the Rook, Bishop, or Mace, but limited to a distance of one.

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

Field Summary
protected static BitSet[] _possibleCastlePositions
          Array of index to possible castle position bit set.
protected static BitSet[] _possiblePositions
          Array of index to possible position bit set.
 
Fields inherited from class org.vizzini.game.boardgame.chess.AbstractChessToken
_emptyBitSet, ONES, TWOS, ZERO
 
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
King()
          Construct this object with no agent as this token's owner.
 
Method Summary
protected static void generatePossibleCastlePositions(IChessEnvironment board, IntegerPosition kingFromPosition)
          Fill the possible positions list.
protected static void generatePossiblePositions(IChessAgent agent, IChessEnvironment board, int index)
          Fill the possible positions list.
 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.
protected static BitSet[] getPossibleCastlePositionsArray(IChessEnvironment board)
          Return the possible positions array.
 BitSet getPossibleMoveCapturePositions(IChessEnvironment board)
          Return a list of the possible move capture positions this token could take.
 BitSet getPossibleMovePositions(IChessEnvironment board)
          Return a list of the possible move positions this token could take.
protected static BitSet[] getPossiblePositionsArray(IChessEnvironment board)
          Return the possible positions array.
static void reset()
          Reset cached data.
protected  void setPossiblePosition(IChessEnvironment board, int positionIndex, int moveIndex)
          Set the possible position.
 
Methods inherited from class org.vizzini.game.boardgame.chess.AbstractChessToken
addCastleActions, addEnPassantCaptureActions, addMoveActions, addMoveCaptureActions, addPawnPromotionActions, addPawnPromotionCaptureActions, addPossiblePosition, addPossiblePositions, configure, copy, createCastleAction, createEnPassantCaptureAction, createMoveAction, createMoveCaptureAction, createPawnPromotionAction, createPawnPromotionCaptureAction, getCounters, getEmptyBitSet, getPossibleEnPassantCapturePositions, getPossiblePawnPromotionCapturePositions, getPossiblePawnPromotionPositions, isPossibleCastlePosition, isPossibleEnPassantCapturePosition, isPossibleMoveCapturePosition, isPossibleMovePosition, isPossiblePawnPromotionCapturePosition, isPossiblePawnPromotionPosition, isWhite, setTeam
 
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.IKing
isPossibleCastlePosition
 
Methods inherited from interface org.vizzini.game.boardgame.chess.IChessToken
isPossibleMoveCapturePosition, isPossibleMovePosition, isWhite
 
Methods inherited from interface org.vizzini.game.IToken
addPropertyChangeListener, clone, configure, getAgent, getIndex, getName, getPosition, getTeam, getValue, removePropertyChangeListener, setAgent, setName, setPosition, setTeam, setValue
 

Field Detail

_possiblePositions

protected static BitSet[] _possiblePositions
Array of index to possible position bit set.


_possibleCastlePositions

protected static BitSet[] _possibleCastlePositions
Array of index to possible castle position bit set.

Constructor Detail

King

public King()
Construct this object with no agent as this token's owner.

Since:
v0.3
Method Detail

reset

public static void reset()
Reset cached data.

Since:
v0.3

getPossibleActions

public List getPossibleActions(IAgent agent0,
                               IEnvironment environment,
                               IAdjudicator adjudicator)
Return a list of possible legal agent actions. Extends the super method for castle actions.

Specified by:
getPossibleActions in interface IBoardGameToken
Overrides:
getPossibleActions in class AbstractChessToken
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.

Specified by:
getPossibleCastlePositions in interface IKing
Overrides:
getPossibleCastlePositions in class AbstractChessToken
Parameters:
board - Chess board.
Since:
v0.3

getPossibleMoveCapturePositions

public BitSet getPossibleMoveCapturePositions(IChessEnvironment board)
Return a list of the possible move capture positions this token could take.

Specified by:
getPossibleMoveCapturePositions in interface IChessToken
Parameters:
board - Chess board.
Since:
v0.3

getPossibleMovePositions

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

Specified by:
getPossibleMovePositions in interface IChessToken
Parameters:
board - Chess board.
Since:
v0.3

generatePossibleCastlePositions

protected static void generatePossibleCastlePositions(IChessEnvironment board,
                                                      IntegerPosition kingFromPosition)
Fill the possible positions list.

Parameters:
board - Grid board environment.
kingFromPosition - Token position.
Since:
v0.3

generatePossiblePositions

protected static void generatePossiblePositions(IChessAgent agent,
                                                IChessEnvironment board,
                                                int index)
Fill the possible positions list.

Parameters:
board - Grid board environment.
index - Token position as an index.
Since:
v0.3

getPossibleCastlePositionsArray

protected static BitSet[] getPossibleCastlePositionsArray(IChessEnvironment board)
Return the possible positions array.

Since:
v0.3

getPossiblePositionsArray

protected static BitSet[] getPossiblePositionsArray(IChessEnvironment board)
Return the possible positions array.

Since:
v0.3

setPossiblePosition

protected void setPossiblePosition(IChessEnvironment board,
                                   int positionIndex,
                                   int moveIndex)
Set the possible position.

Parameters:
positionIndex - This token's position as an index.
moveIndex - The to position as an index.
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02