|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--net.sourceforge.foobase.Move
Implements one single move.
The implementation of a move includes not only information about which piece moves on the board, but also variations, annotations etc.
Board-cells are numbered 0 up to 63. Currently, Board
uses the convention that cell a1 is 0, a8 is 7,
b1 is 8 etc. up to h8 having code 63.
| Field Summary | |
static java.lang.String |
__version
|
protected java.lang.String |
_annotation
Annotation string. |
protected Board |
_board
Board setup to which this move applies. |
protected int |
_castle
Switch indicating castling and, if so, if it is on the king-side (code 1) or on the queen-side (code 2). |
protected java.lang.String |
_eval
Evaluation string (e.g. |
protected int |
_from
Start position (in the range 0 to 63) |
protected java.lang.String |
_moveval
Move evaluation (e.g. |
protected boolean |
_needs_diagram
Diagram required in notation? |
protected java.lang.String |
_poseval
Position evalutation string (e.g. |
protected int |
_prom
Code for new piece, in case of pawn promotion. |
protected int |
_to
End position (in the range 0 to 63) |
protected java.util.Vector |
_vars
Variations on this move. |
static byte |
PC_EMPTY
Code for an empty square in the board structure. |
static byte |
PC_PAWN
Code for a pawn in the board structure. |
static byte |
PC_TYPE_MASK
Mask for just the piece code without color information |
| Constructor Summary | |
Move()
Default public constructor. |
|
Move(int from,
int to,
int prom,
int castle)
Public constructor. |
|
| Method Summary | |
void |
addVariation(java.util.Vector var)
Add a variation. |
boolean |
equals(java.lang.Object o)
Compare two moves for equality. |
java.lang.String |
formatMove(int halfmove,
boolean first)
Format move for human readable output. |
java.lang.String |
formatMove(int halfmove,
boolean first,
byte[] cells)
Format move for human readable output. |
java.lang.String |
getAnnotation()
Get annotation text for this move. |
Board |
getBoard()
Get board setup to which this move applies. |
java.lang.String |
getEvaluation()
Get evaluation string (e.g. |
int |
getFrom()
Retrieve start position of move. |
java.lang.String |
getMoveEvaluation()
Get the move evaluation string (e.g. |
java.lang.String |
getPositionEvaluation()
Get position evalutation string (e.g. |
int |
getPromotedPiece()
Retrieve code for piece in case of pawn promotion. |
int |
getTo()
Retrieve end position of move. |
java.util.Vector |
getVariations()
Get all registered variations. |
boolean |
hasVariations()
Test if this move has variations registered. |
boolean |
isAnnotated()
Check if there is any form of annotation available for this move. |
boolean |
isCastling()
Test if this is a castling operation. |
boolean |
isKingCastling()
Test if this is a king-side castling operation. |
boolean |
isPromotion()
Test if this is a pawn promotion. |
boolean |
isQueenCastling()
Test if this is a queen-side castling operation. |
boolean |
needsDiagram()
Test if a diagram is to be part of the annotation. |
void |
setAnnotation(java.lang.String txt)
Set annotation text for this move. |
void |
setBoard(Board b)
Set board to which this move applies. |
void |
setDiagram(boolean b)
Set if a diagram is to be part of the annotation. |
void |
setEvaluation(java.lang.String txt)
Set evaluation string (e.g. |
void |
setMoveEvaluation(java.lang.String txt)
Set the move evaluation string (e.g. |
void |
setPositionEvaluation(java.lang.String txt)
Set position evalutation string (e.g. |
java.lang.String |
toString()
Convert move to string format. |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
public static final byte PC_TYPE_MASK
public static final byte PC_EMPTY
public static final byte PC_PAWN
protected int _from
protected int _to
protected int _prom
protected int _castle
protected java.lang.String _eval
protected java.lang.String _poseval
protected java.lang.String _moveval
protected java.lang.String _annotation
protected boolean _needs_diagram
protected java.util.Vector _vars
Each element is itself a Vector containing the moves
for that variation.
protected Board _board
Storing that info in the move objects allows easier navigation through a game (undoing and redoing moves)
public static final java.lang.String __version
| Constructor Detail |
public Move()
public Move(int from,
int to,
int prom,
int castle)
from - int containing the start-position of the moveto - int containing the end-position of the moveprom - int containing the code for the piece a pawn
promotes into (or zero for no promotion)castle - int containing a code indicating in which
direction is being castled: 0 means no castling, 1 means 0-0 and 2 means
0-0-0| Method Detail |
public void setBoard(Board b)
This method stores a local copy of the board, not just a reference to it.
b - Board to which this move applies.public Board getBoard()
The returned information is not just a reference but a full copy of the board setup.
Board setup to which this move applies or
null if none is specified.public boolean equals(java.lang.Object o)
o - Object to compare againstboolean value true if o
represents the same move as the current object.public int getFrom()
int containing the start position of this movepublic int getTo()
int containing the end position of this movepublic boolean isPromotion()
boolean value true if this is a
pawn promotion.public int getPromotedPiece()
The possible return values are:
int containing the code for piece in case of
pawn promotion.public boolean isCastling()
boolean value true if this is a
castling operation.public boolean isKingCastling()
boolean value true if this is a
king-side castling operation.public boolean isQueenCastling()
boolean value true if this is a
queen-side castling operation.public void setDiagram(boolean b)
b - boolean value true is a diagram is
to be generated when the annotation of this move is produced.public boolean needsDiagram()
boolean value true is a diagram is
to be generated when the annotation of this move is produced.public boolean isAnnotated()
boolean value true if at least one
of the different annotation or evaluation strings is non-empty.public void setAnnotation(java.lang.String txt)
If the first character of the annotation string is 0xed04,
a diagram will be part of the full notation of this move.
That special character is not part of the annotation string obtained by
getAnnotation().
txt - String containing the annotation textpublic java.lang.String getAnnotation()
String containing the annotation text for this
move. Note that this string will not contain the
special character used elsewhere for denoting the need of a diagram
(that is 0xed04). If no annotation is available, null is
returned.public void addVariation(java.util.Vector var)
var - Vector containing a variation on this move.
The vector elements are themeselves of the type Move.public boolean hasVariations()
boolean value true if there is at
least one variation.public java.util.Vector getVariations()
Vector of Move elements where
each move represents one variation on the current move.public void setEvaluation(java.lang.String txt)
txt - String containing the move evaluationpublic java.lang.String getEvaluation()
String containing the non-null move evaluationpublic void setPositionEvaluation(java.lang.String txt)
txt - String containing the position evalutation
stringpublic java.lang.String getPositionEvaluation()
String containing the non-null position evalutation
stringpublic void setMoveEvaluation(java.lang.String txt)
txt - String containing the move evaluation stringpublic java.lang.String getMoveEvaluation()
txt - String containing the non-null move evaluation
string
public java.lang.String formatMove(int halfmove,
boolean first)
For now, the long notation is used and no mentioning of checks is added to the output.
The halfmove parameter contains both information about the move number and the side to play.
halfmove - int containing the number of the halfmove
that is represented by the current Move (first move of
the game is halfmove zero)first - boolean value true if this
move is either the first of the game or the first of a variation.String containing the human readable representation
of this Move.
public java.lang.String formatMove(int halfmove,
boolean first,
byte[] cells)
For now, the long notation is used and no mentioning of checks is added to the output.
The halfmove parameter contains both information about the move number and the side to play.
halfmove - int containing the number of the halfmove
that is represented by the current Move (first move of
the game is halfmove zero)first - boolean value true if this
move is either the first of the game or the first of a variation.cells - byte[] containing the current pieces setup
or null if no such information is available.String containing the human readable representation
of this Move.public java.lang.String toString()
This method is primarily intended for debugging puropses.
String containing the move properties in human
readable format.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||