]> git.sesse.net Git - stockfish/commitdiff
Retire update_pv() and sp_update_pv()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 26 Jun 2010 14:22:13 +0000 (15:22 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 26 Jun 2010 14:43:54 +0000 (15:43 +0100)
Expand inline instead.

No functional change.

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

index 7699a74658acbab8207b9b66172696f816f05354..8ea1b718825dc1fc684c156235718e412fb49f64 100644 (file)
@@ -296,8 +296,6 @@ namespace {
   template <NodeType PvNode>
   Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous);
 
   template <NodeType PvNode>
   Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous);
 
-  void update_pv(SearchStack* ss);
-  void sp_update_pv(SearchStack* pss, SearchStack* ss);
   bool connected_moves(const Position& pos, Move m1, Move m2);
   bool value_is_mate(Value value);
   bool move_is_killer(Move m, SearchStack* ss);
   bool connected_moves(const Position& pos, Move m1, Move m2);
   bool value_is_mate(Value value);
   bool move_is_killer(Move m, SearchStack* ss);
@@ -937,9 +935,8 @@ namespace {
                 // We are failing high and going to do a research. It's important to update
                 // the score before research in case we run out of time while researching.
                 rml.set_move_score(i, value);
                 // We are failing high and going to do a research. It's important to update
                 // the score before research in case we run out of time while researching.
                 rml.set_move_score(i, value);
-                update_pv(ss);
-                pv[0] = ss->bestMove;
-                TT.extract_pv(pos, pv, PLY_MAX);
+                ss->bestMove = move;
+                TT.extract_pv(pos, move, pv, PLY_MAX);
                 rml.set_move_pv(i, pv);
 
                 // Print information to the standard output
                 rml.set_move_pv(i, pv);
 
                 // Print information to the standard output
@@ -978,9 +975,8 @@ namespace {
 
                 // Update PV
                 rml.set_move_score(i, value);
 
                 // Update PV
                 rml.set_move_score(i, value);
-                update_pv(ss);
-                pv[0] = ss->bestMove;
-                TT.extract_pv(pos, pv, PLY_MAX);
+                ss->bestMove = move;
+                TT.extract_pv(pos, move, pv, PLY_MAX);
                 rml.set_move_pv(i, pv);
 
                 if (MultiPV == 1)
                 rml.set_move_pv(i, pv);
 
                 if (MultiPV == 1)
@@ -1414,10 +1410,10 @@ namespace {
               if (PvNode && value < beta) // This guarantees that always: alpha < beta
                   alpha = value;
 
               if (PvNode && value < beta) // This guarantees that always: alpha < beta
                   alpha = value;
 
-              update_pv(ss);
-
               if (value == value_mate_in(ply + 1))
                   ss->mateKiller = move;
               if (value == value_mate_in(ply + 1))
                   ss->mateKiller = move;
+
+              ss->bestMove = move;
           }
       }
 
           }
       }
 
@@ -1617,7 +1613,7 @@ namespace {
           if (value > alpha)
           {
               alpha = value;
           if (value > alpha)
           {
               alpha = value;
-              update_pv(ss);
+              ss->bestMove = move;
           }
        }
     }
           }
        }
     }
@@ -1798,7 +1794,7 @@ namespace {
               if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta
                   sp->alpha = value;
 
               if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta
                   sp->alpha = value;
 
-              sp_update_pv(sp->parentSstack, ss);
+              sp->parentSstack->bestMove = ss->bestMove = move;
           }
       }
     }
           }
       }
     }
@@ -1810,25 +1806,6 @@ namespace {
     lock_release(&(sp->lock));
   }
 
     lock_release(&(sp->lock));
   }
 
-  // update_pv() is called whenever a search returns a value > alpha.
-  // It updates the PV in the SearchStack object corresponding to the
-  // current node.
-
-  void update_pv(SearchStack* ss) {
-
-    ss->bestMove = ss->currentMove;
-  }
-
-
-  // sp_update_pv() is a variant of update_pv for use at split points. The
-  // difference between the two functions is that sp_update_pv also updates
-  // the PV at the parent node.
-
-  void sp_update_pv(SearchStack* pss, SearchStack* ss) {
-
-    pss->bestMove = ss->bestMove = ss->currentMove;
-  }
-
 
   // connected_moves() tests whether two moves are 'connected' in the sense
   // that the first move somehow made the second move possible (for instance
 
   // connected_moves() tests whether two moves are 'connected' in the sense
   // that the first move somehow made the second move possible (for instance
index 6dd2a10d339e8b7584375e7cc63f7241eaea3852..b7d47e7498951320a861dd60c66877a0a3ce710e 100644 (file)
@@ -185,15 +185,16 @@ void TranspositionTable::insert_pv(const Position& pos, Move pv[]) {
 /// will often get single-move PVs when the search stops while failing high,
 /// and a single-move PV means that we don't have a ponder move.
 
 /// will often get single-move PVs when the search stops while failing high,
 /// and a single-move PV means that we don't have a ponder move.
 
-void TranspositionTable::extract_pv(const Position& pos, Move pv[], const int PLY_MAX) {
+void TranspositionTable::extract_pv(const Position& pos, Move bestMove, Move pv[], const int PLY_MAX) {
 
   const TTEntry* tte;
   StateInfo st;
   Position p(pos, pos.thread());
   int ply = 0;
 
 
   const TTEntry* tte;
   StateInfo st;
   Position p(pos, pos.thread());
   int ply = 0;
 
-  assert(pv[0] != MOVE_NONE);
+  assert(bestMove != MOVE_NONE);
 
 
+  pv[ply] = bestMove;
   p.do_move(pv[ply++], st);
 
   // Try to add moves from TT while possible
   p.do_move(pv[ply++], st);
 
   // Try to add moves from TT while possible
index bcc761acf325da0999838b2f209cb4faab92bb33..b43489dd796ebc8aff60902f12766b5ed5bedc7f 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -110,7 +110,7 @@ public:
   TTEntry* retrieve(const Key posKey) const;
   void new_search();
   void insert_pv(const Position& pos, Move pv[]);
   TTEntry* retrieve(const Key posKey) const;
   void new_search();
   void insert_pv(const Position& pos, Move pv[]);
-  void extract_pv(const Position& pos, Move pv[], const int PLY_MAX);
+  void extract_pv(const Position& pos, Move bestMove, Move pv[], const int PLY_MAX);
   int full() const;
   TTEntry* first_entry(const Key posKey) const;
 
   int full() const;
   TTEntry* first_entry(const Key posKey) const;