+ istringstream is(cmd);
+
+ is >> skipws >> token;
+
+ if (cmd == "quit" || cmd == "stop")
+ {
+ quit = (token == "quit");
+ Search::Signals.stop = true;
+ Threads[0].wake_up(); // In case is waiting for stop or ponderhit
+ }
+
+ else if (cmd == "ponderhit")
+ {
+ // The opponent has played the expected move. GUI sends "ponderhit" if
+ // we were told to ponder on the same move the opponent has played. We
+ // should continue searching but switching from pondering to normal search.
+ Search::Limits.ponder = false; // FIXME racing
+
+ if (Search::Signals.stopOnPonderhit)
+ {
+ Search::Signals.stop = true;
+ Threads[0].wake_up(); // In case is waiting for stop or ponderhit
+ }
+ }
+
+ else if (token == "go")
+ go(pos, is);
+
+ else if (token == "ucinewgame")
+ pos.from_fen(StarFEN, false);
+
+ else if (token == "isready")
+ cout << "readyok" << endl;
+
+ else if (token == "position")
+ set_position(pos, is);
+
+ else if (token == "setoption")
+ set_option(is);
+
+ else if (token == "perft")
+ perft(pos, is);
+
+ else if (token == "d")
+ pos.print();
+
+ else if (token == "flip")
+ pos.flip_me();
+
+ else if (token == "eval")
+ {
+ read_evaluation_uci_options(pos.side_to_move());
+ cout << trace_evaluate(pos) << endl;
+ }
+
+ else if (token == "key")
+ cout << "key: " << hex << pos.get_key()
+ << "\nmaterial key: " << pos.get_material_key()
+ << "\npawn key: " << pos.get_pawn_key() << endl;
+
+ else if (token == "uci")
+ cout << "id name " << engine_name()
+ << "\nid author " << engine_authors()
+ << "\n" << Options.print_all()
+ << "\nuciok" << endl;
+ else
+ cout << "Unknown command: " << cmd << endl;