mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
ChessEngine: Handle the UCI quit command
This commit is contained in:
parent
13dbc69c23
commit
c2b9376409
3 changed files with 13 additions and 0 deletions
|
@ -62,3 +62,9 @@ void ChessEngine::handle_go(GoCommand const& command)
|
|||
|
||||
m_last_tree = move(best_node);
|
||||
}
|
||||
|
||||
void ChessEngine::handle_quit()
|
||||
{
|
||||
if (on_quit)
|
||||
on_quit(ESUCCESS);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ public:
|
|||
virtual void handle_uci() override;
|
||||
virtual void handle_position(Chess::UCI::PositionCommand const&) override;
|
||||
virtual void handle_go(Chess::UCI::GoCommand const&) override;
|
||||
virtual void handle_quit() override;
|
||||
|
||||
Function<void(int)> on_quit;
|
||||
|
||||
private:
|
||||
ChessEngine() = default;
|
||||
|
|
|
@ -17,5 +17,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto engine = TRY(ChessEngine::try_create(Core::DeprecatedFile::standard_input(), Core::DeprecatedFile::standard_output()));
|
||||
engine->on_quit = [&](auto status_code) {
|
||||
loop.quit(status_code);
|
||||
};
|
||||
|
||||
return loop.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue