Skip to content

Commit

Permalink
Automatic tuning patch.
Browse files Browse the repository at this point in the history
3953-3599-4448 in 12000 games at 3+0.02 (10.25 +/- 4.93)
3445-3249-5306 in 12000 games at 15+0.05 (5.68 +/- 4.64)
  • Loading branch information
jeffreyan11 committed Dec 27, 2017
1 parent 0104e21 commit 0571754
Showing 1 changed file with 86 additions and 86 deletions.
172 changes: 86 additions & 86 deletions eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ const int EG = 1;

// Material constants
const int PIECE_VALUES[2][5] = {
{100, 388, 434, 646, 1337},
{140, 391, 443, 705, 1368}
{100, 389, 434, 650, 1339},
{139, 391, 446, 711, 1380}
};
const int KNOWN_WIN = PIECE_VALUES[EG][PAWNS] * 75;
const int TB_WIN = PIECE_VALUES[EG][PAWNS] * 125;
Expand All @@ -106,29 +106,29 @@ const int pieceSquareTable[2][6][32] = {
{
{ // Pawns
0, 0, 0, 0,
30, 38, 54, 64,
19, 34, 52, 55,
6, 12, 16, 28,
29, 38, 54, 64,
19, 34, 52, 58,
8, 12, 16, 28,
-3, -2, 8, 10,
-1, 5, 6, 8,
-1, 8, 3, 0,
0, 0, 0, 0
},
{ // Knights
-110,-36,-28,-19,
-29, -9, 10, 15,
-29, -9, 10, 14,
-12, 4, 18, 25,
9, 9, 21, 25,
0, 9, 16, 19,
-15, 3, 5, 15,
0, 9, 16, 21,
-15, 3, 5, 14,
-22, -9, -4, 6,
-68,-25,-14, -7
-68,-24,-14, -9
},
{ // Bishops
-18,-15,-10,-10,
-20,-15,-10,-10,
-15, -8, -6, 2,
3, 4, 3, 2,
0, 11, 5, 5,
2, 11, 5, 5,
3, 9, 4, 10,
0, 12, 8, 5,
-2, 14, 8, 5,
Expand All @@ -146,13 +146,13 @@ const int pieceSquareTable[2][6][32] = {
},
{ // Queens
-34,-26,-17,-11,
-11,-24, -7, -4,
-11,-23, -7, -4,
-3, 0, 0, 2,
-3, -3, -3, -6,
-3, -3, -3, -6,
-5, 4, -4, -3,
-8, -2, 5, 5,
-13, -8, -5, 5
-11, 0, 5, 4,
-16,-11, -7, 5
},
{ // Kings
-42,-37,-39,-41,
Expand All @@ -161,15 +161,15 @@ const int pieceSquareTable[2][6][32] = {
-28,-24,-30,-31,
-25,-10,-25,-25,
-4, 21,-12,-15,
37, 42, 10, 2,
37, 42, 10, 0,
29, 53, 20, 0
}
},
// Endgame
{
{ // Pawns
0, 0, 0, 0,
28, 38, 52, 61,
31, 42, 52, 61,
27, 29, 30, 30,
10, 8, 8, 8,
-12,-10, -5, -5,
Expand All @@ -178,23 +178,23 @@ const int pieceSquareTable[2][6][32] = {
0, 0, 0, 0
},
{ // Knights
-57,-15,-12, -8,
-4, 3, 7, 13,
0, 8, 16, 20,
4, 12, 18, 25,
4, 12, 17, 21,
-6, 3, 7, 20,
-21, -4, -2, 5,
-44,-24,-18,-12
-59,-16,-14, -9,
-4, 3, 6, 10,
0, 8, 13, 18,
4, 11, 18, 25,
4, 11, 17, 21,
-6, 3, 7, 19,
-20, -4, -2, 5,
-40,-22,-16,-10
},
{ // Bishops
-11, -5, -5, -5
-5, 0, 2, 3,
-12, -7, -5, -5
-4, 0, 2, 3,
-2, 2, 5, 4,
0, 3, 3, 4,
1, 3, 3, 4,
-3, 2, 2, 2,
-5, -1, 5, 5,
-10, -4, -2, -1,
-8, -4, -2, -1,
-13,-10, -7, -4
},
{ // Rooks
Expand Down Expand Up @@ -236,7 +236,7 @@ const int TEMPO_VALUE = 16;

// Material imbalance terms
const int KNIGHT_PAIR_PENALTY = 0;
const int ROOK_PAIR_PENALTY = -6;
const int ROOK_PAIR_PENALTY = -3;

const int OWN_OPP_IMBALANCE[2][5][5] = {
{
Expand All @@ -245,56 +245,56 @@ const int OWN_OPP_IMBALANCE[2][5][5] = {
{ 0}, // Own pawns
{ 3, 0}, // Own knights
{ 1, -5, 0}, // Own bishops
{ 0, -5,-11, 0}, // Own rooks
{ 0, -9, -5,-16, 0} // Own queens
{ 0, -5,-12, 0}, // Own rooks
{ 0, -9, -4,-16, 0} // Own queens
},
{
{ 0}, // Own pawns
{ 6, 0}, // Own knights
{ 1, -1, 0}, // Own bishops
{ 3, -5,-11, 0}, // Own rooks
{ 3, -7,-11, 0}, // Own rooks
{19, -3, 0, 16, 0} // Own queens
}
};

// Bonus for knight in closed positions
const int KNIGHT_CLOSED_BONUS[2] = {4, 4};
const int KNIGHT_CLOSED_BONUS[2] = {4, 5};

//------------------------Positional eval constants-----------------------------
// Mobility tables
const int mobilityScore[2][4][28] = {
// Midgame
{
{ // Knights
-24, -2, 12, 25, 31, 35, 39, 42, 44},
-27, -4, 12, 25, 31, 35, 39, 42, 44},
{ // Bishops
-40,-20, -6, 5, 14, 21, 24, 27, 30, 33, 37, 43, 49, 56},
-37,-20, -6, 5, 14, 21, 24, 27, 30, 33, 37, 43, 50, 56},
{ // Rooks
-48,-31,-10, -5, 1, 4, 7, 13, 15, 18, 20, 22, 26, 28, 29},
-51,-34,-10, -5, 1, 4, 7, 13, 15, 18, 20, 22, 26, 28, 29},
{ // Queens
-36,-24,-18,-13, -7, -4, -1, 1, 4, 7, 9, 12, 15, 17,
-42,-30,-22,-16,-11, -6, -2, 1, 4, 7, 9, 12, 15, 17,
20, 22, 25, 27, 30, 32, 34, 37, 39, 41, 44, 46, 48, 50}
},

// Endgame
{
{ // Knights
-52,-16, 0, 10, 18, 26, 31, 33, 34},
-55,-19, 0, 10, 18, 26, 31, 33, 34},
{ // Bishops
-70,-28, -8, 6, 14, 21, 26, 31, 36, 40, 44, 47, 50, 52},
-74,-31,-10, 6, 14, 21, 26, 31, 36, 40, 44, 47, 49, 51},
{ // Rooks
-68,-17, 12, 28, 41, 48, 55, 61, 66, 71, 75, 79, 83, 87, 91},
-68,-20, 10, 28, 41, 48, 55, 61, 66, 71, 75, 79, 83, 87, 90},
{ // Queens
-75,-43,-25,-15, -9, -4, 2, 6, 9, 12, 15, 18, 20, 23,
25, 27, 29, 31, 33, 35, 37, 39, 41, 42, 44, 45, 46, 47}
-78,-48,-31,-20,-13, -6, 0, 4, 8, 12, 15, 18, 20, 23,
25, 27, 29, 31, 33, 35, 37, 39, 41, 42, 43, 44, 45, 46}
}
};

// Value of each square in the extended center in cp
const int EXTENDED_CENTER_VAL = 3;
// Additional bonus for squares in the center four squares in cp, in addition
// to EXTENDED_CENTER_VAL
const int CENTER_BONUS = 3;
const int CENTER_BONUS = 2;

// King safety
// The value of having 0, 1, and both castling rights
Expand All @@ -312,91 +312,91 @@ const int PAWN_SHIELD_VALUE[4][8] = {
const int PAWN_STORM_VALUE[3][4][8] = {
// Open file
{
{11,-45, 12, 13, 9, 0, 0, 0},
{14,-15, 38, 16, 7, 0, 0, 0},
{ 6, 8, 44, 16, 9, 0, 0, 0},
{ 6, 8, 34, 18, 9, 0, 0, 0}
{11,-45, 12, 13, 8, 0, 0, 0},
{14,-15, 41, 16, 7, 0, 0, 0},
{ 6, 8, 48, 16, 10, 0, 0, 0},
{ 5, 8, 34, 18, 9, 0, 0, 0}
},
// Blocked pawn
{
{ 0, 0, 28, 3, 0, 0, 0, 0},
{ 0, 0, 55, 5, 1, 0, 0, 0},
{ 0, 0, 56, 8, 0, 0, 0, 0},
{ 0, 0, 28, 2, 0, 0, 0, 0},
{ 0, 0, 55, 4, 1, 0, 0, 0},
{ 0, 0, 56, 7, 0, 0, 0, 0},
{ 0, 0, 56, 10, 2, 0, 0, 0}
},
// Non-blocked pawn
{
{ 0, -6, 27, 12, 2, 0, 0, 0},
{ 0, 5, 30, 12, 5, 0, 0, 0},
{ 0, 5, 36, 13, 5, 0, 0, 0},
{ 0, 4, 25, 20, 7, 0, 0, 0}
{ 0, -6, 27, 10, 2, 0, 0, 0},
{ 0, 5, 30, 11, 5, 0, 0, 0},
{ 0, 5, 36, 14, 5, 0, 0, 0},
{ 0, 4, 22, 20, 8, 0, 0, 0}
},
};

const int KING_PRESSURE = 3;
const int KING_PRESSURE = 2;

// Scale factor for pieces attacking opposing king
const int KS_ARRAY_FACTOR = 128;
const int KING_THREAT_MULTIPLIER[4] = {7, 5, 5, 6};
const int KING_THREAT_SQUARE[4] = {9, 13, 10, 14};
const int KING_THREAT_MULTIPLIER[4] = {7, 5, 5, 5};
const int KING_THREAT_SQUARE[4] = {8, 12, 9, 13};
const int KING_DEFENSELESS_SQUARE = 22;
const int KS_PAWN_FACTOR = 10;
const int SAFE_CHECK_BONUS[4] = {78, 27, 47, 51};

// Minor pieces
// A penalty for each own pawn that is on a square of the same color as your bishop
const Score BISHOP_PAWN_COLOR_PENALTY = E(-3, -1);
const Score BISHOP_RAMMED_PAWN_COLOR_PENALTY = E(-3, -9);
const Score BISHOP_RAMMED_PAWN_COLOR_PENALTY = E(-4, -8);
// Minors shielded by own pawn in front
const Score SHIELDED_MINOR_BONUS = E(14, 0);
const Score SHIELDED_MINOR_BONUS = E(15, 0);
// A bonus for strong outpost knights
const Score KNIGHT_OUTPOST_BONUS = E(25, 13);
const Score KNIGHT_OUTPOST_PAWN_DEF_BONUS = E(14, 7);
const Score KNIGHT_OUTPOST_BONUS = E(25, 14);
const Score KNIGHT_OUTPOST_PAWN_DEF_BONUS = E(12, 7);
// A smaller bonus for bishops
const Score BISHOP_OUTPOST_BONUS = E(14, 8);
const Score BISHOP_OUTPOST_PAWN_DEF_BONUS = E(15, 7);
const Score BISHOP_OUTPOST_BONUS = E(15, 8);
const Score BISHOP_OUTPOST_PAWN_DEF_BONUS = E(17, 7);

// Rooks
const Score ROOK_OPEN_FILE_BONUS = E(28, 12);
const Score ROOK_SEMIOPEN_FILE_BONUS = E(13, 1);
const Score ROOK_OPEN_FILE_BONUS = E(29, 12);
const Score ROOK_SEMIOPEN_FILE_BONUS = E(14, 2);
const Score ROOK_PAWN_RANK_THREAT = E(3, 7);

// Threats
const Score UNDEFENDED_PAWN = E(-6, -19);
const Score UNDEFENDED_MINOR = E(-22, -45);
const Score PAWN_PIECE_THREAT = E(-67, -42);
const Score MINOR_ROOK_THREAT = E(-50, -30);
const Score MINOR_QUEEN_THREAT = E(-50, -20);
const Score ROOK_QUEEN_THREAT = E(-54, -15);
const Score UNDEFENDED_PAWN = E(-5, -18);
const Score UNDEFENDED_MINOR = E(-21, -48);
const Score PAWN_PIECE_THREAT = E(-70, -43);
const Score MINOR_ROOK_THREAT = E(-53, -33);
const Score MINOR_QUEEN_THREAT = E(-56, -22);
const Score ROOK_QUEEN_THREAT = E(-56, -18);

const Score LOOSE_PAWN = E(-15, -10);
const Score LOOSE_MINOR = E(-11, -9);
const Score LOOSE_PAWN = E(-15, -11);
const Score LOOSE_MINOR = E(-10, -9);

// Pawn structure
// Passed pawns
const Score PASSER_BONUS[8] = {E( 0, 0), E( 4, 8), E( 5, 8), E( 7, 14),
E( 22, 26), E( 56, 64), E( 97, 97), E( 0, 0)};
const Score PASSER_FILE_BONUS[8] = {E( 14, 14), E( 6, 10), E( -8, -2), E(-12, -8),
E(-12, -8), E( -8, -2), E( 6, 10), E( 14, 14)};
const Score FREE_PROMOTION_BONUS = E(11, 15);
const Score PASSER_BONUS[8] = {E( 0, 0), E( 4, 8), E( 5, 9), E( 7, 15),
E( 22, 25), E( 56, 64), E(100,100), E( 0, 0)};
const Score PASSER_FILE_BONUS[8] = {E( 16, 13), E( 6, 10), E( -8, -2), E(-10, -8),
E(-10, -8), E( -8, -2), E( 6, 10), E( 16, 13)};
const Score FREE_PROMOTION_BONUS = E(13, 18);
const Score FREE_STOP_BONUS = E(5, 6);
const Score FULLY_DEFENDED_PASSER_BONUS = E(8, 8);
const Score DEFENDED_PASSER_BONUS = E(6, 6);
const Score FULLY_DEFENDED_PASSER_BONUS = E(10, 9);
const Score DEFENDED_PASSER_BONUS = E(7, 7);
const Score OWN_KING_DIST = E(0, 2);
const Score OPP_KING_DIST = E(0, 5);

// Doubled pawns
const Score DOUBLED_PENALTY = E(-8, -21);
const Score DOUBLED_PENALTY = E(-9, -20);
// Isolated pawns
const Score ISOLATED_PENALTY = E(-22, -13);
const Score ISOLATED_PENALTY = E(-23, -14);
const Score ISOLATED_SEMIOPEN_PENALTY = E(-6, -6);
// Backward pawns
const Score BACKWARD_PENALTY = E(-19, -10);
const Score BACKWARD_SEMIOPEN_PENALTY = E(-15, -9);
const Score BACKWARD_PENALTY = E(-18, -10);
const Score BACKWARD_SEMIOPEN_PENALTY = E(-15, -10);
// Undefended pawns that are not backwards or isolated
const Score UNDEFENDED_PAWN_PENALTY = E(-6, -5);
const Score UNDEFENDED_PAWN_PENALTY = E(-6, -6);
// Pawn phalanxes
const Score PAWN_PHALANX_RANK_BONUS = E(14, 14);
const Score PAWN_PHALANX_RANK_BONUS = E(13, 14);
// Connected pawns
const Score PAWN_CONNECTED_RANK_BONUS = E(5, 3);
// King-pawn tropism
Expand Down

0 comments on commit 0571754

Please sign in to comment.