X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=2161bf94c07ddf1ee53af1d0c9116a421698a4bc;hp=8c70016e7067acd2ae55725d74683b92d3617f48;hb=42a20920e5259dbe3efd9002fbc7176a9f071636;hpb=5cbcff55cc3a2ff78dd83e7a3f94c5414946f82c diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 8c70016e..2161bf94 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -27,7 +27,6 @@ #include "material.h" #include "pawns.h" #include "thread.h" -#include "uci.h" namespace { @@ -199,8 +198,6 @@ namespace { // scores, indexed by a calculated integer number. Score KingDanger[128]; - const int ScalePawnSpan[2] = { 38, 56 }; - // apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow Score apply_weight(Score v, const Weight& w) { return make_score(mg_value(v) * w.mg / 256, eg_value(v) * w.eg / 256); @@ -499,9 +496,11 @@ namespace { assert(target & (pos.pieces(C) ^ pos.pieces(C, KING))); - PieceType pt; - for (pt = QUEEN; !(target & pos.pieces(C, pt)); --pt) {} - return pt; + for (PieceType pt = QUEEN; pt > PAWN; --pt) + if (target & pos.pieces(C, pt)) + return pt; + + return PAWN; } @@ -764,27 +763,25 @@ namespace { if ( ei.mi->game_phase() < PHASE_MIDGAME && (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN)) { - if (pos.opposite_bishops()) { - // Ignoring any pawns, do both sides only have a single bishop and no - // other pieces? + if (pos.opposite_bishops()) + { + // Endgame with opposite-colored bishops and no other pieces (ignoring pawns) + // is almost a draw, in case of KBP vs KB is even more a draw. if ( pos.non_pawn_material(WHITE) == BishopValueMg && pos.non_pawn_material(BLACK) == BishopValueMg) - { - // Check for KBP vs KB with only a single pawn that is almost - // certainly a draw or at least two pawns. - bool one_pawn = (pos.count(WHITE) + pos.count(BLACK) == 1); - sf = one_pawn ? ScaleFactor(8) : ScaleFactor(32); - } + sf = more_than_one(pos.pieces(PAWN)) ? ScaleFactor(32) : ScaleFactor(8); + + // Endgame with opposite-colored bishops, but also other pieces. Still + // a bit drawish, but not as drawish as with only the two bishops. else - // Endgame with opposite-colored bishops, but also other pieces. Still - // a bit drawish, but not as drawish as with only the two bishops. sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL); - } else if ( abs(eg_value(score)) <= BishopValueEg - && ei.pi->pawn_span(strongSide) <= 1 - && !pos.pawn_passed(~strongSide, pos.king_square(~strongSide))) { - // Endings where weaker side can be place his king in front of the opponent's pawns are drawish. - sf = ScaleFactor(ScalePawnSpan[ei.pi->pawn_span(strongSide)]); } + // Endings where weaker side can place his king in front of the opponent's + // pawns are drawish. + else if ( abs(eg_value(score)) <= BishopValueEg + && ei.pi->pawn_span(strongSide) <= 1 + && !pos.pawn_passed(~strongSide, pos.king_square(~strongSide))) + sf = ei.pi->pawn_span(strongSide) ? ScaleFactor(56) : ScaleFactor(38); } // Interpolate between a middlegame and a (scaled by 'sf') endgame score @@ -903,8 +900,7 @@ namespace Eval { } - /// init() computes evaluation weights from the corresponding UCI parameters - /// and setup king tables. + /// init() computes evaluation weights. void init() {