From: Stefano80 Date: Sun, 29 Apr 2018 05:23:32 +0000 (+0200) Subject: Always scale using pawn contribution X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=213166ba225bcefbbe7dbecdacfd726dfb6c34f9 Always scale using pawn contribution This is a further step in the long quest for a simple way of determining scale factors for the endgame. Here we remove the artificial restriction in evaluate_scale_factor() based on endgame score. Also SCALE_FACTOR_ONEPAWN can be simplified away. The latter is a small non functional simplification with respect to the version that was testedin the framework, verified on bench with depth 22 for good measure. Passed STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 49438 W: 9999 L: 9930 D: 29509 http://tests.stockfishchess.org/tests/view/5ae20c8b0ebc5963175205c8 Passed LTC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 101445 W: 15113 L: 15110 D: 71222 http://tests.stockfishchess.org/tests/view/5ae2a0560ebc5902a1998986 How to continue from there? Maybe the general case could be scaled with pawns from both colors without losing Elo. If that is the case, then this could be merged somehow with the scaling in evaluate_initiative(), which also uses a additive malus down when the number of pawns in the position goes down. Closes https://github.com/official-stockfish/Stockfish/pull/1570 Bench: 5254862 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 4c10a199..c98a83fc 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -794,9 +794,8 @@ namespace { Color strongSide = eg > VALUE_DRAW ? WHITE : BLACK; int sf = me->scale_factor(pos, strongSide); - // If we don't already have an unusual scale factor, check for certain - // types of endgames, and use a lower scale for those. - if (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN) + // If scale is not already specific, scale down the endgame via general heuristics + if (sf == SCALE_FACTOR_NORMAL) { if (pos.opposite_bishops()) { @@ -810,12 +809,8 @@ namespace { else sf = 46; } - // Endings where weaker side can place his king in front of the enemy's - // pawns are drawish. - else if ( abs(eg) <= BishopValueEg - && pos.count(strongSide) <= 2 - && !pos.pawn_passed(~strongSide, pos.square(~strongSide))) - sf = 37 + 7 * pos.count(strongSide); + else + sf = std::min(40 + 7 * pos.count(strongSide), sf); } return ScaleFactor(sf); diff --git a/src/material.cpp b/src/material.cpp index 921e3007..b18d29d0 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -206,12 +206,6 @@ Entry* probe(const Position& pos) { e->factor[BLACK] = uint8_t(npm_b < RookValueMg ? SCALE_FACTOR_DRAW : npm_w <= BishopValueMg ? 4 : 14); - if (pos.count(WHITE) == 1 && npm_w - npm_b <= BishopValueMg) - e->factor[WHITE] = (uint8_t) SCALE_FACTOR_ONEPAWN; - - if (pos.count(BLACK) == 1 && npm_b - npm_w <= BishopValueMg) - e->factor[BLACK] = (uint8_t) SCALE_FACTOR_ONEPAWN; - // Evaluate the material imbalance. We use PIECE_TYPE_NONE as a place holder // for the bishop pair "extended piece", which allows us to be more flexible // in defining bishop pair bonuses. diff --git a/src/types.h b/src/types.h index 72c5699f..ab5e1b88 100644 --- a/src/types.h +++ b/src/types.h @@ -159,7 +159,6 @@ enum Phase { enum ScaleFactor { SCALE_FACTOR_DRAW = 0, - SCALE_FACTOR_ONEPAWN = 48, SCALE_FACTOR_NORMAL = 64, SCALE_FACTOR_MAX = 128, SCALE_FACTOR_NONE = 255