com.editev.chess
Class Move

java.lang.Object
  |
  +--com.editev.chess.Move

public class Move
extends java.lang.Object
implements java.lang.Cloneable

Represents a move in the game of chess. A move is identified with its start square. There's also a target square, and perhaps a promotion piece. This class is used promiscuously as an interator, perhaps the ultimate reverse of an immutable class.

See Also:
the source here.

Field Summary
 byte index
          Index the move in the series of offsets in the Piece.
 byte promotion
          What piece is being created if this move is a promotion? Most of the time, Moves are not promotions and this field is wasted.
 Square source
          The target square that this move is going to.
 Square target
          The target square that this move is going to.
 
Constructor Summary
Move()
           
 
Method Summary
 java.lang.Object clone()
          Clone this Move as an Object.
 Move cloneMove()
          Clone this Move as a Move.
 void copyFrom(Move move)
          Copy the contents of another Move into this Move.
 boolean equals(java.lang.Object object)
          Two Moves are equal if they are equal as squares and their targets are equal as Squares.
 void resetPromotion()
          Reset the promotion variable to the start.
 java.lang.String toString()
          Represent the Move as the source and target Squares.
 
Methods inherited from class java.lang.Object
, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

source

public final Square source
The target square that this move is going to.

target

public final Square target
The target square that this move is going to.

index

public byte index
Index the move in the series of offsets in the Piece. The Piece manipulates this variable to iterate through all the the offsets that represent possible moves.

promotion

public byte promotion
What piece is being created if this move is a promotion? Most of the time, Moves are not promotions and this field is wasted.
Constructor Detail

Move

public Move()
Method Detail

resetPromotion

public void resetPromotion()
Reset the promotion variable to the start.

equals

public boolean equals(java.lang.Object object)
Two Moves are equal if they are equal as squares and their targets are equal as Squares.
Overrides:
equals in class java.lang.Object

clone

public java.lang.Object clone()
Clone this Move as an Object. @return an Object that clones this Move.
Overrides:
clone in class java.lang.Object

cloneMove

public Move cloneMove()
Clone this Move as a Move. @return a Move that clones this Move.

copyFrom

public void copyFrom(Move move)
Copy the contents of another Move into this Move.

toString

public java.lang.String toString()
Represent the Move as the source and target Squares.
Overrides:
toString in class java.lang.Object