Also small tweak to extract_ponder_from_tt
No functional change.
void RootMove::insert_pv_in_tt(Position& pos) {
StateInfo state[MAX_PLY], *st = state;
void RootMove::insert_pv_in_tt(Position& pos) {
StateInfo state[MAX_PLY], *st = state;
- for ( ; idx < pv.size(); ++idx)
- bool ttHit;
- TTEntry* tte = TT.probe(pos.key(), ttHit);
+ assert(MoveList<LEGAL>(pos).contains(m));
- if (!ttHit || tte->move() != pv[idx]) // Don't overwrite correct entries
- tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, pv[idx], VALUE_NONE, TT.generation());
+ TTEntry* tte = TT.probe(pos.key(), ttHit);
- assert(MoveList<LEGAL>(pos).contains(pv[idx]));
+ if (!ttHit || tte->move() != m) // Don't overwrite correct entries
+ tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, m, VALUE_NONE, TT.generation());
- pos.do_move(pv[idx], *st++);
- while (idx) pos.undo_move(pv[--idx]);
+ for (size_t i = pv.size(); i > 0; )
+ pos.undo_move(pv[--i]);
/// 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.
/// 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.
-Move RootMove::extract_ponder_from_tt(Position& pos)
+bool RootMove::extract_ponder_from_tt(Position& pos)
assert(pv.size() == 1);
pos.do_move(pv[0], st);
assert(pv.size() == 1);
pos.do_move(pv[0], st);
- TTEntry* tte = TT.probe(pos.key(), found);
- Move m = found ? tte->move() : MOVE_NONE;
- if (!MoveList<LEGAL>(pos).contains(m))
- m = MOVE_NONE;
-
+ TTEntry* tte = TT.probe(pos.key(), ttHit);
- pv.push_back(m);
- return m;
+
+ 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;
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
bool operator==(const Move& m) const { return pv[0] == m; }
void insert_pv_in_tt(Position& pos);
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
bool operator==(const Move& m) const { return pv[0] == m; }
void insert_pv_in_tt(Position& pos);
- Move extract_ponder_from_tt(Position& pos);
+ bool extract_ponder_from_tt(Position& pos);
Value score;
Value previousScore;
Value score;
Value previousScore;