X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=a6db7a3ef8883b41701200f7d5e0124bb33be5ea;hp=64863be166b07f84f53571c10ee79e392f3d210d;hb=5c81602d14539f8259a715477315e28b5de7cb54;hpb=2155fb78256204aae5aa80946dfe7d8d9c6e2397 diff --git a/src/search.cpp b/src/search.cpp index 64863be1..a6db7a3e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008 Marco Costalba + Copyright (C) 2008-2009 Marco Costalba Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -359,10 +359,11 @@ void SearchStack::initKillers() { //// /// think() is the external interface to Stockfish's search, and is called when -/// the program receives the UCI 'go' command. It initializes various -/// search-related global variables, and calls root_search() +/// the program receives the UCI 'go' command. It initializes various +/// search-related global variables, and calls root_search(). It returns false +/// when a quit command is received during the search. -void think(const Position &pos, bool infinite, bool ponder, int side_to_move, +bool think(const Position &pos, bool infinite, bool ponder, int side_to_move, int time[], int increment[], int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]) { @@ -377,7 +378,7 @@ void think(const Position &pos, bool infinite, bool ponder, int side_to_move, if (bookMove != MOVE_NONE) { std::cout << "bestmove " << bookMove << std::endl; - return; + return true; } } @@ -541,13 +542,8 @@ void think(const Position &pos, bool infinite, bool ponder, int side_to_move, if (UseLogFile) LogFile.close(); - if (Quit) - { - stop_threads(); - quit_eval(); - exit(0); - } Idle = true; + return !Quit; } @@ -2454,6 +2450,7 @@ namespace { AbortSearch = true; PonderSearch = false; Quit = true; + return; } else if(command == "stop") { @@ -2551,19 +2548,21 @@ namespace { // after which the bestmove and pondermove will be printed (in id_loop()). void wait_for_stop_or_ponderhit() { + std::string command; - while(true) { - if(!std::getline(std::cin, command)) - command = "quit"; + while (true) + { + if (!std::getline(std::cin, command)) + command = "quit"; - if(command == "quit") { - stop_threads(); - quit_eval(); - exit(0); - } - else if(command == "ponderhit" || command == "stop") - break; + if (command == "quit") + { + Quit = true; + break; + } + else if(command == "ponderhit" || command == "stop") + break; } }