|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--chesspresso.Chess
General chess-specific definition.
The following methods are used often throughout the higher-level classes and are therefore implemented as simple as possible. Sometimes, checking for illegal arguments is left to the caller for optimized performance.
To del with squares, the concepts of square, column, and row index are introduced. A square index is a number our of [0..63], a column (file) and row (rank) are out of [0..7].
A piece is an uncolored type of chessman, a stone is a piece plus a colored. For instance, possible pieces would be: a knight, a pawn, a king. Possible stones are: a white queen, a black pawn. Possible colors (or players) are: white, black and nobody.
Field Summary | |
static int |
A1
|
static int |
A2
|
static int |
A3
|
static int |
A4
|
static int |
A5
|
static int |
A6
|
static int |
A7
|
static int |
A8
|
static int |
B1
|
static int |
B2
|
static int |
B3
|
static int |
B4
|
static int |
B5
|
static int |
B6
|
static int |
B7
|
static int |
B8
|
static short |
BISHOP
|
static int |
BLACK
|
static short |
BLACK_BISHOP
|
static short |
BLACK_KING
|
static short |
BLACK_KNIGHT
|
static short |
BLACK_PAWN
|
static short |
BLACK_QUEEN
|
static short |
BLACK_ROOK
|
static int |
C1
|
static int |
C2
|
static int |
C3
|
static int |
C4
|
static int |
C5
|
static int |
C6
|
static int |
C7
|
static int |
C8
|
static int |
D1
|
static int |
D2
|
static int |
D3
|
static int |
D4
|
static int |
D5
|
static int |
D6
|
static int |
D7
|
static int |
D8
|
static int |
E1
|
static int |
E2
|
static int |
E3
|
static int |
E4
|
static int |
E5
|
static int |
E6
|
static int |
E7
|
static int |
E8
|
static int |
F1
|
static int |
F2
|
static int |
F3
|
static int |
F4
|
static int |
F5
|
static int |
F6
|
static int |
F7
|
static int |
F8
|
static int |
G1
|
static int |
G2
|
static int |
G3
|
static int |
G4
|
static int |
G5
|
static int |
G6
|
static int |
G7
|
static int |
G8
|
static int |
H1
|
static int |
H2
|
static int |
H3
|
static int |
H4
|
static int |
H5
|
static int |
H6
|
static int |
H7
|
static int |
H8
|
static short |
KING
|
static short |
KNIGHT
|
static short |
MAX_PIECE
|
static short |
MAX_STONE
|
static short |
MIN_PIECE
|
static short |
MIN_STONE
|
static int |
NO_COL
|
static short |
NO_PIECE
|
static int |
NO_RES
|
static int |
NO_ROW
|
static int |
NO_SQUARE
|
static short |
NO_STONE
|
static int |
NOBODY
|
static int |
NUM_OF_COLS
|
static int |
NUM_OF_ROWS
|
static int |
NUM_OF_SQUARES
|
static short |
PAWN
|
static char[] |
pieceChars
|
static short |
QUEEN
|
static int |
RES_BLACK_WINS
|
static int |
RES_DRAW
|
static int |
RES_NOT_FINISHED
|
static int |
RES_WHITE_WINS
|
static short |
ROOK
|
static int |
WHITE
|
static short |
WHITE_BISHOP
|
static short |
WHITE_KING
|
static short |
WHITE_KNIGHT
|
static short |
WHITE_PAWN
|
static short |
WHITE_QUEEN
|
static short |
WHITE_ROOK
|
Constructor Summary | |
Chess()
|
Method Summary | |
static int |
charToCol(char ch)
Returns the column represented by the character. |
static int |
charToPiece(char ch)
Converts a character to a piece. |
static int |
charToRow(char ch)
Returns the row represented by the character. |
static char |
colToChar(int col)
Returns the character of a column (file): 'a'..' |
static int |
coorToSqi(int col,
int row)
Converts coordinates to square index. |
static int |
deltaCol(int sqi1,
int sqi2)
Returns the column difference from one square index to the other. |
static int |
deltaRow(int sqi1,
int sqi2)
Returns the row difference from one square index to the other. |
static int |
getOpponentStone(int stone)
Change the color of the stone. |
static boolean |
isWhitePly(int plyNumber)
Returns whether it is white move at the given ply. |
static boolean |
isWhiteSquare(int sqi)
Returns whether the square is white. |
static int |
otherPlayer(int player)
Returns the opposite player. |
static char |
pieceToChar(int piece)
Returns a character representing the piece. |
static int |
pieceToStone(int piece,
int color)
Converts a piece, color pair to a stone. |
static int |
plyToMoveNumber(int plyNumber)
Converts a ply to a move number |
static char |
rowToChar(int row)
Returns the character of a row (rank): '1'..'8'. |
static int |
sqiToCol(int sqi)
Extract the column of a square index. |
static int |
sqiToRow(int sqi)
Extract the row of a square index. |
static java.lang.String |
sqiToStr(int sqi)
Returns the algebraic representation of a square "a1".." |
static boolean |
stoneHasColor(int stone,
int color)
Check whether the stone is of a certain color. |
static char |
stoneToChar(int stone)
Returns a character representing the stone. |
static int |
stoneToColor(int stone)
Extracts the color of a stone. |
static int |
stoneToPiece(int stone)
Converts a stone to a piece (remove color info). |
static int |
strToSqi(char colCh,
char rowCh)
Converts a col and row character pair to a square index. |
static int |
strToSqi(java.lang.String s)
Converts a square representation to a square index. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NUM_OF_COLS
public static final int NUM_OF_ROWS
public static final int NUM_OF_SQUARES
public static final int RES_WHITE_WINS
public static final int RES_DRAW
public static final int RES_BLACK_WINS
public static final int RES_NOT_FINISHED
public static final int NO_RES
public static final int A8
public static final int B8
public static final int C8
public static final int D8
public static final int E8
public static final int F8
public static final int G8
public static final int H8
public static final int A7
public static final int B7
public static final int C7
public static final int D7
public static final int E7
public static final int F7
public static final int G7
public static final int H7
public static final int A6
public static final int B6
public static final int C6
public static final int D6
public static final int E6
public static final int F6
public static final int G6
public static final int H6
public static final int A5
public static final int B5
public static final int C5
public static final int D5
public static final int E5
public static final int F5
public static final int G5
public static final int H5
public static final int A4
public static final int B4
public static final int C4
public static final int D4
public static final int E4
public static final int F4
public static final int G4
public static final int H4
public static final int A3
public static final int B3
public static final int C3
public static final int D3
public static final int E3
public static final int F3
public static final int G3
public static final int H3
public static final int A2
public static final int B2
public static final int C2
public static final int D2
public static final int E2
public static final int F2
public static final int G2
public static final int H2
public static final int A1
public static final int B1
public static final int C1
public static final int D1
public static final int E1
public static final int F1
public static final int G1
public static final int H1
public static final int NO_COL
public static final int NO_ROW
public static final int NO_SQUARE
public static final short MIN_PIECE
public static final short MAX_PIECE
public static final short KING
public static final short PAWN
public static final short QUEEN
public static final short ROOK
public static final short BISHOP
public static final short KNIGHT
public static final short NO_PIECE
public static final short MIN_STONE
public static final short MAX_STONE
public static final short WHITE_KING
public static final short WHITE_PAWN
public static final short WHITE_QUEEN
public static final short WHITE_ROOK
public static final short WHITE_BISHOP
public static final short WHITE_KNIGHT
public static final short BLACK_KING
public static final short BLACK_PAWN
public static final short BLACK_QUEEN
public static final short BLACK_ROOK
public static final short BLACK_BISHOP
public static final short BLACK_KNIGHT
public static final short NO_STONE
public static final char[] pieceChars
public static final int WHITE
public static final int BLACK
public static final int NOBODY
Constructor Detail |
public Chess()
Method Detail |
public static final int coorToSqi(int col, int row)
col
- the column (file)row
- the row (rank)
public static final int sqiToRow(int sqi)
sqi
- the square index
public static final int sqiToCol(int sqi)
sqi
- the square index
public static final int deltaRow(int sqi1, int sqi2)
sqi1
- the one square indexsqi2
- the other square index
public static final int deltaCol(int sqi1, int sqi2)
sqi1
- the one square indexsqi2
- the other square index
public static final char colToChar(int col)
col
- the column
public static final char rowToChar(int row)
public static final java.lang.String sqiToStr(int sqi)
sqi
- the square
public static final boolean isWhiteSquare(int sqi)
sqi
- the square
public static final int charToCol(char ch)
ch
- the column character ('a'..'h')
NO_COL
if an illegal character is passedpublic static final int charToRow(char ch)
ch
- the row character ('1'..'8')
NO_ROW
if an illegal character is passedpublic static final int strToSqi(java.lang.String s)
s
- the algebraic square representation
NO_SQUARE
if an illegal string is passedpublic static final int strToSqi(char colCh, char rowCh)
NO_SQUARE
if an illegal character is passedpublic static final int stoneToColor(int stone)
stone
- the colored piece
public static final boolean stoneHasColor(int stone, int color)
stone
- the colored piececolor
- the color to test for
public static final int stoneToPiece(int stone)
stone
- the colored piece
public static final int getOpponentStone(int stone)
stone
- the colored piece
public static final int charToPiece(char ch)
ch
- a piece character
NO_PIECE
if illegalpublic static final char pieceToChar(int piece)
piece
- the piece
public static final char stoneToChar(int stone)
stone
- the stone
public static final int pieceToStone(int piece, int color)
piece
- the piececolor
- the color
NO_PIECE
if illegalpublic static final int otherPlayer(int player)
player
- the player (or color)
public static boolean isWhitePly(int plyNumber)
plyNumber
- the ply number, starting at 0public static int plyToMoveNumber(int plyNumber)
plyNumber
- the ply number, starting at 0
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |