]> git.sesse.net Git - stockfish/commitdiff
Simplification of lazy threshold
authorAlain SAVARD <support@multicim.com>
Fri, 13 Jan 2017 03:11:14 +0000 (22:11 -0500)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 21 Jan 2017 09:47:54 +0000 (10:47 +0100)
Passed STC
http://tests.stockfishchess.org/tests/view/587846c10ebc5915193f74ec
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 217236 W: 39041 L: 39254 D: 138941

Passed LTC
http://tests.stockfishchess.org/tests/view/587e157a0ebc5915193f76e7
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 52396 W: 6883 L: 6804 D: 38709

This submitted version (using if (abs(mg + eg) > 1500) )
seems more logical than the following other green simplification (using if (abs(mg)>1500))
since it can happen than mg_value is > eg_value (about 20% of the time)
and the submitted version seems stronger at LTC

STC
http://tests.stockfishchess.org/tests/view/5879702d0ebc5915193f7585
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 39958 W: 7315 L: 7227 D: 25416

LTC
http://tests.stockfishchess.org/tests/view/5879af3e0ebc5915193f7592
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 204322 W: 26529 L: 26648 D: 151145

bench: 6406285

src/evaluate.cpp

index ed1bcf49036915b708a55d182813c9fb0f1255ba..4b9960d530672d2a9113112eade7e20f274e33bc 100644 (file)
@@ -217,7 +217,7 @@ namespace {
   const int KnightCheck       = 924;
 
   // Threshold for lazy evaluation
-  const Value LazyEval = Value(1500);
+  const Value LazyThreshold = Value(1500);
 
   // eval_init() initializes king and attack bitboards for a given color
   // adding pawn attacks. To be done at the beginning of the evaluation.
@@ -792,18 +792,6 @@ namespace {
     return sf;
   }
 
-
-  Value lazy_eval(Value mg, Value eg) {
-
-    if (mg > LazyEval && eg > LazyEval)
-        return  LazyEval + ((mg + eg) / 2 - LazyEval) / 4;
-
-    else if (mg < -LazyEval && eg < -LazyEval)
-        return -LazyEval + ((mg + eg) / 2 + LazyEval) / 4;
-
-    return VALUE_ZERO;
-  }
-
 } // namespace
 
 
@@ -816,6 +804,7 @@ Value Eval::evaluate(const Position& pos) {
   assert(!pos.checkers());
 
   Score mobility[COLOR_NB] = { SCORE_ZERO, SCORE_ZERO };
+  Value v;
   EvalInfo ei;
 
   // Probe the material hash table
@@ -835,11 +824,10 @@ Value Eval::evaluate(const Position& pos) {
   ei.pe = Pawns::probe(pos);
   score += ei.pe->pawns_score();
 
-  // We have taken into account all cheap evaluation terms.
-  // If score exceeds a threshold return a lazy evaluation.
-  Value lazy = lazy_eval(mg_value(score), eg_value(score));
-  if (lazy)
-      return pos.side_to_move() == WHITE ? lazy : -lazy;
+  // Early exit if score is high
+  v = (mg_value(score) + eg_value(score)) / 2;
+  if (abs(v) > LazyThreshold)
+     return pos.side_to_move() == WHITE ? v : -v;
 
   // Initialize attack and king safety bitboards
   eval_init<WHITE>(pos, ei);
@@ -874,8 +862,8 @@ Value Eval::evaluate(const Position& pos) {
   ScaleFactor sf = evaluate_scale_factor(pos, ei, eg_value(score));
 
   // Interpolate between a middlegame and a (scaled by 'sf') endgame score
-  Value v =  mg_value(score) * int(ei.me->game_phase())
-           + eg_value(score) * int(PHASE_MIDGAME - ei.me->game_phase()) * sf / SCALE_FACTOR_NORMAL;
+  v =  mg_value(score) * int(ei.me->game_phase())
+     + eg_value(score) * int(PHASE_MIDGAME - ei.me->game_phase()) * sf / SCALE_FACTOR_NORMAL;
 
   v /= int(PHASE_MIDGAME);