]> git.sesse.net Git - stockfish/blobdiff - src/uci.cpp
Merge remote-tracking branch 'upstream/master' into clusterMergeMaster7
[stockfish] / src / uci.cpp
index 99bf1a13fa729c673e7883de3782522a6f7848c9..00e8ff54f6957852015dfd67dda4b9cd2e8f5d33 100644 (file)
@@ -24,6 +24,7 @@
 #include <string>
 
 #include "evaluate.h"
+#include "cluster.h"
 #include "movegen.h"
 #include "position.h"
 #include "search.h"
@@ -97,7 +98,7 @@ namespace {
 
     if (Options.count(name))
         Options[name] = value;
-    else
+    else if (Cluster::is_root())
         sync_cout << "No such option: " << name << sync_endl;
   }
 
@@ -157,10 +158,11 @@ namespace {
 
         if (token == "go")
         {
-            cerr << "\nPosition: " << cnt++ << '/' << num << endl;
+            if (Cluster::is_root())
+                cerr << "\nPosition: " << cnt++ << '/' << num << endl;
             go(pos, is, states);
             Threads.main()->wait_for_search_finished();
-            nodes += Threads.nodes_searched();
+            nodes += Cluster::nodes_searched();
         }
         else if (token == "setoption")  setoption(is);
         else if (token == "position")   position(pos, is, states);
@@ -171,10 +173,11 @@ namespace {
 
     dbg_print(); // Just before exiting
 
-    cerr << "\n==========================="
-         << "\nTotal time (ms) : " << elapsed
-         << "\nNodes searched  : " << nodes
-         << "\nNodes/second    : " << 1000 * nodes / elapsed << endl;
+    if (Cluster::is_root())
+        cerr << "\n==========================="
+             << "\nTotal time (ms) : " << elapsed
+             << "\nNodes searched  : " << nodes
+             << "\nNodes/second    : " << 1000 * nodes / elapsed << endl;
   }
 
 } // namespace
@@ -198,7 +201,7 @@ void UCI::loop(int argc, char* argv[]) {
       cmd += std::string(argv[i]) + " ";
 
   do {
-      if (argc == 1 && !getline(cin, cmd)) // Block here waiting for input or EOF
+      if (argc == 1 && !Cluster::getline(cin, cmd)) // Block here waiting for input or EOF
           cmd = "quit";
 
       istringstream is(cmd);
@@ -217,7 +220,7 @@ void UCI::loop(int argc, char* argv[]) {
       else if (token == "ponderhit")
           Threads.main()->ponder = false; // Switch to normal search
 
-      else if (token == "uci")
+      else if (token == "uci" && Cluster::is_root())
           sync_cout << "id name " << engine_info(true)
                     << "\n"       << Options
                     << "\nuciok"  << sync_endl;
@@ -226,15 +229,18 @@ void UCI::loop(int argc, char* argv[]) {
       else if (token == "go")         go(pos, is, states);
       else if (token == "position")   position(pos, is, states);
       else if (token == "ucinewgame") Search::clear();
-      else if (token == "isready")    sync_cout << "readyok" << sync_endl;
+      else if (token == "isready" && Cluster::is_root())
+          sync_cout << "readyok" << sync_endl;
 
       // Additional custom non-UCI commands, mainly for debugging.
       // Do not use these commands during a search!
       else if (token == "flip")  pos.flip();
       else if (token == "bench") bench(pos, is, states);
-      else if (token == "d")     sync_cout << pos << sync_endl;
-      else if (token == "eval")  sync_cout << Eval::trace(pos) << sync_endl;
-      else
+      else if (token == "d" && Cluster::is_root())
+          sync_cout << pos << sync_endl;
+      else if (token == "eval" && Cluster::is_root())
+          sync_cout << Eval::trace(pos) << sync_endl;
+      else if (Cluster::is_root())
           sync_cout << "Unknown command: " << cmd << sync_endl;
 
   } while (token != "quit" && argc == 1); // Command line args are one-shot