X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=b380dbf074874717e93d5adfcfc6f3d80f54f2b3;hp=fe020facbf2ac67e4f755872b64ab384f57e309e;hb=04be84e0e296d0829aa838c512fc95bf495ce629;hpb=56dd58e6f9d9073b963ebf2add7da9723eb5cd5a diff --git a/src/evaluate.cpp b/src/evaluate.cpp index fe020fac..b380dbf0 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -168,7 +168,7 @@ namespace { // Passed[mg/eg][Rank] contains midgame and endgame bonuses for passed pawns. // We don't use a Score because we process the two components independently. const Value Passed[][RANK_NB] = { - { V(0), V( 1), V(26), V(68), V(161), V(247) }, + { V(5), V( 5), V(31), V(73), V(166), V(252) }, { V(7), V(14), V(38), V(64), V(137), V(193) } }; @@ -424,36 +424,20 @@ namespace { b2 = pos.attacks_from(ksq) & safe; // Enemy queen safe checks - b = (b1 | b2) & ei.attackedBy[Them][QUEEN]; - if (b) - { - attackUnits += QueenCheck * popcount(b); - score -= Checked; - } + if ((b1 | b2) & ei.attackedBy[Them][QUEEN]) + attackUnits += QueenCheck, score -= Checked; // Enemy rooks safe checks - b = b1 & ei.attackedBy[Them][ROOK]; - if (b) - { - attackUnits += RookCheck * popcount(b); - score -= Checked; - } + if (b1 & ei.attackedBy[Them][ROOK]) + attackUnits += RookCheck, score -= Checked; // Enemy bishops safe checks - b = b2 & ei.attackedBy[Them][BISHOP]; - if (b) - { - attackUnits += BishopCheck * popcount(b); - score -= Checked; - } + if (b2 & ei.attackedBy[Them][BISHOP]) + attackUnits += BishopCheck, score -= Checked; // Enemy knights safe checks - b = pos.attacks_from(ksq) & ei.attackedBy[Them][KNIGHT] & safe; - if (b) - { - attackUnits += KnightCheck * popcount(b); - score -= Checked; - } + if (pos.attacks_from(ksq) & ei.attackedBy[Them][KNIGHT] & safe) + attackUnits += KnightCheck, score -= Checked; // Finally, extract the king danger score from the KingDanger[] // array and subtract the score from the evaluation. @@ -467,7 +451,7 @@ namespace { } - // evaluate_threats() assigns bonuses according to the types of the attacking + // evaluate_threats() assigns bonuses according to the types of the attacking // and the attacked pieces. template @@ -615,10 +599,10 @@ namespace { else if (defendedSquares & blockSq) k += 4; - mbonus += k * rr * 3 / 4, ebonus += k * rr; + mbonus += k * rr, ebonus += k * rr; } else if (pos.pieces(Us) & blockSq) - mbonus += (rr * 3 + r * 2 + 3) * 3 / 4, ebonus += rr + r * 2; + mbonus += rr + r * 2, ebonus += rr + r * 2; } // rr != 0 if (pos.count(Us) < pos.count(Them)) @@ -679,11 +663,12 @@ namespace { // status of the players. Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) { - int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)); + int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)) + - distance(pos.square(WHITE), pos.square(BLACK)); int pawns = pos.count(WHITE) + pos.count(BLACK); // Compute the initiative bonus for the attacking side - int initiative = 8 * (pawns + asymmetry + kingDistance - 15); + int initiative = 8 * (asymmetry + kingDistance - 15) + 12 * pawns; // Now apply the bonus: note that we find the attacking side by extracting // the sign of the endgame value, and that we carefully cap the bonus so @@ -695,9 +680,9 @@ namespace { // evaluate_scale_factor() computes the scale factor for the winning side - ScaleFactor evaluate_scale_factor(const Position& pos, const EvalInfo& ei, Score score) { + ScaleFactor evaluate_scale_factor(const Position& pos, const EvalInfo& ei, Value eg) { - Color strongSide = eg_value(score) > VALUE_DRAW ? WHITE : BLACK; + Color strongSide = eg > VALUE_DRAW ? WHITE : BLACK; ScaleFactor sf = ei.me->scale_factor(pos, strongSide); // If we don't already have an unusual scale factor, check for certain @@ -720,7 +705,7 @@ namespace { } // Endings where weaker side can place his king in front of the opponent's // pawns are drawish. - else if ( abs(eg_value(score)) <= BishopValueEg + else if ( abs(eg) <= BishopValueEg && ei.pi->pawn_span(strongSide) <= 1 && !pos.pawn_passed(~strongSide, pos.square(~strongSide))) sf = ei.pi->pawn_span(strongSide) ? ScaleFactor(51) : ScaleFactor(37); @@ -816,7 +801,7 @@ Value Eval::evaluate(const Position& pos) { score += evaluate_initiative(pos, ei.pi->pawn_asymmetry(), eg_value(score)); // Evaluate scale factor for the winning side - ScaleFactor sf = evaluate_scale_factor(pos, ei, score); + ScaleFactor sf = evaluate_scale_factor(pos, ei, eg_value(score)); // Interpolate between a middlegame and a (scaled by 'sf') endgame score Value v = mg_value(score) * int(ei.me->game_phase())