Internet Chess ToolKit
v0.2.0

ictk.boardgame
Class Move

java.lang.Object
  extended byictk.boardgame.Move
Direct Known Subclasses:
ChessMove

public abstract class Move
extends java.lang.Object

A move contains all the necessary components to make a move on the board. Whether it be simply placing a piece at a location, moving pieces around or taking a piece off the board, a Move is the embodyment of a player action for one turn.

The Move is an implementation of a Command Pattern. It is sent to its Board object via the Board.play(Move) or more commonly History.add(Move); (the latter being prefered -- see those methods for a more detailed explaination of why. When execute() is called on the Move it performs all the operations necessary on the Board's state. unexecute() rolls back any changes made by execute().

Move contains mostly references to other objects. From this move there branches a tree of other moves called "continuations". Continuations include the main-line (which was how the official game was played) and a list of variations (where are possible continuations of the game). These can all be accessed through the getContinuationList() method.

There are two two phases to the Move object

1) unverified
The move is but coordinates, not associated with a board or history list. There is no guarentee that the move is valid. Executing a method that relies on valid information will result in an UnexecutedMoveException. This is very rare, however, since most Move objects are verififed and validated immediately upon creation.

2) verified
The move has been executed at least once on the corrisponding board and verified to be a legal move. At this point all information about the move can be assertained including such things as isCheckmate() (for ChessMoves).


Constructor Summary
Move()
           
 
Method Summary
 void dispose()
          reclaims all resources and recursively deletes all branch moves.
 java.lang.String dump()
          for debugging
 Annotation getAnnotation()
          returns an object full of comments on the move or the board position.
abstract  Board getBoard()
           
 ContinuationList getContinuationList()
          returns the ContinuationList of moves that follow this move.
 History getHistory()
           
 Move getNext()
          get the next move in the game history.
 Annotation getPrenotation()
          returns an object full of comments that are supposed to be read before the move these comments are attached to.
 Move getPrev()
          gets the move previous to this move.
 Result getResult()
          returns the current game result on this move.
 boolean hasNext()
          checks to see if there is a main-line continuation from this move.
 boolean isExecuted()
          has this move currently been executed on its board
abstract  boolean isLegal()
           
 boolean isVerified()
          has the move been verified to be legal (this usually follows a successful execute(), though the move might not be isExecuted currently.
 void setAnnotation(Annotation anno)
          by default the annotation object is null.
 void setPrenotation(Annotation anno)
          by default the prenotation object is null.
 void setResult(Result res)
          sets the result.
abstract  java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Move

public Move()
Method Detail

getHistory

public History getHistory()

getBoard

public abstract Board getBoard()

getContinuationList

public ContinuationList getContinuationList()
returns the ContinuationList of moves that follow this move. This can be use for accessing the variations other than the main-line, and ordering the variations.


getPrev

public Move getPrev()
gets the move previous to this move.


hasNext

public boolean hasNext()
checks to see if there is a main-line continuation from this move. ie, a move that follows this move in the actual game.


getNext

public Move getNext()
get the next move in the game history. If the move branches (if there are several variations of the game after this move) then this function returns the main line of descent for this game.


dispose

public void dispose()
reclaims all resources and recursively deletes all branch moves.

Throws:
java.lang.IllegalStateException - if the move is executed

isLegal

public abstract boolean isLegal()

isExecuted

public boolean isExecuted()
has this move currently been executed on its board


isVerified

public boolean isVerified()
has the move been verified to be legal (this usually follows a successful execute(), though the move might not be isExecuted currently.


getPrenotation

public Annotation getPrenotation()
returns an object full of comments that are supposed to be read before the move these comments are attached to.

Returns:
the Annotation objects is an abstract base class so casting is necessary.

setPrenotation

public void setPrenotation(Annotation anno)
by default the prenotation object is null.


getAnnotation

public Annotation getAnnotation()
returns an object full of comments on the move or the board position.

Returns:
the Annotation objects is an abstract base class so casting is necessary.

setAnnotation

public void setAnnotation(Annotation anno)
by default the annotation object is null.


getResult

public Result getResult()
returns the current game result on this move.

Returns:
null if no result has been assigned to this move.

setResult

public void setResult(Result res)
sets the result. Note: a move does not have to be terminal to have a result.


toString

public abstract java.lang.String toString()

dump

public java.lang.String dump()
for debugging


Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .