]> git.sesse.net Git - stockfish/commitdiff
Retire update_gains()
authorMarco Costalba <mcostalba@gmail.com>
Sun, 30 Oct 2011 21:52:59 +0000 (22:52 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 30 Oct 2011 22:05:31 +0000 (23:05 +0100)
Called from one place only.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 25a3984d69331cb8a927e4424c6d0734e8440f29..30e0502086fddb09cd0b9d41222855f478c4e178 100644 (file)
@@ -196,7 +196,6 @@ namespace {
   bool connected_threat(const Position& pos, Move m, Move threat);
   Value refine_eval(const TTEntry* tte, Value defaultEval, int ply);
   void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount);
   bool connected_threat(const Position& pos, Move m, Move threat);
   Value refine_eval(const TTEntry* tte, Value defaultEval, int ply);
   void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount);
-  void update_gains(const Position& pos, Move move, Value before, Value after);
   void do_skill_level(Move* best, Move* ponder);
 
   int current_search_time(int set = 0);
   void do_skill_level(Move* best, Move* ponder);
 
   int current_search_time(int set = 0);
@@ -503,7 +502,7 @@ namespace {
     *ponderMove = bestMove = easyMove = skillBest = skillPonder = MOVE_NONE;
     depth = aspirationDelta = 0;
     value = alpha = -VALUE_INFINITE, beta = VALUE_INFINITE;
     *ponderMove = bestMove = easyMove = skillBest = skillPonder = MOVE_NONE;
     depth = aspirationDelta = 0;
     value = alpha = -VALUE_INFINITE, beta = VALUE_INFINITE;
-    ss->currentMove = MOVE_NULL; // Hack to skip update_gains()
+    ss->currentMove = MOVE_NULL; // Hack to skip update gains
 
     // Moves to search are verified and copied
     Rml.init(pos, searchMoves);
 
     // Moves to search are verified and copied
     Rml.init(pos, searchMoves);
@@ -551,7 +550,7 @@ namespace {
             // research with bigger window until not failing high/low anymore.
             do {
                 // Search starts from ss+1 to allow referencing (ss-1). This is
             // research with bigger window until not failing high/low anymore.
             do {
                 // Search starts from ss+1 to allow referencing (ss-1). This is
-                // needed by update_gains() and ss copy when splitting at Root.
+                // needed by update gains and ss copy when splitting at Root.
                 value = search<Root>(pos, ss+1, alpha, beta, depth * ONE_PLY);
 
                 // Bring to front the best move. It is critical that sorting is
                 value = search<Root>(pos, ss+1, alpha, beta, depth * ONE_PLY);
 
                 // Bring to front the best move. It is critical that sorting is
@@ -820,8 +819,17 @@ namespace {
         TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ss->evalMargin);
     }
 
         TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ss->evalMargin);
     }
 
-    // Save gain for the parent non-capture move
-    update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, ss->eval);
+    // Update gain for the parent non-capture move given the static position
+    // evaluation before and after the move.
+    if (   (move = (ss-1)->currentMove) != MOVE_NULL
+        && (ss-1)->eval != VALUE_NONE
+        && ss->eval != VALUE_NONE
+        && pos.captured_piece_type() == PIECE_TYPE_NONE
+        && !is_special(move))
+    {
+        Square to = move_to(move);
+        H.update_gain(pos.piece_on(to), to, -(ss-1)->eval - ss->eval);
+    }
 
     // Step 6. Razoring (is omitted in PV nodes)
     if (   !PvNode
 
     // Step 6. Razoring (is omitted in PV nodes)
     if (   !PvNode
@@ -1726,20 +1734,6 @@ split_point_start: // At split points actual search starts from here
   }
 
 
   }
 
 
-  // update_gains() updates the gains table of a non-capture move given
-  // the static position evaluation before and after the move.
-
-  void update_gains(const Position& pos, Move m, Value before, Value after) {
-
-    if (   m != MOVE_NULL
-        && before != VALUE_NONE
-        && after != VALUE_NONE
-        && pos.captured_piece_type() == PIECE_TYPE_NONE
-        && !is_special(m))
-        H.update_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
-  }
-
-
   // current_search_time() returns the number of milliseconds which have passed
   // since the beginning of the current search.
 
   // current_search_time() returns the number of milliseconds which have passed
   // since the beginning of the current search.