X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=6e33bb7215d0579e035915d20c40811dac8c8ae9;hp=ed1bcf49036915b708a55d182813c9fb0f1255ba;hb=58c181de9a8f505e539b2e7811cf820175c73ebf;hpb=9eed1834895886c8b61a253d9f70df0ac878fa47 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index ed1bcf49..6e33bb72 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -75,7 +75,6 @@ namespace { Material::Entry* me; Pawns::Entry* pe; - Bitboard pinnedPieces[COLOR_NB]; Bitboard mobilityArea[COLOR_NB]; // attackedBy[color][piece type] is a bitboard representing all squares @@ -217,7 +216,7 @@ namespace { const int KnightCheck = 924; // Threshold for lazy evaluation - const Value LazyEval = Value(1500); + const Value LazyThreshold = Value(1500); // eval_init() initializes king and attack bitboards for a given color // adding pawn attacks. To be done at the beginning of the evaluation. @@ -230,8 +229,6 @@ namespace { const Square Down = (Us == WHITE ? SOUTH : NORTH); const Bitboard LowRanks = (Us == WHITE ? Rank2BB | Rank3BB: Rank7BB | Rank6BB); - ei.pinnedPieces[Us] = pos.pinned_pieces(Us); - // Find our pawns on the first two ranks, and those which are blocked Bitboard b = pos.pieces(Us, PAWN) & (shift(pos.pieces()) | LowRanks); @@ -283,7 +280,7 @@ namespace { : Pt == ROOK ? attacks_bb< ROOK>(s, pos.pieces() ^ pos.pieces(Us, ROOK, QUEEN)) : pos.attacks_from(s); - if (ei.pinnedPieces[Us] & s) + if (pos.pinned_pieces(Us) & s) b &= LineBB[pos.square(Us)][s]; ei.attackedBy2[Us] |= ei.attackedBy[Us][ALL_PIECES] & b; @@ -429,7 +426,7 @@ namespace { kingDanger = std::min(807, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) + 101 * ei.kingAdjacentZoneAttacksCount[Them] + 235 * popcount(undefended) - + 134 * (popcount(b) + !!ei.pinnedPieces[Us]) + + 134 * (popcount(b) + !!pos.pinned_pieces(Us)) - 717 * !pos.count(Them) - 7 * mg_value(score) / 5 - 5; @@ -792,18 +789,6 @@ namespace { return sf; } - - Value lazy_eval(Value mg, Value eg) { - - if (mg > LazyEval && eg > LazyEval) - return LazyEval + ((mg + eg) / 2 - LazyEval) / 4; - - else if (mg < -LazyEval && eg < -LazyEval) - return -LazyEval + ((mg + eg) / 2 + LazyEval) / 4; - - return VALUE_ZERO; - } - } // namespace @@ -816,6 +801,7 @@ Value Eval::evaluate(const Position& pos) { assert(!pos.checkers()); Score mobility[COLOR_NB] = { SCORE_ZERO, SCORE_ZERO }; + Value v; EvalInfo ei; // Probe the material hash table @@ -835,11 +821,10 @@ Value Eval::evaluate(const Position& pos) { ei.pe = Pawns::probe(pos); score += ei.pe->pawns_score(); - // We have taken into account all cheap evaluation terms. - // If score exceeds a threshold return a lazy evaluation. - Value lazy = lazy_eval(mg_value(score), eg_value(score)); - if (lazy) - return pos.side_to_move() == WHITE ? lazy : -lazy; + // Early exit if score is high + v = (mg_value(score) + eg_value(score)) / 2; + if (abs(v) > LazyThreshold) + return pos.side_to_move() == WHITE ? v : -v; // Initialize attack and king safety bitboards eval_init(pos, ei); @@ -874,8 +859,8 @@ Value Eval::evaluate(const Position& pos) { 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()) - + eg_value(score) * int(PHASE_MIDGAME - ei.me->game_phase()) * sf / SCALE_FACTOR_NORMAL; + v = mg_value(score) * int(ei.me->game_phase()) + + eg_value(score) * int(PHASE_MIDGAME - ei.me->game_phase()) * sf / SCALE_FACTOR_NORMAL; v /= int(PHASE_MIDGAME);