This is a first version where it is possible to play in console.

Rules are not implemented and program crashes when moving a piece that does not
exit or when trying to capture our own pieces...
This commit is contained in:
2006-01-07 16:34:40 +00:00
parent 08c973a452
commit 5bd6db4b06
7 changed files with 327 additions and 75 deletions

View File

@ -23,24 +23,31 @@ public class Piece {
* Take really good care if you want to change those values
* Class BitBoard makes intensive use of those
*/
public static final int NONE=-1;
//Contants used to detect color
public static final int WHITE=0;
public static final int BLACK=1;
//Constants used in the board representation
public static final int WHITE_PIECE = WHITE;
public static final int BLACK_PIECE = BLACK;
public static final int WHITE_PAWN = 2;
public static final int BLACK_PAWN = 3;
public static final int WHITE_KING = 4;
public static final int BLACK_KING = 5;
public static final int WHITE_QUEEN = 6;
public static final int BLACK_QUEEN = 7;
public static final int WHITE_BISHOP = 8;
public static final int BLACK_BISHOP = 9;
public static final int WHITE_KNIGHT = 10;
public static final int BLACK_KNIGHT = 11;
public static final int WHITE_ROOK = 12;
public static final int BLACK_ROOK = 13;
public static final int PAWN = 2;
public static final int WHITE_PAWN = PAWN + WHITE;
public static final int BLACK_PAWN = PAWN + BLACK;
public static final int KING = 4;
public static final int WHITE_KING = KING + WHITE;
public static final int BLACK_KING = KING + BLACK;
public static final int QUEEN = 6;
public static final int WHITE_QUEEN = QUEEN + WHITE;
public static final int BLACK_QUEEN = QUEEN + BLACK;
public static final int BISHOP = 8;
public static final int WHITE_BISHOP = BISHOP + WHITE;
public static final int BLACK_BISHOP = BISHOP + BLACK;
public static final int KNIGHT = 10;
public static final int WHITE_KNIGHT = KNIGHT + WHITE;
public static final int BLACK_KNIGHT = KNIGHT + BLACK;
public static final int ROOK = 12;
public static final int WHITE_ROOK = ROOK + WHITE;
public static final int BLACK_ROOK = ROOK + BLACK;
//Constants used for promotion (as used in the xboard protocol)
@ -49,12 +56,14 @@ public class Piece {
public static final char BISHOP_CHAR='b';
public static final char KNIGHT_CHAR='n';
public static final char ROOK_CHAR='r';
//may be useful
public static final char PAWN_CHAR='p';
/****************
* PRIVATE DATA *
****************/
private static int pieceNumber;
private int pieceNumber;
/***************
* CONSTRUCTOR *
@ -64,6 +73,30 @@ public class Piece {
pieceNumber = piece;
}
public Piece(char piece, int color) {
pieceNumber = NONE;
switch (piece) {
case PAWN_CHAR:
pieceNumber = PAWN + color;
break;
case KING_CHAR:
pieceNumber = KING + color;
break;
case QUEEN_CHAR:
pieceNumber = QUEEN + color;
break;
case BISHOP_CHAR:
pieceNumber = BISHOP + color;
break;
case KNIGHT_CHAR:
pieceNumber = KNIGHT + color;
break;
case ROOK_CHAR:
pieceNumber = ROOK + color;
break;
}
}
/***********
* METHODS *
***********/