Version 0.7.9

=============
Added open book
Added a weighted static evaluation function where
  the position of each piece is important
This commit is contained in:
2006-07-02 18:29:29 +00:00
parent b02755be4e
commit 8a641a6e1e
6 changed files with 231 additions and 36 deletions

View File

@ -32,12 +32,6 @@ public class Board {
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_PAWNS = 3;
//with less than that many pieces on one side, the computer will enter endgame mode
public static final int ENDGAME_PIECES = 6;
@SuppressWarnings("serial")
public class NoPieceOnSquare extends Exception {
NoPieceOnSquare(String s) { super(s); };
@ -74,16 +68,34 @@ public class Board {
/**
* Importance of real mobility in position evaluation (ie. how many moves can one make compared to the other)
*/
public static final int REAL_MOBILITY_VALUE = 10;
public static final int REAL_MOBILITY_VALUE = 1000; //10;
/**
* Importance of relative mobility (mobility of other pieces that may not be able to play because of a compulsory move)
*/
public static final int RELATIVE_MOBILITY_VALUE = 5;
public static final int RELATIVE_MOBILITY_VALUE = 1000; //5;
//with less than that many pawns on one side, the computer will enter endgame mode
public static final int ENDGAME_PAWNS = 3;
//with less than that many pieces on one side, the computer will enter endgame mode
public static final int ENDGAME_PIECES = 8;
public static final int[] SQUARE_WEIGHT = {
-20, -10, -10, -10, -10, -10, -10, -20,
-10, 0, 3, 5, 5, 3, 0, -10,
-10, 2, 15, 15, 15, 15, 2, -10,
-10, 7, 15, 25, 25, 15, 7, -10,
-10, 7, 15, 25, 25, 15, 7, -10,
-10, 2, 15, 15, 15, 15, 2, -10,
-10, 0, 3, 5, 5, 3, 0, -10,
-20, -10, -10, -10, -10, -10, -10, -20
};
/*======*
* DATA *
*======*/
//The following table is used to map squares to bits
protected static long mapSquaresToBits[];
@ -421,8 +433,7 @@ public class Board {
public Square getEnPassantSquare() {
return enPassantSquare;
}
/**
* This function returns an integer representing the result of the static evaluation function
* for the current board
@ -619,7 +630,13 @@ public class Board {
} else {
//System.out.println("Playing midgame");
for (int i = Piece.OFFSET; i<=Piece.MAX_PIECE_NUMBER; i++) {
boardValue += numberOfPieces[i]*Piece.PIECE_VALUE_MIDDLEGAME[i];
//boardValue += numberOfPieces[i]*Piece.PIECE_VALUE_MIDDLEGAME[i];
for(int squareNb = 0; squareNb<NB_OF_SQUARES; squareNb++) {
Piece pieceOnSquare = getPiece(new Square(squareNb));
if(pieceOnSquare.getPieceNumber()!=Piece.NONE) {
boardValue += SQUARE_WEIGHT[squareNb]*Piece.PIECE_VALUE_MIDDLEGAME[pieceOnSquare.getColor()];
}
}
}
boardValue += ((mobility(Piece.WHITE)-mobility(Piece.BLACK)));
}