From: Fabian Fichter Date: Mon, 21 Dec 2020 12:19:42 +0000 (+0100) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f67ded8cdd1a673700cf52227b9bfac64a49b008;p=fairystockfish.git Merge official-stockfish/master bench: 4525008 --- f67ded8cdd1a673700cf52227b9bfac64a49b008 diff --cc src/evaluate.cpp index 14f5912,c507aa0..64abaca --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -764,22 -593,18 +764,22 @@@ namespace int kingFlankAttack = popcount(b1) + popcount(b2); int kingFlankDefense = popcount(b3); - kingDanger += kingAttackersCount[Them] * kingAttackersWeight[Them] // (~10 Elo) - + 183 * popcount(kingRing[Us] & weak) // (~15 Elo) - + 148 * popcount(unsafeChecks) // (~4 Elo) - + 98 * popcount(pos.blockers_for_king(Us)) // (~2 Elo) - + 69 * kingAttacksCount[Them] // (~0.5 Elo) - + 3 * kingFlankAttack * kingFlankAttack / 8 // (~0.5 Elo) - + mg_value(mobility[Them] - mobility[Us]) // (~0.5 Elo) - - 873 * !pos.count(Them) // (~24 Elo) - - 100 * bool(attackedBy[Us][KNIGHT] & attackedBy[Us][KING]) // (~5 Elo) - - 6 * mg_value(score) / 8 // (~8 Elo) - - 4 * kingFlankDefense // (~5 Elo) - + 37; // (~0.5 Elo) + kingDanger += kingAttackersCount[Them] * kingAttackersWeight[Them] + + kingAttackersCountInHand[Them] * kingAttackersWeight[Them] + + kingAttackersCount[Them] * kingAttackersWeightInHand[Them] - + 185 * popcount(kingRing[Us] & (weak | ~pos.board_bb(Us, KING))) * (1 + pos.captures_to_hand() + pos.check_counting()) ++ + 183 * popcount(kingRing[Us] & (weak | ~pos.board_bb(Us, KING))) * (1 + pos.captures_to_hand() + pos.check_counting()) + + 148 * popcount(unsafeChecks) * (1 + pos.check_counting()) + + 98 * popcount(pos.blockers_for_king(Us)) + + 69 * kingAttacksCount[Them] * (2 + 8 * pos.check_counting() + pos.captures_to_hand()) / 2 + + 3 * kingFlankAttack * kingFlankAttack / 8 + + mg_value(mobility[Them] - mobility[Us]) + - 873 * !(pos.major_pieces(Them) || pos.captures_to_hand()) + * 2 / (2 + 2 * pos.check_counting() + 2 * pos.two_boards() + 2 * pos.makpong() + + (pos.king_type() != KING) * (pos.diagonal_lines() ? 1 : 2)) + - 100 * bool(attackedBy[Us][KNIGHT] & attackedBy[Us][KING]) + - 6 * mg_value(score) / 8 + - 4 * kingFlankDefense + + 37; // Transform the kingDanger units into a Score, and subtract it from the evaluation if (kingDanger > 100) diff --cc src/material.cpp index 9323408,f77972e..bdf22bc --- a/src/material.cpp +++ b/src/material.cpp @@@ -28,31 -29,32 +29,33 @@@ namespace // Polynomial material imbalance parameters - constexpr int QuadraticOurs[][PIECE_TYPE_NB] = { + constexpr Score QuadraticOurs[][PIECE_TYPE_NB] = { // OUR PIECES // pair pawn knight bishop rook queen - {1438 }, // Bishop pair - { 40, 38 }, // Pawn - { 32, 255, -62 }, // Knight OUR PIECES - { 0, 104, 4, 0 }, // Bishop - { -26, -2, 47, 105, -208 }, // Rook - {-189, 24, 117, 133, -134, -6 } // Queen + {S(1419, 1455) }, // Bishop pair + {S( 101, 28), S( 37, 39) }, // Pawn + {S( 57, 64), S(249, 187), S(-49, -62) }, // Knight OUR PIECES + {S( 0, 0), S(118, 137), S( 10, 27), S( 0, 0) }, // Bishop + {S( -63, -68), S( -5, 3), S(100, 81), S(132, 118), S(-246, -244) }, // Rook + {S(-210, -211), S( 37, 14), S(147, 141), S(161, 105), S(-158, -174), S(-9,-31) } // Queen }; - constexpr int QuadraticTheirs[][PIECE_TYPE_NB] = { + constexpr Score QuadraticTheirs[][PIECE_TYPE_NB] = { // THEIR PIECES // pair pawn knight bishop rook queen - { }, // Bishop pair - { 36, }, // Pawn - { 9, 63, }, // Knight OUR PIECES - { 59, 65, 42, }, // Bishop - { 46, 39, 24, -24, }, // Rook - { 97, 100, -42, 137, 268, } // Queen + { }, // Bishop pair + {S( 33, 30) }, // Pawn + {S( 46, 18), S(106, 84) }, // Knight OUR PIECES + {S( 75, 35), S( 59, 44), S( 60, 15) }, // Bishop + {S( 26, 35), S( 6, 22), S( 38, 39), S(-12, -2) }, // Rook + {S( 97, 93), S(100, 163), S(-58, -91), S(112, 192), S(276, 225) } // Queen }; + #undef S + // Endgame evaluation and scaling functions are accessed directly and not through // the function maps because they correspond to more than one material hash key. + Endgame EvaluateKFsPsK[] = { Endgame(WHITE), Endgame(BLACK) }; Endgame EvaluateKXK[] = { Endgame(WHITE), Endgame(BLACK) }; Endgame ScaleKBPsK[] = { Endgame(WHITE), Endgame(BLACK) }; @@@ -91,7 -85,7 +94,7 @@@ /// piece type for both colors. template - int imbalance(const Position& pos, const int pieceCount[][PIECE_TYPE_NB]) { - Score imbalance(const int pieceCount[][PIECE_TYPE_NB]) { ++ Score imbalance(const Position& pos, const int pieceCount[][PIECE_TYPE_NB]) { constexpr Color Them = ~Us; @@@ -242,7 -216,7 +245,7 @@@ Entry* probe(const Position& pos) { pos.count(BLACK) > 1, pos.count(BLACK), pos.count(BLACK), pos.count(BLACK) , pos.count(BLACK), pos.count(BLACK) } }; - e->value = int16_t((imbalance(pos, pieceCount) - imbalance(pos, pieceCount)) / 16); - e->score = (imbalance(pieceCount) - imbalance(pieceCount)) / 16; ++ e->score = (imbalance(pos, pieceCount) - imbalance(pos, pieceCount)) / 16; return e; } diff --cc src/material.h index 7bfb7a0,28da59d..43911d7 --- a/src/material.h +++ b/src/material.h @@@ -43,6 -42,6 +42,8 @@@ struct Entry bool specialized_eval_exists() const { return evaluationFunction != nullptr; } Value evaluate(const Position& pos) const { return (*evaluationFunction)(pos); } ++ int material_density() const { return materialDensity; } ++ // scale_factor() takes a position and a color as input and returns a scale factor // for the given color. We have to provide the position in addition to the color // because the scale factor may also be a function which should be applied to @@@ -58,10 -57,9 +59,11 @@@ const EndgameBase* evaluationFunction; const EndgameBase* scalingFunction[COLOR_NB]; // Could be one for each // side (e.g. KPKP, KBPsK) - int16_t value; + Score score; + int16_t gamePhase; uint8_t factor[COLOR_NB]; - Phase gamePhase; ++ + int materialDensity; }; typedef HashTable Table;