#include <string>
#include "evaluate.h"
+#include "cluster.h"
#include "movegen.h"
#include "position.h"
#include "search.h"
if (Options.count(name))
Options[name] = value;
- else
+ else if (Cluster::is_root())
sync_cout << "No such option: " << name << sync_endl;
}
if (token == "go" || token == "eval")
{
- cerr << "\nPosition: " << cnt++ << '/' << num << " (" << pos.fen() << ")" << endl;
+ if (Cluster::is_root())
+ cerr << "\nPosition: " << cnt++ << '/' << num << " (" << pos.fen() << ")" << endl;
+
if (token == "go")
{
go(pos, is, states);
Threads.main()->wait_for_search_finished();
nodes += Threads.nodes_searched();
}
- else
+ else if (Cluster::is_root())
trace_eval(pos);
}
else if (token == "setoption") setoption(is);
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;
}
// The win rate model returns the probability (per mille) of winning given an eval
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);
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;
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") trace_eval(pos);
- else if (token == "compiler") sync_cout << compiler_info() << sync_endl;
- else
+ else if (token == "d" && Cluster::is_root())
+ sync_cout << pos << sync_endl;
+ else if (token == "eval" && Cluster::is_root())
+ trace_eval(pos);
+ else if (token == "compiler" && Cluster::is_root())
+ sync_cout << compiler_info() << 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