From 802ff4b379da29baaa3363a993f5c8ea319a4ecd Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 17 Nov 2014 18:02:44 +0100 Subject: [PATCH] DEBUG: Instrument with Gary's test code To verify that the end position from the PV matches the evaluation score after these changes We need to temporarily disable the qsearch tt-value refinement, as that will change the score returned. --- src/search.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index d11d6be9..92a13b15 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -110,6 +110,31 @@ namespace { Move best; }; + void check_eval(const RootMove& rm, Position& pos) { + if (rm.score == 0) + return; + + std::string foo = pos.fen(); + StateInfo state[MAX_PLY+6], *st = state; + int idx = 0; + + for (; idx < int(rm.pv.size()); ++idx) { + pos.do_move(rm.pv[idx], *st++); + } + + if (abs(rm.score) != abs(evaluate(pos))) { + for (int j = 0; j < int(rm.pv.size()); ++j) + std::cout << " " << UCI::format_move(rm.pv[j], false); + std::cout << std::endl << foo << std::endl << pos.fen(); + std::cout << std::endl << "Eval mismatch: " << rm.score << " " << evaluate(pos) << std::endl; + exit(1); + } + else + std::cerr << "Success!!: " << rm.score << " " << evaluate(pos) << std::endl; + + while (idx) pos.undo_move(rm.pv[--idx]); + } + } // namespace @@ -344,6 +369,9 @@ namespace { else if ( PVIdx + 1 == std::min(multiPV, RootMoves.size()) || Time::now() - SearchTime > 3000) sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; + + if (!Signals.stop) + check_eval(RootMoves[0], RootPos); } // If skill levels are enabled and time is up, pick a sub-optimal best move @@ -1082,10 +1110,10 @@ moves_loop: // When in check and at SpNode search starts from here if ((ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE) ss->staticEval = bestValue = evaluate(pos); - // Can ttValue be used as a better position evaluation? - if (ttValue != VALUE_NONE) - if (tte->bound() & (ttValue > bestValue ? BOUND_LOWER : BOUND_UPPER)) - bestValue = ttValue; +// // Can ttValue be used as a better position evaluation? +// if (ttValue != VALUE_NONE) +// if (tte->bound() & (ttValue > bestValue ? BOUND_LOWER : BOUND_UPPER)) +// bestValue = ttValue; } else ss->staticEval = bestValue =