X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=30b107ee9565c2254f93065cc5f76438f6f0a3e8;hp=34a87771aea96a120e14f5858ffebd510f73d60f;hb=83a574ff271ec5924976b48cf65ac62278f87558;hpb=a9e93fa6a56d985e98f16a480a8b0d166fdea324 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 34a87771..30b107ee 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -89,23 +89,15 @@ namespace { std::string do_trace(const Position& pos); } - // Evaluation weights, initialized from UCI options + // Evaluation weights, indexed by evaluation term enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem }; - struct Weight { int mg, eg; } Weights[6]; + const struct Weight { int mg, eg; } Weights[] = { + {289, 344}, {233, 201}, {221, 273}, {46, 0}, {271, 0}, {307, 0} + }; typedef Value V; #define S(mg, eg) make_score(mg, eg) - // Internal evaluation weights. These are applied on top of the evaluation - // weights read from UCI parameters. The purpose is to be able to change - // the evaluation weights while keeping the default values of the UCI - // parameters at 100, which looks prettier. - // - // Values modified by Joona Kiiski - const Score WeightsInternal[] = { - S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(271, 0), S(307, 0) - }; - // MobilityBonus[PieceType][attacked] contains bonuses for middle and end // game, indexed by piece type and number of attacked squares not occupied by // friendly pieces. @@ -169,7 +161,6 @@ namespace { const Score RookSemiopenFile = make_score(19, 10); const Score BishopPawns = make_score( 8, 12); const Score MinorBehindPawn = make_score(16, 0); - const Score UndefendedMinor = make_score(25, 10); const Score TrappedRook = make_score(90, 0); const Score Unstoppable = make_score( 0, 20); @@ -214,17 +205,6 @@ namespace { } - // weight_option() computes the value of an evaluation weight, by combining - // two UCI-configurable weights (midgame and endgame) with an internal weight. - - Weight weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight) { - - Weight w = { Options[mgOpt] * mg_value(internalWeight) / 100, - Options[egOpt] * eg_value(internalWeight) / 100 }; - return w; - } - - // init_eval_info() initializes king bitboards for given color adding // pawn attacks. To be done at the beginning of the evaluation. @@ -520,16 +500,9 @@ namespace { const Color Them = (Us == WHITE ? BLACK : WHITE); - Bitboard b, undefendedMinors, weakEnemies; + Bitboard b, weakEnemies; Score score = SCORE_ZERO; - // Undefended minors get penalized even if they are not under attack - undefendedMinors = pos.pieces(Them, BISHOP, KNIGHT) - & ~ei.attackedBy[Them][ALL_PIECES]; - - if (undefendedMinors) - score += UndefendedMinor; - // Enemies not defended by a pawn and under our attack weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN] @@ -787,13 +760,6 @@ namespace { sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL); } - // Stealmate detection - Color stm = pos.side_to_move(); - if ( (ei.attackedBy[stm][ALL_PIECES] == ei.attackedBy[stm][KING]) - && (!(ei.attackedBy[stm][KING] & ~ei.attackedBy[~stm][ALL_PIECES])) - && !MoveList(pos).size()) - sf = SCALE_FACTOR_DRAW; - // Interpolate between a middlegame and a (scaled by 'sf') endgame score Value v = mg_value(score) * int(ei.mi->game_phase()) + eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL; @@ -913,13 +879,6 @@ namespace Eval { void init() { - Weights[Mobility] = weight_option("Mobility (Midgame)", "Mobility (Endgame)", WeightsInternal[Mobility]); - Weights[PawnStructure] = weight_option("Pawn Structure (Midgame)", "Pawn Structure (Endgame)", WeightsInternal[PawnStructure]); - Weights[PassedPawns] = weight_option("Passed Pawns (Midgame)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]); - Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]); - Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]); - Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]); - const double MaxSlope = 30; const double Peak = 1280;