if (Options["Protocol"] == "xboard")
{
// Send move only when not in analyze mode and not at game end
- if (!Options["UCI_AnalyseMode"] && rootMoves[0].pv[0] != MOVE_NONE)
+ if (!Options["UCI_AnalyseMode"] && rootMoves[0].pv[0] != MOVE_NONE && !Threads.abort.exchange(true))
sync_cout << "move " << UCI::move(rootPos, bestThread->rootMoves[0].pv[0]) << sync_endl;
return;
}
main()->wait_for_search_finished();
- main()->stopOnPonderhit = stop = false;
+ main()->stopOnPonderhit = stop = abort = false;
main()->ponder = ponderMode;
Search::Limits = limits;
Search::RootMoves rootMoves;
/// StateMachine::process_command() processes commands of the XBoard protocol.
void StateMachine::process_command(Position& pos, std::string token, std::istringstream& is, StateListPtr& states) {
- if (moveAfterSearch)
+ if (moveAfterSearch && token != "ptell")
{
+ // abort search in bughouse when receiving "holding" command
+ bool doMove = token != "holding" || Threads.abort.exchange(true);
Threads.stop = true;
Threads.main()->wait_for_search_finished();
- do_move(pos, moveList, states, Threads.main()->bestThread->rootMoves[0].pv[0]);
- moveAfterSearch = false;
+ if (doMove)
+ {
+ do_move(pos, moveList, states, Threads.main()->bestThread->rootMoves[0].pv[0]);
+ moveAfterSearch = false;
+ }
}
if (token == "protover")
{
std::string fen = pos.fen(false, white_holdings + black_holdings);
setboard(pos, states, fen);
}
+ // restart search
+ if (moveAfterSearch)
+ go(pos, limits, states);
}
// Additional custom non-XBoard commands
else if (token == "perft")