Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

antichess
Class Move  view Move download Move.java

java.lang.Object
  extended byantichess.Move

public class Move
extends java.lang.Object

A move consists of a start and destination location, and information about whether the move is a capture move, switch, en passant, a castling move, a pawn moving 2 squares, or a promotion. Move is mutable. A move can be undone using Piece.undoMove. The move must passed into undoMove must be the same move pass into makeMove, because makeMove will store additional information necessary for undo in the move after applying the move.


Field Summary
(package private) static int captureMASK
           
(package private) static int castleMASK
           
private  int[] col
           
private  int destCol
           
private  int destRow
           
(package private) static int epMASK
           
 int info
           
private  int[] lastCol
           
 Piece[][] lastPieces
           
private  int[] lastRow
           
(package private) static int MASK
           
(package private) static int maxPiecesModified
           
 Piece[] modifiedPieces
           
private  boolean[] moved
           
(package private) static int pawnMASK
           
(package private) static int promoteMASK
           
private  int[] row
           
(package private) static int specialMASK
           
private  int startCol
           
private  int startRow
           
(package private)  java.lang.String string
           
 
Constructor Summary
Move(int startCol, int startRow, int destCol, int destRow)
          Creates a new move from a string representation.
Move(Move m)
          Creates a new move from a given move
Move(java.lang.String str)
          Creates a new move.
 
Method Summary
 void copyFrom(Move m)
          Copy values from a given Move
 boolean equals(Move m)
           
 boolean equals(java.lang.Object o)
          Determine whether this Object is semantically equal to another Object.
 boolean getCapture()
           
 boolean getCastle()
           
private  int getColFromString(java.lang.String str)
           
 int getDestCol()
           
 int getDestRow()
           
 boolean getEp()
           
 Piece[] getModifiedPieces()
           
 boolean getNormal()
           
 boolean getPawn()
           
 boolean getPromote()
           
private  int getRowFromString(java.lang.String str)
           
 boolean getSpecial()
           
 int getStartCol()
           
 int getStartRow()
           
 boolean isValid()
           
private  java.lang.String locationToString(int col, int row)
           
 void restoreLastPieces(Board b)
          Restores the last pieces information to a board
 void restorePieceInfo(Piece p, int i)
          Restore piece information of p at location i
 void setCapture(boolean x)
           
 void setCastle(boolean x)
           
 void setDest(int col, int row)
           
 void setEp(boolean x)
           
private  void setInvalid()
           
 void setLastPieces(Board b)
          Retrieves and stores the last pieces information from a board
 void setPawn(boolean x)
           
 void setPromote(boolean x)
           
 void setSpecial(boolean x)
           
 void setStart(int col, int row)
           
 void storePieceInfo(Piece p, int i)
          Stores piece information of p at location i
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxPiecesModified

static int maxPiecesModified

captureMASK

static int captureMASK

castleMASK

static int castleMASK

specialMASK

static int specialMASK

epMASK

static int epMASK

pawnMASK

static int pawnMASK

promoteMASK

static int promoteMASK

MASK

static int MASK

info

public int info

startRow

private int startRow

startCol

private int startCol

destRow

private int destRow

destCol

private int destCol

modifiedPieces

public Piece[] modifiedPieces

lastPieces

public Piece[][] lastPieces

moved

private boolean[] moved

row

private int[] row

col

private int[] col

lastRow

private int[] lastRow

lastCol

private int[] lastCol

string

java.lang.String string
Constructor Detail

Move

public Move(java.lang.String str)
Creates a new move. This will make copies of the locations.


Move

public Move(int startCol,
            int startRow,
            int destCol,
            int destRow)
Creates a new move from a string representation.


Move

public Move(Move m)
Creates a new move from a given move

Method Detail

setInvalid

private void setInvalid()

copyFrom

public void copyFrom(Move m)
Copy values from a given Move


setCapture

public void setCapture(boolean x)

setCastle

public void setCastle(boolean x)

setSpecial

public void setSpecial(boolean x)

setEp

public void setEp(boolean x)

setPawn

public void setPawn(boolean x)

setPromote

public void setPromote(boolean x)

setStart

public void setStart(int col,
                     int row)

setDest

public void setDest(int col,
                    int row)

setLastPieces

public void setLastPieces(Board b)
Retrieves and stores the last pieces information from a board


storePieceInfo

public void storePieceInfo(Piece p,
                           int i)
Stores piece information of p at location i


isValid

public boolean isValid()

restoreLastPieces

public void restoreLastPieces(Board b)
Restores the last pieces information to a board


restorePieceInfo

public void restorePieceInfo(Piece p,
                             int i)
Restore piece information of p at location i


getModifiedPieces

public Piece[] getModifiedPieces()

getNormal

public boolean getNormal()

getCapture

public boolean getCapture()

getCastle

public boolean getCastle()

getSpecial

public boolean getSpecial()

getEp

public boolean getEp()

getPawn

public boolean getPawn()

getPromote

public boolean getPromote()

getStartRow

public int getStartRow()

getStartCol

public int getStartCol()

getDestRow

public int getDestRow()

getDestCol

public int getDestCol()

equals

public boolean equals(Move m)

equals

public boolean equals(java.lang.Object o)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


locationToString

private java.lang.String locationToString(int col,
                                          int row)

getRowFromString

private int getRowFromString(java.lang.String str)

getColFromString

private int getColFromString(java.lang.String str)