org.vizzini.game.boardgame.chess.action
Class CastleAction

java.lang.Object
  extended by org.vizzini.game.action.AbstractAction
      extended by org.vizzini.game.boardgame.action.AbstractGridBoardAction
          extended by org.vizzini.game.boardgame.action.AbstractMoveAction
              extended by org.vizzini.game.boardgame.chess.action.CastleAction
All Implemented Interfaces:
Serializable, Comparable, IAction, IGridBoardAction, IMoveAction

public class CastleAction
extends AbstractMoveAction

Provides an agent action for castle movement of a chess King and Rook.

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

Constructor Summary
protected CastleAction(IChessEnvironment board, IChessAgent agent, IntegerPosition kingFromPosition, IntegerPosition kingToPosition, IntegerPosition rookFromPosition, IntegerPosition rookToPosition)
          Construct this object with the given arguments.
 
Method Summary
 int compareTo(Object object)
          Compare this to the given object.
 boolean doIt()
          Perform the command encapsulated by this object.
 boolean equals(Object object)
          Return true if the given object is equal to this.
static CastleAction get(IChessEnvironment board, IChessAgent agent, IntegerPosition kingFromPosition, IntegerPosition kingToPosition, IntegerPosition rookFromPosition, IntegerPosition rookToPosition)
          Return an instance of this class using the given parameters.
 IntegerPosition getFromPosition()
           
 IntegerPosition getKingFromPosition()
           
 IntegerPosition getKingToPosition()
           
 IntegerPosition getRookFromPosition()
          Return the Rook from position.
 IntegerPosition getRookToPosition()
          Return the Rook to position.
 IntegerPosition getToPosition()
           
 int hashCode()
          Returns a hash code value for the object.
static void poolReport()
          Log a statistics report.
 void release()
          Return this instance to the reusable object pool.
protected  void set(IChessEnvironment board, IChessAgent agent, IntegerPosition kingFromPosition, IntegerPosition kingToPosition, IntegerPosition rookFromPosition, IntegerPosition rookToPosition)
          Set parameters on this object.
 String toString()
          Return a string representation of this object.
 boolean undoIt()
          Undo the last invocation of doIt.
 
Methods inherited from class org.vizzini.game.boardgame.action.AbstractMoveAction
clear, prettyPrint, setFromPosition
 
Methods inherited from class org.vizzini.game.boardgame.action.AbstractGridBoardAction
getGridBoard, setGridBoard, setToPosition
 
Methods inherited from class org.vizzini.game.action.AbstractAction
getAgent, getRating, setAgent, setRating
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.boardgame.action.IGridBoardAction
getGridBoard
 
Methods inherited from interface org.vizzini.game.action.IAction
getAgent, getRating, setAgent, setRating
 

Constructor Detail

CastleAction

protected CastleAction(IChessEnvironment board,
                       IChessAgent agent,
                       IntegerPosition kingFromPosition,
                       IntegerPosition kingToPosition,
                       IntegerPosition rookFromPosition,
                       IntegerPosition rookToPosition)
Construct this object with the given arguments.

Parameters:
board - Chess board. (required)
agent - The agent making this action. (required)
kingFromPosition - The king from position. (required)
kingToPosition - The king to position. (required)
rookFromPosition - The rook from position. (required)
rookToPosition - The rook to position. (required)
Since:
v0.3
Method Detail

get

public static CastleAction get(IChessEnvironment board,
                               IChessAgent agent,
                               IntegerPosition kingFromPosition,
                               IntegerPosition kingToPosition,
                               IntegerPosition rookFromPosition,
                               IntegerPosition rookToPosition)
Return an instance of this class using the given parameters.

Since:
v0.3

poolReport

public static void poolReport()
Log a statistics report.

Since:
v0.3

compareTo

public int compareTo(Object object)
Compare this to the given object.

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class AbstractMoveAction
Returns:
-1,0,1 if this is less than, equal to, greater than object.
Throws:
ClassCastException - if another is not an instance of AbstractAction.
Since:
v0.3

doIt

public boolean doIt()
Perform the command encapsulated by this object.

Specified by:
doIt in interface IAction
Overrides:
doIt in class AbstractAction
Returns:
true if sucessful and can be undone.
Since:
v0.3

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface IAction
Overrides:
equals in class AbstractMoveAction
Parameters:
object - The object to compare.
Since:
v0.3

getFromPosition

public IntegerPosition getFromPosition()
Specified by:
getFromPosition in interface IMoveAction
Overrides:
getFromPosition in class AbstractMoveAction
Returns:
Returns the fromPosition.
Since:
v0.3

getKingFromPosition

public IntegerPosition getKingFromPosition()
Returns:
Return kingFromPosition.
Since:
v0.3

getKingToPosition

public IntegerPosition getKingToPosition()
Returns:
Return kingToPosition.
Since:
v0.3

getRookFromPosition

public IntegerPosition getRookFromPosition()
Return the Rook from position.

Since:
v0.3

getRookToPosition

public IntegerPosition getRookToPosition()
Return the Rook to position.

Since:
v0.3

getToPosition

public IntegerPosition getToPosition()
Specified by:
getToPosition in interface IGridBoardAction
Overrides:
getToPosition in class AbstractGridBoardAction
Returns:
Returns the toPosition.
Since:
v0.3

hashCode

public int hashCode()
Returns a hash code value for the object.

Specified by:
hashCode in interface IAction
Overrides:
hashCode in class AbstractMoveAction
Since:
v0.3

release

public void release()
Return this instance to the reusable object pool.

Specified by:
release in interface IAction
Overrides:
release in class AbstractAction
Since:
v0.3

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class AbstractAction
Since:
v0.3

undoIt

public boolean undoIt()
Undo the last invocation of doIt.

Specified by:
undoIt in interface IAction
Overrides:
undoIt in class AbstractAction
Returns:
true if the undo was successful.
Since:
v0.3

set

protected void set(IChessEnvironment board,
                   IChessAgent agent,
                   IntegerPosition kingFromPosition,
                   IntegerPosition kingToPosition,
                   IntegerPosition rookFromPosition,
                   IntegerPosition rookToPosition)
Set parameters on this object.

Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02