mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 17:46:26 +08:00
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.
This commit is contained in:
@@ -1140,8 +1140,6 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
|||||||
|
|
||||||
std::string Tracing::do_trace(const Position& pos) {
|
std::string Tracing::do_trace(const Position& pos) {
|
||||||
|
|
||||||
Search::RootColor = pos.side_to_move();
|
|
||||||
|
|
||||||
stream.str("");
|
stream.str("");
|
||||||
stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
|
stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
|
||||||
std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score));
|
std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score));
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ void UCI::loop(const string& args) {
|
|||||||
<< "\n" << Options
|
<< "\n" << Options
|
||||||
<< "\nuciok" << sync_endl;
|
<< "\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 == "ucinewgame") TT.clear();
|
||||||
else if (token == "go") go(pos, is);
|
else if (token == "go") go(pos, is);
|
||||||
else if (token == "position") position(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 == "bench") benchmark(pos, is);
|
||||||
else if (token == "d") sync_cout << pos.pretty() << sync_endl;
|
else if (token == "d") sync_cout << pos.pretty() << sync_endl;
|
||||||
else if (token == "isready") sync_cout << "readyok" << sync_endl;
|
else if (token == "isready") sync_cout << "readyok" << sync_endl;
|
||||||
else if (token == "eval") sync_cout << Eval::trace(pos) << sync_endl;
|
|
||||||
else
|
else
|
||||||
sync_cout << "Unknown command: " << cmd << sync_endl;
|
sync_cout << "Unknown command: " << cmd << sync_endl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user