From 5205d44f878fc93be5cb634a920545bc2f4dd370 Mon Sep 17 00:00:00 2001 From: Stefano80 Date: Sun, 5 Feb 2017 16:02:02 -0800 Subject: [PATCH] Simplify scale factor computation Minor non-functional simplifications in computing the scale factor. In my opinion, the code is now slightly more readable: - remove one condition which can never be satisfied. - immediately return instead of assigning the sf variable. Tested for non-regression: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 62162 W: 11166 L: 11115 D: 39881 No functional change Closes #992 --- src/evaluate.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9e0629ef..2c5f1303 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -755,8 +755,7 @@ namespace { // If we don't already have an unusual scale factor, check for certain // types of endgames, and use a lower scale for those. - if ( ei.me->game_phase() < PHASE_MIDGAME - && (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN)) + if (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN) { if (pos.opposite_bishops()) { @@ -764,19 +763,18 @@ namespace { // is almost a draw, in case of KBP vs KB, it is even more a draw. if ( pos.non_pawn_material(WHITE) == BishopValueMg && pos.non_pawn_material(BLACK) == BishopValueMg) - sf = more_than_one(pos.pieces(PAWN)) ? ScaleFactor(31) : ScaleFactor(9); + return more_than_one(pos.pieces(PAWN)) ? ScaleFactor(31) : ScaleFactor(9); // Endgame with opposite-colored bishops, but also other pieces. Still // a bit drawish, but not as drawish as with only the two bishops. - else - sf = ScaleFactor(46); + return ScaleFactor(46); } // Endings where weaker side can place his king in front of the opponent's // pawns are drawish. else if ( abs(eg) <= BishopValueEg && pos.count(strongSide) <= 2 && !pos.pawn_passed(~strongSide, pos.square(~strongSide))) - sf = ScaleFactor(37 + 7 * pos.count(strongSide)); + return ScaleFactor(37 + 7 * pos.count(strongSide)); } return sf; -- 2.39.2