]> git.sesse.net Git - stockfish/commitdiff
Rearrange interpolation formula
authorMarco Costalba <mcostalba@gmail.com>
Mon, 28 Apr 2014 15:15:16 +0000 (17:15 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 28 Apr 2014 15:27:49 +0000 (17:27 +0200)
Put the division at the end to reduce
rounding errors. This alters the bench
due to different rounding errors, but
should not alter ELO in any way.

bench: 7615217

src/evaluate.cpp

index ccc3d9154d62612daea3c68ab972e42d6afb2553..ede94ec0d7beaaeaf5d34b2d035a961fc7dde37c 100644 (file)
@@ -779,9 +779,9 @@ namespace {
              sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL);
     }
 
-    // Interpolate between a middlegame and an endgame score, scaling by 'sf'
+    // Interpolate between a middlegame and a (scaled by 'sf') endgame score
     Value v =  mg_value(score) * int(ei.mi->game_phase())
-             + eg_value(score) * int(sf) / SCALE_FACTOR_NORMAL * int(PHASE_MIDGAME - ei.mi->game_phase());
+             + eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL;
 
     v /= PHASE_MIDGAME;