Chagned to use the search value instead of the value of the PV leaf to avoid crash by assertion.

This commit is contained in:
nodchip
2020-08-10 13:07:22 +09:00
parent bac96aa04a
commit 12c6c2f550

View File

@@ -639,13 +639,21 @@ void MultiThinkGenSfen::thread_worker(size_t thread_id)
}
// reach leaf
// cout << pos;
auto v = Eval::evaluate(pos);
// evaluate() returns the evaluation value on the turn side, so
// If it's a turn different from root_color, you must invert v and return it.
if (rootColor != pos.side_to_move())
v = -v;
Value v;
if (pos.checkers()) {
// Sometime a king is checked. An example is a case that a checkmate is
// found in the search. If Eval::evaluate() is called whne a king is
// checked, classic eval crashes by an assertion. To avoid crashes, return
// value1 instead of the score of the PV leaf.
v = value1;
}
else {
v = Eval::evaluate(pos);
// evaluate() returns the evaluation value on the turn side, so
// If it's a turn different from root_color, you must invert v and return it.
if (rootColor != pos.side_to_move())
v = -v;
}
// Rewind.
// Is it C++x14, and isn't there even foreach to turn in reverse?