From 12c6c2f550dab77dcbc5381900f59a7f9694126b Mon Sep 17 00:00:00 2001 From: nodchip Date: Mon, 10 Aug 2020 13:07:22 +0900 Subject: [PATCH] Chagned to use the search value instead of the value of the PV leaf to avoid crash by assertion. --- src/learn/learner.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index 4b76e444..998c82eb 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -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?