From 15616ad19965444ea66896a0511f2a4d48745110 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 11 Aug 2013 07:02:50 +0200 Subject: [PATCH 1/1] Don't set Search::RootColor in Eval::trace Search::RootColor is a global parameter set before to start a search, it is not something trace() should change. This patch allows to add trace() calls, for debugging, inside search itself without altering the bench, and also ensures that the values returned by trace() and evaluate() are fully equivalent. No functional change. --- src/evaluate.cpp | 2 -- src/uci.cpp | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 147a1b3e..70c91f8a 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1140,8 +1140,6 @@ Value do_evaluate(const Position& pos, Value& margin) { std::string Tracing::do_trace(const Position& pos) { - Search::RootColor = pos.side_to_move(); - stream.str(""); stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2); std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score)); diff --git a/src/uci.cpp b/src/uci.cpp index 95d050f3..395b78a8 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -103,6 +103,11 @@ void UCI::loop(const string& args) { << "\n" << Options << "\nuciok" << sync_endl; + else if (token == "eval") + { + Search::RootColor = pos.side_to_move(); // Ensure it is set + sync_cout << Eval::trace(pos) << sync_endl; + } else if (token == "ucinewgame") TT.clear(); else if (token == "go") go(pos, is); else if (token == "position") position(pos, is); @@ -111,7 +116,6 @@ void UCI::loop(const string& args) { else if (token == "bench") benchmark(pos, is); else if (token == "d") sync_cout << pos.pretty() << sync_endl; else if (token == "isready") sync_cout << "readyok" << sync_endl; - else if (token == "eval") sync_cout << Eval::trace(pos) << sync_endl; else sync_cout << "Unknown command: " << cmd << sync_endl; -- 2.39.2