mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 02:57:11 +08:00
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
This commit is contained in:
@@ -755,8 +755,7 @@ namespace {
|
|||||||
|
|
||||||
// If we don't already have an unusual scale factor, check for certain
|
// If we don't already have an unusual scale factor, check for certain
|
||||||
// types of endgames, and use a lower scale for those.
|
// types of endgames, and use a lower scale for those.
|
||||||
if ( ei.me->game_phase() < PHASE_MIDGAME
|
if (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN)
|
||||||
&& (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN))
|
|
||||||
{
|
{
|
||||||
if (pos.opposite_bishops())
|
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.
|
// is almost a draw, in case of KBP vs KB, it is even more a draw.
|
||||||
if ( pos.non_pawn_material(WHITE) == BishopValueMg
|
if ( pos.non_pawn_material(WHITE) == BishopValueMg
|
||||||
&& pos.non_pawn_material(BLACK) == 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
|
// Endgame with opposite-colored bishops, but also other pieces. Still
|
||||||
// a bit drawish, but not as drawish as with only the two bishops.
|
// a bit drawish, but not as drawish as with only the two bishops.
|
||||||
else
|
return ScaleFactor(46);
|
||||||
sf = ScaleFactor(46);
|
|
||||||
}
|
}
|
||||||
// Endings where weaker side can place his king in front of the opponent's
|
// Endings where weaker side can place his king in front of the opponent's
|
||||||
// pawns are drawish.
|
// pawns are drawish.
|
||||||
else if ( abs(eg) <= BishopValueEg
|
else if ( abs(eg) <= BishopValueEg
|
||||||
&& pos.count<PAWN>(strongSide) <= 2
|
&& pos.count<PAWN>(strongSide) <= 2
|
||||||
&& !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide)))
|
&& !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide)))
|
||||||
sf = ScaleFactor(37 + 7 * pos.count<PAWN>(strongSide));
|
return ScaleFactor(37 + 7 * pos.count<PAWN>(strongSide));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sf;
|
return sf;
|
||||||
|
|||||||
Reference in New Issue
Block a user