using namespace std;
+extern void benchmark(istringstream& is);
+
namespace {
// FEN string of the initial position, normal chess
/// that we exit gracefully if the GUI dies unexpectedly. In addition to the UCI
/// commands, the function also supports a few debug commands.
-void uci_loop() {
+void uci_loop(const string& args) {
Position pos(StartFEN, false, 0); // The root position
string cmd, token;
while (token != "quit")
{
- if (!getline(cin, cmd)) // Block here waiting for input
+ if (!args.empty())
+ cmd = args;
+
+ else if (!getline(cin, cmd)) // Block here waiting for input
cmd = "quit";
istringstream is(cmd);
else if (token == "eval")
cout << Eval::trace(pos) << endl;
+ else if (token == "bench")
+ benchmark(is);
+
else if (token == "key")
cout << "key: " << hex << pos.key()
<< "\nmaterial key: " << pos.material_key()
<< "\nuciok" << endl;
else
cout << "Unknown command: " << cmd << endl;
+
+ if (!args.empty()) // Command line arguments have one-shot behaviour
+ {
+ Threads.wait_for_search_finished();
+ break;
+ }
}
}