- response->set_depth(entry->depth());
- FillValue(eval, response->mutable_eval());
- if (entry->depth() > DEPTH_NONE) {
- FillValue(value, response->mutable_value());
- }
- response->set_bound(HashProbeLine::ValueBound(bound));
-
- // Follow the PV until we hit an illegal move.
- std::stack<Move> pv;
- std::set<Key> seen;
- while (found && is_ok(entry->move())) {
- FillMove(entry->move(), response->add_pv());
- if (seen.count(pos->key())) break;
- pv.push(entry->move());
- seen.insert(pos->key());
- setup_states->push(StateInfo());
- pos->do_move(entry->move(), setup_states->top(), pos->gives_check(entry->move(), CheckInfo(*pos)));
- entry = TT.probe(pos->key(), found);
+void HashProbeImpl::ProbeMove(Position* pos, std::stack<StateInfo>* setup_states, bool invert, HashProbeLine* response) {
+ bool found;
+ TTEntry *entry = TT.probe(pos->key(), found);
+ response->set_found(found);
+ if (found) {
+ Value value = entry->value();
+ Value eval = entry->eval();
+ Bound bound = entry->bound();
+
+ if (invert) {
+ value = -value;
+ eval = -eval;
+ if (bound == BOUND_UPPER) {
+ bound = BOUND_LOWER;
+ } else if (bound == BOUND_LOWER) {
+ bound = BOUND_UPPER;