From da34023cfcb856e95d8cbc0b80653ab0ee6af6d6 Mon Sep 17 00:00:00 2001 From: Alain SAVARD Date: Tue, 22 Dec 2015 10:00:04 +0000 Subject: [PATCH] New mobility bonus Tuned the global mobility factor for each piece, as well as some +- delta, The master mobility factor was {266,334} and tuning gave {267, 362} +S(-2,-2) for the Knight {249, 328} +S( 0,-2) for the Bishop {298, 353} +S(1,1) for the Rook {265, 358} +S(2,-1) for the Queen Passed STC LLR: 2.95 (-2.94,2.94) [0.00,4.00] Total: 49402 W: 9367 L: 9037 D: 30998 and LTC LLR: 2.97 (-2.94,2.94) [0.00,5.00] Total: 26831 W: 3871 L: 3658 D: 19302 Bench: 8355485 Resolves #536 --- src/evaluate.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index bf90e08c..925d70ac 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -108,10 +108,10 @@ namespace { // Evaluation weights, indexed by the corresponding evaluation term - enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety }; + enum { PawnStructure, PassedPawns, Space, KingSafety }; const struct Weight { int mg, eg; } Weights[] = { - {266, 334}, {214, 203}, {193, 262}, {47, 0}, {330, 0} + {214, 203}, {193, 262}, {47, 0}, {330, 0} }; Score operator*(Score s, const Weight& w) { @@ -123,23 +123,22 @@ namespace { #define S(mg, eg) make_score(mg, eg) // MobilityBonus[PieceType][attacked] contains bonuses for middle and end - // game, indexed by piece type and number of attacked squares not occupied by - // friendly pieces. + // game, indexed by piece type and number of attacked squares in the MobilityArea. const Score MobilityBonus[][32] = { {}, {}, - { S(-70,-52), S(-52,-37), S( -7,-17), S( 0, -6), S( 8, 5), S( 16, 9), // Knights - S( 23, 20), S( 31, 21), S( 36, 22) }, - { S(-49,-44), S(-22,-13), S( 16, 0), S( 27, 11), S( 38, 19), S( 52, 34), // Bishops - S( 56, 44), S( 65, 47), S( 67, 51), S( 73, 56), S( 81, 59), S( 83, 69), - S( 95, 72), S(100, 75) }, - { S(-49,-57), S(-22,-14), S(-10, 18), S( -5, 39), S( -4, 50), S( -2, 58), // Rooks - S( 6, 78), S( 11, 86), S( 17, 92), S( 19,103), S( 26,111), S( 27,115), - S( 36,119), S( 41,121), S( 50,122) }, - { S(-41,-24), S(-26, -8), S( 0, 6), S( 2, 14), S( 12, 27), S( 21, 40), // Queens - S( 22, 45), S( 37, 55), S( 40, 57), S( 43, 63), S( 50, 68), S( 52, 74), - S( 56, 80), S( 66, 84), S( 68, 85), S( 69, 88), S( 71, 92), S( 72, 94), - S( 80, 96), S( 89, 98), S( 94,101), S(102,113), S(106,114), S(107,116), - S(112,125), S(113,127), S(117,137), S(122,143) } + { S(-75,-76), S(-56,-54), S(- 9,-26), S( -2,-10), S( 6, 5), S( 15, 11), // Knights + S( 22, 26), S( 30, 28), S( 36, 29) }, + { S(-48,-58), S(-21,-19), S( 16, -2), S( 26, 12), S( 37, 22), S( 51, 42), // Bishops + S( 54, 54), S( 63, 58), S( 65, 63), S( 71, 70), S( 79, 74), S( 81, 86), + S( 92, 90), S( 97, 94) }, + { S(-56,-78), S(-25,-18), S(-11, 26), S( -5, 55), S( -4, 70), S( -1, 81), // Rooks + S( 8,109), S( 14,120), S( 21,128), S( 23,143), S( 31,154), S( 32,160), + S( 43,165), S( 49,168), S( 59,169) }, + { S(-40,-35), S(-25,-12), S( 2, 7), S( 4, 19), S( 14, 37), S( 24, 55), // Queens + S( 25, 62), S( 40, 76), S( 43, 79), S( 47, 87), S( 54, 94), S( 56,102), + S( 60,111), S( 70,116), S( 72,118), S( 73,122), S( 75,128), S( 77,130), + S( 85,133), S( 94,136), S( 99,140), S(108,157), S(112,158), S(113,161), + S(118,174), S(119,177), S(123,191), S(128,199) } }; // Outpost[knight/bishop][supported by pawn] contains bonuses for knights and @@ -752,7 +751,7 @@ Value Eval::evaluate(const Position& pos) { assert(!pos.checkers()); EvalInfo ei; - Score score, mobility[2] = { SCORE_ZERO, SCORE_ZERO }; + Score score, mobility[COLOR_NB] = { SCORE_ZERO, SCORE_ZERO }; // Initialize score by reading the incrementally updated scores included in // the position object (material + piece square tables). Score is computed @@ -792,7 +791,7 @@ Value Eval::evaluate(const Position& pos) { // Evaluate all pieces but king and pawns score += evaluate_pieces(pos, ei, mobility, mobilityArea); - score += (mobility[WHITE] - mobility[BLACK]) * Weights[Mobility]; + score += mobility[WHITE] - mobility[BLACK]; // Evaluate kings after all other pieces because we need full attack // information when computing the king safety evaluation. @@ -841,8 +840,7 @@ Value Eval::evaluate(const Position& pos) { Trace::add(MATERIAL, pos.psq_score()); Trace::add(IMBALANCE, ei.me->imbalance()); Trace::add(PAWN, ei.pi->pawns_score()); - Trace::add(MOBILITY, mobility[WHITE] * Weights[Mobility] - , mobility[BLACK] * Weights[Mobility]); + Trace::add(MOBILITY, mobility[WHITE], mobility[BLACK]); Trace::add(SPACE, evaluate_space(pos, ei) * Weights[Space] , evaluate_space(pos, ei) * Weights[Space]); Trace::add(TOTAL, score); -- 2.39.2