]> git.sesse.net Git - stockfish/blobdiff - src/tt.cpp
Extract only exact scores to get the PV
[stockfish] / src / tt.cpp
index 6dd2a10d339e8b7584375e7cc63f7241eaea3852..f3af6432a090149ca3905839abd879b0bf33f9a7 100644 (file)
@@ -185,20 +185,23 @@ 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.
 
-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;
 
-  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
+  // Extract moves from TT when possible. We try hard to always
+  // get a ponder move, that's the reason of ply < 2 conditions.
   while (   (tte = retrieve(p.get_key())) != NULL
          && tte->move() != MOVE_NONE
+         && (tte->type() == VALUE_TYPE_EXACT || ply < 2)
          && move_is_legal(p, tte->move())
          && (!p.is_draw() || ply < 2)
          && ply < PLY_MAX)