]> git.sesse.net Git - stockfish/commitdiff
Extend bench to static evaluations
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Wed, 27 Nov 2019 18:03:23 +0000 (19:03 +0100)
committerStéphane Nicolet <Stephane.Nicolet@u-paris2.fr>
Thu, 28 Nov 2019 09:39:02 +0000 (10:39 +0100)
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.

src/benchmark.cpp
src/evaluate.cpp
src/uci.cpp

index 8f30bee4f8eadeb2098173b288a232102e003a44..58f05e668a5504e3715350ef87dd52b9cac12c1e 100644 (file)
@@ -117,7 +117,7 @@ vector<string> 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;
index 116d5d6616838696d1b6787a85d8fc2f029e7c40..e42b4f387ccafc533952586f863a221a5ddca908 100644 (file)
@@ -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
index 99bf1a13fa729c673e7883de3782522a6f7848c9..6f0bdd769d1b4e805ee0a5949c85735b54bfe5ef 100644 (file)
@@ -146,7 +146,7 @@ namespace {
     uint64_t num, nodes = 0, cnt = 1;
 
     vector<string> 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);