core
Class Move

java.lang.Object
  extended by core.Move

public class Move
extends Object

A Move represents a single player's move on a board. It is immutable, and may mean different things on different boards. A can either be represented by an ordered pair of Positions or by a pass.

Specification Fields
Derived Fields:
boardupdates : Map // How the move changes a board Abstract invariant: either it is a pass or the positions are valid

Constructor Summary
Move()
          Construct the pass move.
Move(Position from, Position to)
           
 
Method Summary
 boolean equals(Object o)
           
static Move fromString(String s)
           
 Position getFrom()
           
 Position getTo()
           
 int hashCode()
           
 boolean isPass()
           
static boolean parseableMove(String s)
           
 Map<Position,Piece> toMap(GameState g)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Move

public Move(Position from,
            Position to)
See Also:
Piece

Move

public Move()
Construct the pass move.

Method Detail

getFrom

public Position getFrom()
Returns:
the Position the move is from

getTo

public Position getTo()
Returns:
the Position the move is to

isPass

public boolean isPass()
Returns:
whether this is a pass

fromString

public static Move fromString(String s)
Parameters:
s - is a String representing an Antichess move
Returns:
a Move representing the same set of changes to the GameState g as the String s. Its toString method will return a String equal to s.
Requires:
s is of the form [position1]-[position2]; that is, two valid and distinct positions separated by a hyphen. For example, a3-a8 is a legal argument to this method. Or, s.equals("") for a pass.

toMap

public Map<Position,Piece> toMap(GameState g)
Parameters:
g - is the gamestate to make this move on
Requires:
g != null and this move is a valid move candidate; the pieces may move as desired, but for possibly not capturing or entering into check.
Returns:
the Map of updates to g to perform this move.

parseableMove

public static boolean parseableMove(String s)
Returns:
true if s is of the form [position1]-[position2]; that is, two valid and distinct positions separated by a hyphen. For example, a3-a8 is a valid move String.

toString

public String toString()
Overrides:
toString in class Object
Returns:
a String representation of this, in the form [position1]-[position2], where position1 and position2 are the old and new positions of the moving piece, respectively. In the case of castling, the King is the "moving" piece. In the case of en passant, the capturing pawn is the "moving" piece.

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object