+ for (size_t i = pv.size(); i > 0; )
+ pos.undo_move(pv[--i]);
+}
+
+
+/// RootMove::extract_ponder_from_tt() is called in case we have no ponder move before
+/// exiting the search, for instance in case we stop the search during a fail high at
+/// root. We try hard to have a ponder move to return to the GUI, otherwise in case of
+/// 'ponder on' we have nothing to think on.
+
+bool RootMove::extract_ponder_from_tt(Position& pos)
+{
+ StateInfo st;
+ bool ttHit;
+
+ assert(pv.size() == 1);
+
+ pos.do_move(pv[0], st);
+ TTEntry* tte = TT.probe(pos.key(), ttHit);
+ pos.undo_move(pv[0]);
+
+ if (ttHit)
+ {
+ Move m = tte->move(); // Local copy to be SMP safe
+ if (MoveList<LEGAL>(pos).contains(m))
+ return pv.push_back(m), true;
+ }
+
+ return false;