- 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);
- }
+ }
+ 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()) &&
+ pos->pseudo_legal(entry->move()) &&
+ pos->legal(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_back(StateInfo());
+ pos->do_move(entry->move(), setup_states->back(), pos->gives_check(entry->move()));
+ entry = TT.probe(pos->key(), found);
+ }