Skip to content

Commit

Permalink
Always scale using pawn contribution
Browse files Browse the repository at this point in the history
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 #1570

Bench: 5254862
  • Loading branch information
Stefano80 authored and snicolet committed Apr 29, 2018
1 parent d6252ef commit 213166b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
13 changes: 4 additions & 9 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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<PAWN>(strongSide) <= 2
&& !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide)))
sf = 37 + 7 * pos.count<PAWN>(strongSide);
else
sf = std::min(40 + 7 * pos.count<PAWN>(strongSide), sf);
}

return ScaleFactor(sf);
Expand Down
6 changes: 0 additions & 6 deletions src/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PAWN>(WHITE) == 1 && npm_w - npm_b <= BishopValueMg)
e->factor[WHITE] = (uint8_t) SCALE_FACTOR_ONEPAWN;

if (pos.count<PAWN>(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.
Expand Down
1 change: 0 additions & 1 deletion src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 213166b

Please sign in to comment.