From: Joost VandeVondele Date: Wed, 27 Nov 2019 18:03:23 +0000 (+0100) Subject: Extend bench to static evaluations X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=54253bcce69a0ebc3e6bc4c35dfa76f8ff46521e Extend bench to static evaluations this patch extends bench to print static evaluations. ./stockfish bench 16 1 1 filename eval will now print the evaluations for all fens in the file. This complements the various 'go' flavors for bench and might be useful for debugging and/or tuning. No functional change. --- diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 8f30bee4..58f05e66 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -117,7 +117,7 @@ vector setup_bench(const Position& current, istream& is) { string fenFile = (is >> token) ? token : "default"; string limitType = (is >> token) ? token : "depth"; - go = "go " + limitType + " " + limit; + go = limitType == "eval" ? "eval" : "go " + limitType + " " + limit; if (fenFile == "default") fens = Defaults; diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 116d5d66..e42b4f38 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -847,6 +847,9 @@ Value Eval::evaluate(const Position& pos) { std::string Eval::trace(const Position& pos) { + if (pos.checkers()) + return "Total evaluation: none (in check)"; + std::memset(scores, 0, sizeof(scores)); pos.this_thread()->contempt = SCORE_ZERO; // Reset any dynamic contempt diff --git a/src/uci.cpp b/src/uci.cpp index 99bf1a13..6f0bdd76 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -146,7 +146,7 @@ namespace { uint64_t num, nodes = 0, cnt = 1; vector list = setup_bench(pos, args); - num = count_if(list.begin(), list.end(), [](string s) { return s.find("go ") == 0; }); + num = count_if(list.begin(), list.end(), [](string s) { return s.find("go ") == 0 || s.find("eval") == 0; }); TimePoint elapsed = now(); @@ -155,12 +155,17 @@ namespace { istringstream is(cmd); is >> skipws >> token; - if (token == "go") + if (token == "go" || token == "eval") { cerr << "\nPosition: " << cnt++ << '/' << num << endl; - go(pos, is, states); - Threads.main()->wait_for_search_finished(); - nodes += Threads.nodes_searched(); + if (token == "go") + { + go(pos, is, states); + Threads.main()->wait_for_search_finished(); + nodes += Threads.nodes_searched(); + } + else + sync_cout << "\n" << Eval::trace(pos) << sync_endl; } else if (token == "setoption") setoption(is); else if (token == "position") position(pos, is, states);