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:
@ -1,5 +1,7 @@
|
||||
package suicideChess;
|
||||
|
||||
import suicideChess.Square.NotAValidSquare;
|
||||
|
||||
/**
|
||||
* @author djib
|
||||
*
|
||||
@ -58,11 +60,47 @@ public class Board {
|
||||
|
||||
/***************
|
||||
* CONSTRUCTOR *
|
||||
* @throws NotAValidSquare
|
||||
***************/
|
||||
|
||||
public Board() {
|
||||
public Board() throws NotAValidSquare {
|
||||
bitBoards = new long[NB_OF_BITBOARDS];
|
||||
addPiece(new Square("a1"),new Piece(Piece.WHITE_ROOK));
|
||||
addPiece(new Square("b1"),new Piece(Piece.WHITE_KNIGHT));
|
||||
addPiece(new Square("c1"),new Piece(Piece.WHITE_BISHOP));
|
||||
addPiece(new Square("d1"),new Piece(Piece.WHITE_QUEEN));
|
||||
addPiece(new Square("e1"),new Piece(Piece.WHITE_KING));
|
||||
addPiece(new Square("f1"),new Piece(Piece.WHITE_BISHOP));
|
||||
addPiece(new Square("g1"),new Piece(Piece.WHITE_KNIGHT));
|
||||
addPiece(new Square("h1"),new Piece(Piece.WHITE_ROOK));
|
||||
|
||||
addPiece(new Square("a2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("b2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("c2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("d2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("e2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("f2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("g2"),new Piece(Piece.WHITE_PAWN));
|
||||
addPiece(new Square("h2"),new Piece(Piece.WHITE_PAWN));
|
||||
|
||||
addPiece(new Square("a8"),new Piece(Piece.BLACK_ROOK));
|
||||
addPiece(new Square("b8"),new Piece(Piece.BLACK_KNIGHT));
|
||||
addPiece(new Square("c8"),new Piece(Piece.BLACK_BISHOP));
|
||||
addPiece(new Square("d8"),new Piece(Piece.BLACK_QUEEN));
|
||||
addPiece(new Square("e8"),new Piece(Piece.BLACK_KING));
|
||||
addPiece(new Square("f8"),new Piece(Piece.BLACK_BISHOP));
|
||||
addPiece(new Square("g8"),new Piece(Piece.BLACK_KNIGHT));
|
||||
addPiece(new Square("h8"),new Piece(Piece.BLACK_ROOK));
|
||||
|
||||
addPiece(new Square("a7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("b7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("c7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("d7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("e7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("f7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("g7"),new Piece(Piece.BLACK_PAWN));
|
||||
addPiece(new Square("h7"),new Piece(Piece.BLACK_PAWN));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -70,15 +108,24 @@ public class Board {
|
||||
* METHODS *
|
||||
***********/
|
||||
|
||||
private long getBitBoard(int bitboard_number) {
|
||||
public void doMove(Move move) throws NoPieceOnSquare {
|
||||
if (move.isCaptureMove()) {
|
||||
removePiece(move.toSquare(), move.getCapturedPiece());
|
||||
}
|
||||
removePiece(move.fromSquare(), move.getMovingPiece());
|
||||
if (move.isPromotionMove()) {
|
||||
addPiece(move.toSquare(), move.getPromotionPiece());
|
||||
} else {
|
||||
addPiece(move.toSquare(), move.getMovingPiece());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private long getBitBoard(int bitboard_number) {
|
||||
return bitBoards[bitboard_number];
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
private void updateBitBoards(String move) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
||||
private int squareToBitBoardSquare(Square square) {
|
||||
//converts a square ("e2") to a BitboardSquare (
|
||||
|
Reference in New Issue
Block a user