diff --git a/src/suicideChess/Board.java b/src/suicideChess/Board.java index 92a0d6f..46b2191 100644 --- a/src/suicideChess/Board.java +++ b/src/suicideChess/Board.java @@ -30,6 +30,9 @@ public class Board { public static final int NB_OF_SQUARES = NB_OF_RANKS*NB_OF_FILES; private static final int NB_OF_BITBOARDS = 14; + + //with less than that many pawns on one side, the computer will enter endgame mode + public static final int ENDGAME = 3; @SuppressWarnings("serial") public class NoPieceOnSquare extends Exception { @@ -83,11 +86,11 @@ public class Board { private boolean enPassant=false; //is there an 'en passant pawn' on the board private Square enPassantSquare; - private int numberOfBlackPieces = NB_OF_FILES*2; - private int numberOfWhitePieces = NB_OF_FILES*2; - private int[] numberOfPieces = new int[Piece.MAX_PIECE_NUMBER]; - { numberOfPieces[Piece.BLACK_BISHOP]=2; - } + //the number of each piece type will be accessed + //using the index and the piece value defined in Piece class + private int[] numberOfPieces; + //the value of each piece (used for the evaluation function) + private int boardValue = 0; //evaluation of the board value private int currentPlayer; //color of the current player. @@ -105,6 +108,11 @@ public class Board { //the following line makes sure that enPassantSquare is defined at some point. enPassantSquare = new Square("a1"); + numberOfPieces = new int[Piece.MAX_PIECE_NUMBER+1]; + for (int i=0; i<=Piece.MAX_PIECE_NUMBER; i++) { + numberOfPieces[i]=0; + } + bitBoards = new long[NB_OF_BITBOARDS]; addPiece(new Square("a1"),new Piece(Piece.WHITE_ROOK)); addPiece(new Square("b1"),new Piece(Piece.WHITE_KNIGHT)); @@ -150,8 +158,11 @@ public class Board { */ public Board(Board bitboard) { - this.numberOfBlackPieces = bitboard.numberOfBlackPieces; - this.numberOfWhitePieces = bitboard.numberOfWhitePieces; + numberOfPieces = new int[Piece.MAX_PIECE_NUMBER+1]; + for (int i=0; i<=Piece.MAX_PIECE_NUMBER; i++) { + this.numberOfPieces[i] = bitboard.numberOfPieces[i]; + } + this.boardValue = bitboard.boardValue; this.bitBoards = new long[NB_OF_BITBOARDS]; for (int i=0; i