org.vizzini.game.boardgame.chess
Class ChessAdjudicator

java.lang.Object
  extended by org.vizzini.game.AbstractAdjudicator
      extended by org.vizzini.game.boardgame.chess.ChessAdjudicator
All Implemented Interfaces:
IChessAdjudicator, IGridBoardAdjudicator, IAdjudicator

public class ChessAdjudicator
extends AbstractAdjudicator
implements IChessAdjudicator

Provides an adjudicator for 3D chess. An adjudicator instance encapsulates the rules of a game by determining the legality of actions and when the game is over.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from class org.vizzini.game.AbstractAdjudicator
_winner
 
Constructor Summary
ChessAdjudicator()
           
 
Method Summary
 boolean agentHasLine(IEnvironment environment, IAgent agent0, IAgent agent1, int startF, int startR, int startL, int df, int dr, int dl)
          Return true if an agent has tokens in the line specified by the other arguments.
 void configure(Properties properties)
          Configure this adjudicator.
 int getPawnPromotionLevel(IChessEnvironment board, boolean isWhite)
          Return the level for pawn promotion.
 int getPawnPromotionLevelsCount()
           
 int getPawnPromotionRank(IChessEnvironment board, boolean isWhite)
          Return the rank for pawn promotion.
 Set getWinningPositions()
           
 boolean isActionLegal(IEnvironment environment, IAction action)
          Return true if the given agent action is legal in the given environment.
protected  boolean isActionLegal0(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isCaptureActionLegal0(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isCastleActionLegal(IChessEnvironment board, CastleAction action)
          Return true if the given castle agent action is legal in the given environment.
 boolean isCastleActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition kingFromPosition, IntegerPosition kingToPosition, IntegerPosition rookFromPosition, IntegerPosition rookToPosition)
          Return true if the given castle agent action is legal in the given environment.
protected  boolean isEnPassantCaptureActionLegal(IChessEnvironment board, EnPassantCaptureAction action)
          Return true if the given agent action is legal in the given environment.
 boolean isEnPassantCaptureActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition capturePosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isEnPassantPositions(IChessEnvironment board, IntegerPosition fromPosition, IntegerPosition capturePosition)
          Return true if the given positions are correct for en passant capture.
 boolean isGameOver(IEnvironment environment)
          Return true if one of the agents has won.
 boolean isGoal(IEnvironment environment)
          Return true if one of the agents has won.
 boolean isInCheck(IChessEnvironment board, IChessAgent agent)
          Return true if the given agent's King is in check.
 boolean isInCheckmate(IChessEnvironment board, IChessAgent agent)
          Return true if the given agent's King is in checkmate.
 boolean isInPawnPromotionRange(IChessEnvironment board, IntegerPosition toPosition, boolean isWhite)
          Return true if the given position is in pawn promotion range for the given board and team.
 boolean isMoveActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isMoveActionLegal(IChessEnvironment board, MoveAction action)
          Return true if the given agent action is legal in the given environment.
 boolean isMoveCaptureActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isMoveCaptureActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, boolean isCheckTested)
          Return true if the given agent action is legal in the given environment.
protected  boolean isMoveCaptureActionLegal(IChessEnvironment board, MoveCaptureAction action)
          Return true if the given agent action is legal in the given environment.
protected  boolean isNonCaptureActionLegal0(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isPathClear(IChessEnvironment board, IntegerPosition from, IntegerPosition to)
          Return true if the linear path is clear between the given positions.
 boolean isPawnPromotionActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isPawnPromotionActionLegal(IChessEnvironment board, PawnPromotionAction action)
          Return true if the given agent action is legal in the given environment.
 boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return true if the given agent action is legal in the given environment.
protected  boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, boolean isCheckTested)
          Return true if the given agent action is legal in the given environment.
protected  boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board, PawnPromotionCaptureAction action)
          Return true if the given agent action is legal in the given environment.
protected  void kingCheck(IChessEnvironment board, IChessAgent agent)
          Make sure the King exists.
protected  void kingsCheck(IChessEnvironment board)
          Make sure the Kings exist.
protected  boolean performCheckTest(IChessEnvironment board, IAction action)
          Perform a test to see if the given action will result in the action's agent being in check.
protected  void setPawnPromotionLevelsCount(int pawnPromotionLevelsCount)
           
 
Methods inherited from class org.vizzini.game.AbstractAdjudicator
areActionsLegal, getWinner, reset, setWinner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.IAdjudicator
areActionsLegal, getWinner, reset, setWinner
 

Constructor Detail

ChessAdjudicator

public ChessAdjudicator()
Method Detail

agentHasLine

public boolean agentHasLine(IEnvironment environment,
                            IAgent agent0,
                            IAgent agent1,
                            int startF,
                            int startR,
                            int startL,
                            int df,
                            int dr,
                            int dl)
Return true if an agent has tokens in the line specified by the other arguments. Note that this method assumes two agents.

Specified by:
agentHasLine in interface IGridBoardAdjudicator
Parameters:
environment - Environment of interest.
agent0 - First agent.
agent1 - Second agent.
startF - Starting file.
startR - Starting rank.
startL - Starting level.
df - Delta in the file direction.
dr - Delta in the rank direction.
dl - Delta in the level direction.
Since:
v0.3

configure

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

Parameters:
properties - Source of configuration information.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.3

getPawnPromotionLevel

public int getPawnPromotionLevel(IChessEnvironment board,
                                 boolean isWhite)
Return the level for pawn promotion.

Specified by:
getPawnPromotionLevel in interface IChessAdjudicator
Parameters:
board - Chess board.
isWhite - Flag indicating if the token is white.
Since:
v0.3

getPawnPromotionLevelsCount

public int getPawnPromotionLevelsCount()
Returns:
Return pawnPromotionLevelsCount.
Since:
v0.3

getPawnPromotionRank

public int getPawnPromotionRank(IChessEnvironment board,
                                boolean isWhite)
Return the rank for pawn promotion.

Specified by:
getPawnPromotionRank in interface IChessAdjudicator
Parameters:
board - Chess board.
isWhite - Flag indicating if the token is white.
Since:
v0.3

getWinningPositions

public Set getWinningPositions()
Specified by:
getWinningPositions in interface IGridBoardAdjudicator
Returns:
Return winningPositions.
Since:
v0.3

isActionLegal

public boolean isActionLegal(IEnvironment environment,
                             IAction action)
Return true if the given agent action is legal in the given environment.

Specified by:
isActionLegal in interface IAdjudicator
Parameters:
environment - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isCastleActionLegal

public boolean isCastleActionLegal(IChessEnvironment board,
                                   IChessAgent agent,
                                   IntegerPosition kingFromPosition,
                                   IntegerPosition kingToPosition,
                                   IntegerPosition rookFromPosition,
                                   IntegerPosition rookToPosition)
Return true if the given castle agent action is legal in the given environment.

Specified by:
isCastleActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
kingFromPosition - King from position.
kingToPosition - King to position.
rookFromPosition - Rook from position.
rookToPosition - Rook to position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isEnPassantCaptureActionLegal

public boolean isEnPassantCaptureActionLegal(IChessEnvironment board,
                                             IChessAgent agent,
                                             IntegerPosition fromPosition,
                                             IntegerPosition capturePosition,
                                             IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment.

Specified by:
isEnPassantCaptureActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
capturePosition - Capture position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isGameOver

public boolean isGameOver(IEnvironment environment)
Return true if one of the agents has won.

Specified by:
isGameOver in interface IAdjudicator
Parameters:
environment - The environment of interest.
Since:
v0.3

isGoal

public boolean isGoal(IEnvironment environment)
Return true if one of the agents has won. If no one has won, return false.

Specified by:
isGoal in interface IAdjudicator
Parameters:
environment - The environment of interest.
Since:
v0.3

isInCheck

public boolean isInCheck(IChessEnvironment board,
                         IChessAgent agent)
Return true if the given agent's King is in check.

Specified by:
isInCheck in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - The agent whose King is in question.
Since:
v0.3

isInCheckmate

public boolean isInCheckmate(IChessEnvironment board,
                             IChessAgent agent)
Return true if the given agent's King is in checkmate.

Specified by:
isInCheckmate in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
Since:
v0.3

isInPawnPromotionRange

public boolean isInPawnPromotionRange(IChessEnvironment board,
                                      IntegerPosition toPosition,
                                      boolean isWhite)
Return true if the given position is in pawn promotion range for the given board and team.

Specified by:
isInPawnPromotionRange in interface IChessAdjudicator
Parameters:
board - Chess board.
toPosition - To position.
isWhite - Flag indicating if the token is white.
Since:
v0.3

isMoveActionLegal

public boolean isMoveActionLegal(IChessEnvironment board,
                                 IChessAgent agent,
                                 IntegerPosition fromPosition,
                                 IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment.

Specified by:
isMoveActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isMoveCaptureActionLegal

public boolean isMoveCaptureActionLegal(IChessEnvironment board,
                                        IChessAgent agent,
                                        IntegerPosition fromPosition,
                                        IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment.

Specified by:
isMoveCaptureActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isPawnPromotionActionLegal

public boolean isPawnPromotionActionLegal(IChessEnvironment board,
                                          IChessAgent agent,
                                          IntegerPosition fromPosition,
                                          IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment.

Specified by:
isPawnPromotionActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isPawnPromotionCaptureActionLegal

public boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board,
                                                 IChessAgent agent,
                                                 IntegerPosition fromPosition,
                                                 IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment.

Specified by:
isPawnPromotionCaptureActionLegal in interface IChessAdjudicator
Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isActionLegal0

protected boolean isActionLegal0(IChessEnvironment board,
                                 IChessAgent agent,
                                 IntegerPosition fromPosition,
                                 IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment. This method performs some common validations.

Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isCaptureActionLegal0

protected boolean isCaptureActionLegal0(IChessEnvironment board,
                                        IChessAgent agent,
                                        IntegerPosition fromPosition,
                                        IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment. This method performs some common validations.

Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isCastleActionLegal

protected boolean isCastleActionLegal(IChessEnvironment board,
                                      CastleAction action)
Return true if the given castle agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The castle agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isEnPassantCaptureActionLegal

protected boolean isEnPassantCaptureActionLegal(IChessEnvironment board,
                                                EnPassantCaptureAction action)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isEnPassantPositions

protected boolean isEnPassantPositions(IChessEnvironment board,
                                       IntegerPosition fromPosition,
                                       IntegerPosition capturePosition)
Return true if the given positions are correct for en passant capture.

Since:
v0.3

isMoveActionLegal

protected boolean isMoveActionLegal(IChessEnvironment board,
                                    MoveAction action)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isMoveCaptureActionLegal

protected boolean isMoveCaptureActionLegal(IChessEnvironment board,
                                           MoveCaptureAction action)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isMoveCaptureActionLegal

protected boolean isMoveCaptureActionLegal(IChessEnvironment board,
                                           IChessAgent agent,
                                           IntegerPosition fromPosition,
                                           IntegerPosition toPosition,
                                           boolean isCheckTested)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isNonCaptureActionLegal0

protected boolean isNonCaptureActionLegal0(IChessEnvironment board,
                                           IChessAgent agent,
                                           IntegerPosition fromPosition,
                                           IntegerPosition toPosition)
Return true if the given agent action is legal in the given environment. This method performs some common validations.

Parameters:
board - Chess environment.
agent - Chess agent.
fromPosition - From position.
toPosition - To position.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isPathClear

protected boolean isPathClear(IChessEnvironment board,
                              IntegerPosition from,
                              IntegerPosition to)
Return true if the linear path is clear between the given positions.

Since:
v0.3

isPawnPromotionActionLegal

protected boolean isPawnPromotionActionLegal(IChessEnvironment board,
                                             PawnPromotionAction action)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isPawnPromotionCaptureActionLegal

protected boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board,
                                                    PawnPromotionCaptureAction action)
Return true if the given agent action is legal in the given environment.

Parameters:
board - Chess environment.
action - The agent action in question.
Returns:
true if the given agent action is legal in the given environment.
Since:
v0.3

isPawnPromotionCaptureActionLegal

protected boolean isPawnPromotionCaptureActionLegal(IChessEnvironment board,
                                                    IChessAgent agent,
                                                    IntegerPosition fromPosition,
                                                    IntegerPosition toPosition,
                                                    boolean isCheckTested)
Return true if the given agent action is legal in the given environment.

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

kingCheck

protected void kingCheck(IChessEnvironment board,
                         IChessAgent agent)
Make sure the King exists.

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

kingsCheck

protected void kingsCheck(IChessEnvironment board)
Make sure the Kings exist.

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

performCheckTest

protected boolean performCheckTest(IChessEnvironment board,
                                   IAction action)
Perform a test to see if the given action will result in the action's agent being in check.

Returns:
true if after performing the given action, the action's agent is in check.
Since:
v0.3

setPawnPromotionLevelsCount

protected void setPawnPromotionLevelsCount(int pawnPromotionLevelsCount)
Parameters:
pawnPromotionLevelsCount - The pawnPromotionLevelsCount to set.
Since:
v0.3


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