- // parameters.
-
- void go(UCIInputParser &uip) {
-
- std::string token;
-
- int time[2] = {0, 0}, inc[2] = {0, 0}, movesToGo = 0, depth = 0, nodes = 0;
- int moveTime = 0;
- bool infinite = false, ponder = false;
- Move searchMoves[500];
-
- searchMoves[0] = MOVE_NONE;
-
- while(!uip.at_end_of_line()) {
- token = uip.get_next_token();
-
- if(token == "infinite")
- infinite = true;
- else if(token == "ponder")
- ponder = true;
- else if(token == "wtime") {
- if(!uip.at_end_of_line())
- time[0] = atoi(uip.get_next_token().c_str());
- }
- else if(token == "btime") {
- if(!uip.at_end_of_line())
- time[1] = atoi(uip.get_next_token().c_str());
- }
- else if(token == "winc") {
- if(!uip.at_end_of_line())
- inc[0] = atoi(uip.get_next_token().c_str());
- }
- else if(token == "binc") {
- if(!uip.at_end_of_line())
- inc[1] = atoi(uip.get_next_token().c_str());
- }
- else if(token == "movestogo") {
- if(!uip.at_end_of_line())
- movesToGo = atoi(uip.get_next_token().c_str());
- }
- else if(token == "depth") {
- if(!uip.at_end_of_line())
- depth = atoi(uip.get_next_token().c_str());
- }
- else if(token == "nodes") {
- if(!uip.at_end_of_line())
- nodes = atoi(uip.get_next_token().c_str());
- }
- else if(token == "movetime") {
- if(!uip.at_end_of_line())
- moveTime = atoi(uip.get_next_token().c_str());
- }
- else if(token == "searchmoves" && !uip.at_end_of_line()) {
- int numOfMoves = 0;
- while(!uip.at_end_of_line()) {
- token = uip.get_next_token();
- searchMoves[numOfMoves++] = move_from_string(RootPosition, token);
+ // parameters. Returns false if a quit command is received while
+ // thinking, returns true otherwise.
+
+ bool go(Position& pos, UCIParser& up) {
+
+ string token;
+ int time[] = { 0, 0 }, inc[] = { 0, 0 };
+ SearchLimits limits(0, 0, 0, 0, 0, 0, false, false);
+ Move searchMoves[MOVES_MAX] = { MOVE_NONE };
+ Move* cur = searchMoves;
+
+ while (up >> token)
+ {
+ if (token == "infinite")
+ limits.infinite = true;
+ else if (token == "ponder")
+ limits.ponder = true;
+ else if (token == "wtime")
+ up >> time[WHITE];
+ else if (token == "btime")
+ up >> time[BLACK];
+ else if (token == "winc")
+ up >> inc[WHITE];
+ else if (token == "binc")
+ up >> inc[BLACK];
+ else if (token == "movestogo")
+ up >> limits.movesToGo;
+ else if (token == "depth")
+ up >> limits.maxDepth;
+ else if (token == "nodes")
+ up >> limits.maxNodes;
+ else if (token == "movetime")
+ up >> limits.maxTime;
+ else if (token == "searchmoves")
+ {
+ while (up >> token)
+ *cur++ = move_from_uci(pos, token);
+
+ *cur = MOVE_NONE;