-/// RootMove::extract_pv_from_tt() builds a PV by adding moves from the TT table.
-/// We also consider both failing high nodes and BOUND_EXACT nodes here to
-/// ensure that we have a ponder move even when we fail high at root. This
-/// results in a long PV to print that is important for position analysis.
-
-void RootMove::extract_pv_from_tt(Position& pos) {
-
- StateInfo state[MAX_PLY], *st = state;
- const TTEntry* tte;
- int ply = 1; // At root ply is 1...
- Move m = pv[0]; // ...instead pv[] array starts from 0
- Value expectedScore = score;
-
- pv.clear();
-
- do {
- pv.push_back(m);
-
- assert(MoveList<LEGAL>(pos).contains(pv[ply - 1]));
-
- pos.do_move(pv[ply++ - 1], *st++);
- tte = TT.probe(pos.key());
- expectedScore = -expectedScore;
-
- } while ( tte
- && expectedScore == value_from_tt(tte->value(), ply)
- && pos.pseudo_legal(m = tte->move()) // Local copy, TT could change
- && pos.legal(m, pos.pinned_pieces(pos.side_to_move()))
- && ply < MAX_PLY
- && (!pos.is_draw() || ply <= 2));
-
- pv.push_back(MOVE_NONE); // Must be zero-terminating
-
- while (--ply) pos.undo_move(pv[ply - 1]);
-}
-
-