org.vizzini.game.boardgame.chess
Class AbstractChessEnvironment

java.lang.Object
  extended by org.vizzini.game.AbstractEnvironment
      extended by org.vizzini.game.boardgame.AbstractGridBoard
          extended by org.vizzini.game.boardgame.chess.AbstractChessEnvironment
All Implemented Interfaces:
Serializable, Cloneable, IChessEnvironment, IGridBoard, IEnvironment
Direct Known Subclasses:
DefaultChessEnvironment

public abstract class AbstractChessEnvironment
extends AbstractGridBoard
implements IChessEnvironment

Provides a chess grid board for 3D chess.

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

Field Summary
protected  CheckManager _checkManager
          Check manager.
 
Fields inherited from class org.vizzini.game.boardgame.AbstractGridBoard
UNDO_ACTION
 
Constructor Summary
AbstractChessEnvironment()
           
 
Method Summary
 void addCheckListener(ICheckListener listener)
          Add the given listener.
 void configure(Properties properties)
          Configure this environment.
 void copy(IEnvironment environment)
          Copy data from the given instance into this.
protected  ITokenCollection createInitialTokens()
          Create the initial tokens from the cached properties.
protected  IChessToken createToken(IChessAgent agent)
          Create a new token.
 IChessAgent getAgent(boolean isWhite)
          Return the proper agent for the given flag.
 IChessAgent getAgentBlack()
          Return the agent for the black team.
 IChessAgent getAgentWhite()
          Return the agent for the white team.
 int getEnPassantRank(boolean isWhite)
          Return the en passant capture rank (if any) for the given parameter.
 List getHintPositionsFor(IntegerPosition position, IAdjudicator adjudicator)
          Return the hint positions for the given position.
 IntegerPosition getInitialKingPosition(boolean isWhite)
          Return the initial king position.
 IntegerPosition getInitialKingsRookPosition(boolean isWhite)
          Return the initial king's rook position.
 IntegerPosition getInitialQueensRookPosition(boolean isWhite)
          Return the initial queen's rook position.
 int getKingsCastleDeltaFile(boolean isKingSide)
          Return the King's delta file for either king-side or queen-side castling.
 IChessAgent getOpponent(IChessAgent agent)
          Return the opposing agent to the given agent.
 int getRooksCastleDeltaFile(boolean isKingSide)
          Return the Rook's delta file for either king-side or queen-side castling.
 ITeam getTeamBlack()
          Return the team for black.
 ITeam getTeamWhite()
          Return the team for white.
 boolean isCastlingAllowed()
          Return true if this environment allows castling.
 boolean isEnPassantCaptureAllowed()
          Return true if this environment allows en passant capture.
 boolean isFiringChecks()
          Return true if this is set to fire check events.
 boolean isInitialPosition(Class tokenClass, ITeam team, IntegerPosition position)
          Return true if the given coordinates are the initial position for a Pawn.
 boolean isKingsSide(IntegerPosition rookPos, IntegerPosition kingPos)
          Return true if the given Rook position is King's side.
 boolean isPawnInitialPosition(ITeam team, IntegerPosition position)
          Return true if the given coordinates are the initial position for a Pawn.
 void performAction(IAction action)
          Perform the given movement agent action.
 void removeCheckListener(ICheckListener listener)
          Remove the given listener.
 void reset()
          Reset to the initial state.
 void setFiringChecks(boolean fire)
          Set the flag which indicates whether to fire state change events.
 
Methods inherited from class org.vizzini.game.boardgame.AbstractGridBoard
agentTokenCount, coordsToIndex, get, getCellCount, getCurrentAgent, getFileCount, getLastAgent, getLevelCount, getMaxDimension, getRankCount, indexToFile, indexToLevel, indexToPosition, indexToRank, is3D, isActionHistoryUsed, isPositionUsable, isPositionUsable, isRedoAllowed, isUndoAllowed, positionToIndex, setActionHistoryUsed, setLastAgent, setToken, setToken, undoAction
 
Methods inherited from class org.vizzini.game.AbstractEnvironment
addStateListener, clone, equals, get, getAdjudicator, getAgentCollection, getStateManager, getTeamCollection, getTokenCollection, getTokenCollectionClass, getTurnNumber, hashCode, incrementTurnNumber, isFiringStateChanges, open, performActions, removeStateListener, setAdjudicator, setAgentCollection, setFiringStateChanges, setTokenCollectionClass, setTurnNumber, update
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.boardgame.IGridBoard
agentTokenCount, coordsToIndex, get, getCellCount, getFileCount, getLastAgent, getLevelCount, getMaxDimension, getRankCount, indexToFile, indexToLevel, indexToPosition, indexToRank, is3D, isActionHistoryUsed, isPositionUsable, isPositionUsable, isRedoAllowed, isUndoAllowed, positionToIndex, setActionHistoryUsed, setToken, setToken
 
Methods inherited from interface org.vizzini.game.IEnvironment
addStateListener, clone, get, getAdjudicator, getAgentCollection, getTeamCollection, getTokenCollection, getTurnNumber, incrementTurnNumber, isFiringStateChanges, open, performActions, removeStateListener, setAdjudicator, setAgentCollection, setFiringStateChanges, setTurnNumber, undoAction, update
 

Field Detail

_checkManager

protected transient CheckManager _checkManager
Check manager.

Constructor Detail

AbstractChessEnvironment

public AbstractChessEnvironment()
Method Detail

addCheckListener

public void addCheckListener(ICheckListener listener)
Add the given listener.

Specified by:
addCheckListener in interface IChessEnvironment
Since:
v0.3

configure

public void configure(Properties properties)
               throws InstantiationException,
                      IllegalAccessException
Configure this environment.

Specified by:
configure in interface IEnvironment
Overrides:
configure in class AbstractGridBoard
Parameters:
properties - Source of configuration information.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.3

copy

public void copy(IEnvironment environment)
Copy data from the given instance into this.

Specified by:
copy in interface IEnvironment
Overrides:
copy in class AbstractGridBoard
Parameters:
environment - Environment from which to copy data.
Since:
v0.3

getAgent

public IChessAgent getAgent(boolean isWhite)
Return the proper agent for the given flag.

Specified by:
getAgent in interface IChessEnvironment
Parameters:
isWhite - Flag indicating whether to return the white agent.
Since:
v0.3

getAgentBlack

public IChessAgent getAgentBlack()
Return the agent for the black team.

Specified by:
getAgentBlack in interface IChessEnvironment
Since:
v0.3

getAgentWhite

public IChessAgent getAgentWhite()
Return the agent for the white team.

Specified by:
getAgentWhite in interface IChessEnvironment
Since:
v0.3

getEnPassantRank

public int getEnPassantRank(boolean isWhite)
Return the en passant capture rank (if any) for the given parameter.

Specified by:
getEnPassantRank in interface IChessEnvironment
Parameters:
isWhite - Flag indicating whether White or Black.
Returns:
the en passant capture rank, or -1 if there is none.

getHintPositionsFor

public List getHintPositionsFor(IntegerPosition position,
                                IAdjudicator adjudicator)
Return the hint positions for the given position.

Specified by:
getHintPositionsFor in interface IChessEnvironment
Since:
v0.3

getInitialKingPosition

public IntegerPosition getInitialKingPosition(boolean isWhite)
Return the initial king position.

Specified by:
getInitialKingPosition in interface IChessEnvironment
Since:
v0.3

getInitialKingsRookPosition

public IntegerPosition getInitialKingsRookPosition(boolean isWhite)
Return the initial king's rook position.

Specified by:
getInitialKingsRookPosition in interface IChessEnvironment
Since:
v0.3

getInitialQueensRookPosition

public IntegerPosition getInitialQueensRookPosition(boolean isWhite)
Return the initial queen's rook position.

Specified by:
getInitialQueensRookPosition in interface IChessEnvironment
Since:
v0.3

getKingsCastleDeltaFile

public int getKingsCastleDeltaFile(boolean isKingSide)
Return the King's delta file for either king-side or queen-side castling.

Specified by:
getKingsCastleDeltaFile in interface IChessEnvironment
Since:
v0.3

getOpponent

public IChessAgent getOpponent(IChessAgent agent)
Return the opposing agent to the given agent.

Specified by:
getOpponent in interface IChessEnvironment
Since:
v0.3

getRooksCastleDeltaFile

public int getRooksCastleDeltaFile(boolean isKingSide)
Return the Rook's delta file for either king-side or queen-side castling.

Specified by:
getRooksCastleDeltaFile in interface IChessEnvironment
Since:
v0.3

getTeamBlack

public ITeam getTeamBlack()
Return the team for black.

Specified by:
getTeamBlack in interface IChessEnvironment
Since:
v0.3

getTeamWhite

public ITeam getTeamWhite()
Return the team for white.

Specified by:
getTeamWhite in interface IChessEnvironment
Since:
v0.3

isCastlingAllowed

public boolean isCastlingAllowed()
Return true if this environment allows castling.

Specified by:
isCastlingAllowed in interface IChessEnvironment
Since:
v0.3

isEnPassantCaptureAllowed

public boolean isEnPassantCaptureAllowed()
Return true if this environment allows en passant capture.

Specified by:
isEnPassantCaptureAllowed in interface IChessEnvironment
Since:
v0.3

isFiringChecks

public boolean isFiringChecks()
Return true if this is set to fire check events.

Specified by:
isFiringChecks in interface IChessEnvironment
Since:
v0.3

isInitialPosition

public boolean isInitialPosition(Class tokenClass,
                                 ITeam team,
                                 IntegerPosition position)
Return true if the given coordinates are the initial position for a Pawn.

Specified by:
isInitialPosition in interface IChessEnvironment
Since:
v0.3

isKingsSide

public boolean isKingsSide(IntegerPosition rookPos,
                           IntegerPosition kingPos)
Return true if the given Rook position is King's side.

Since:
v0.3

isPawnInitialPosition

public boolean isPawnInitialPosition(ITeam team,
                                     IntegerPosition position)
Return true if the given coordinates are the initial position for a Pawn.

Specified by:
isPawnInitialPosition in interface IChessEnvironment
Since:
v0.3

performAction

public void performAction(IAction action)
Perform the given movement agent action. Extend the super method to handle check notification.

Specified by:
performAction in interface IEnvironment
Overrides:
performAction in class AbstractGridBoard
Parameters:
action - Action.
Since:
v0.3

removeCheckListener

public void removeCheckListener(ICheckListener listener)
Remove the given listener.

Specified by:
removeCheckListener in interface IChessEnvironment
Since:
v0.3

reset

public void reset()
Reset to the initial state.

Specified by:
reset in interface IEnvironment
Overrides:
reset in class AbstractEnvironment
Since:
v0.3

setFiringChecks

public void setFiringChecks(boolean fire)
Set the flag which indicates whether to fire state change events.

Specified by:
setFiringChecks in interface IChessEnvironment
Since:
v0.3

createInitialTokens

protected ITokenCollection createInitialTokens()
                                        throws InstantiationException,
                                               IllegalAccessException
Create the initial tokens from the cached properties.

Overrides:
createInitialTokens in class AbstractEnvironment
Throws:
InstantiationException
IllegalAccessException
Since:
v0.3

createToken

protected IChessToken createToken(IChessAgent agent)
Create a new token. This class does not use this method.

Parameters:
agent - The token's associated agent.
Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02