|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--chesspresso.move.Move
Abstraction of a chess move.
This class provides support for two ways to encode moves:
short
: optimized for speed and memory but cannot be
used to print a SAN (short annotation, see PGN spec).
Contains the following information: from square, to square, capturing,
promotion piece.
Field Summary | |
static short |
BLACK_LONG_CASTLE
|
static short |
BLACK_SHORT_CASTLE
|
static short |
ILLEGAL_MOVE
Representing an illegal move. |
static short |
NO_MOVE
Represents "no move". |
static short |
NUM_OF_OTHER_SPECIALS
Number of special moves which can be defined. |
static int |
NUM_OF_SPECIAL_MOVES
|
static short |
OTHER_SPECIALS
The range [OTHER_SPECIALS,OTHER_SPECIALS+NUM_OF_OTHER_SPECIALS[ is reserved
for clients of Move to define their own special moves. |
static int |
SPECIAL_MOVE
|
static short |
WHITE_LONG_CASTLE
|
static short |
WHITE_SHORT_CASTLE
|
Constructor Summary | |
Move(short move,
int movingPiece,
int colFrom,
int rowFrom,
boolean isCheck,
boolean isMate,
boolean isWhiteMove)
Creates a full move. |
Method Summary | |
static Move |
createCastle(short move,
boolean isCheck,
boolean isMate,
boolean whiteMove)
Convenience method to create a castle move. |
static Move |
createIllegalMove()
Premanufactured illegal move, always returns the same instance. |
static Move |
createLongCastle(int toPlay,
boolean isCheck,
boolean isMate,
boolean whiteMove)
Convenience factory method to create a long castle move. |
static Move |
createShortCastle(int toPlay,
boolean isCheck,
boolean isMate,
boolean whiteMove)
Convenience factory method to create a short castle move. |
boolean |
equals(java.lang.Object obj)
Equality test. |
static java.lang.String |
getBinaryString(short move)
|
int |
getColFrom()
|
static short |
getEPMove(int fromSqi,
int toSqi)
Manufacture an en passant move. |
int |
getFromSqi()
|
static int |
getFromSqi(short move)
|
java.lang.String |
getLAN()
Returns the LAN (long annotation, see PGN spec) of the move, e.g. |
static short |
getLongCastle(int toPlay)
Manufacture a long castle move. |
int |
getMovingPiece()
|
static short |
getPawnMove(int fromSqi,
int toSqi,
boolean capturing,
int promotionPiece)
Manufacture a pawn move. |
int |
getPromo()
|
static int |
getPromotionPiece(short move)
|
static short |
getRegularMove(int fromSqi,
int toSqi,
boolean capturing)
Manufacture a regular move. |
int |
getRowFrom()
|
java.lang.String |
getSAN()
Returns the SAN (short annotation, see PGN spec) of the move, e.g. |
static short |
getShortCastle(int toPlay)
Manufacture a short castle move. |
short |
getShortMoveDesc()
|
static java.lang.String |
getString(short move)
Returns a string representation of the move. |
int |
getToSqi()
|
static int |
getToSqi(short move)
|
boolean |
isCapturing()
|
static boolean |
isCapturing(short move)
|
static boolean |
isCastle(short move)
|
boolean |
isCheck()
|
static boolean |
isEPMove(short move)
|
boolean |
isLongCastle()
|
static boolean |
isLongCastle(short move)
|
boolean |
isMate()
|
boolean |
isPromotion()
|
static boolean |
isPromotion(short move)
|
boolean |
isShortCastle()
|
static boolean |
isShortCastle(short move)
|
static boolean |
isSpecial(short move)
|
boolean |
isValid()
|
static boolean |
isValid(short move)
|
boolean |
isWhiteMove()
|
static void |
normalizeOrder(short[] moves)
Returns the moves in a normalized order such that the same set of moves always yields the same order. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int SPECIAL_MOVE
public static final int NUM_OF_SPECIAL_MOVES
public static final short WHITE_SHORT_CASTLE
public static final short WHITE_LONG_CASTLE
public static final short BLACK_SHORT_CASTLE
public static final short BLACK_LONG_CASTLE
public static final short NO_MOVE
public static final short ILLEGAL_MOVE
public static final short OTHER_SPECIALS
[OTHER_SPECIALS,OTHER_SPECIALS+NUM_OF_OTHER_SPECIALS[
is reserved
for clients of Move to define their own special moves. This can be used
to indicate special conditions when a move is expected. Moves of the
range above do not collide whith any other moves.
public static final short NUM_OF_OTHER_SPECIALS
Constructor Detail |
public Move(short move, int movingPiece, int colFrom, int rowFrom, boolean isCheck, boolean isMate, boolean isWhiteMove)
move
- the short movemovingPiece
- the piece movingcolFrom
- file if should be taken for SAN, NO_COL
otherwiserowFrom
- rank if should be taken for SAN, NO_ROW
otherwiseisCheck
- whether the move gives a checkisMate
- whether the move sets mateMethod Detail |
public static void normalizeOrder(short[] moves)
public static short getRegularMove(int fromSqi, int toSqi, boolean capturing)
fromSqi
- the from squaretoSqi
- the to squarecapturing
- whether or not it is a capturing movepublic static short getPawnMove(int fromSqi, int toSqi, boolean capturing, int promotionPiece)
fromSqi
- the from squaretoSqi
- the to squarecapturing
- whether or not it is a capturing movepromotionPiece
- set to a piece if it is a promotion move, set to No_PIECE
otherwisepublic static short getEPMove(int fromSqi, int toSqi)
fromSqi
- the from squaretoSqi
- the to squarepublic static short getShortCastle(int toPlay)
toPlay
- for which colorpublic static short getLongCastle(int toPlay)
toPlay
- for which colorpublic static final int getFromSqi(short move)
public static final int getToSqi(short move)
public static final boolean isCapturing(short move)
public static final boolean isPromotion(short move)
public static final int getPromotionPiece(short move)
public static final boolean isEPMove(short move)
public static boolean isCastle(short move)
public static boolean isShortCastle(short move)
public static boolean isLongCastle(short move)
public static boolean isSpecial(short move)
public static boolean isValid(short move)
public static java.lang.String getBinaryString(short move)
public static java.lang.String getString(short move)
public static Move createIllegalMove()
public static Move createCastle(short move, boolean isCheck, boolean isMate, boolean whiteMove)
move
- a castling move to based upon, must be a castling moveisCheck
- whether the move gives a checkisMate
- whether the move sets mate
public static Move createShortCastle(int toPlay, boolean isCheck, boolean isMate, boolean whiteMove)
toPlay
- the moving playerisCheck
- whether the move gives a checkisMate
- whether the move sets mate
public static Move createLongCastle(int toPlay, boolean isCheck, boolean isMate, boolean whiteMove)
toPlay
- the moving playerisCheck
- whether the move gives a checkisMate
- whether the move sets mate
public short getShortMoveDesc()
public int getPromo()
public int getFromSqi()
public int getToSqi()
public int getMovingPiece()
public int getColFrom()
public int getRowFrom()
public boolean isCapturing()
public boolean isPromotion()
public boolean isCheck()
public boolean isMate()
public boolean isShortCastle()
public boolean isLongCastle()
public boolean isValid()
public boolean isWhiteMove()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare against
public java.lang.String getLAN()
public java.lang.String getSAN()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |