summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Ledbetter <timledbetter@gmail.com>2023-04-26 19:02:42 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-28 05:55:51 +0200
commit536f6b8b3467e5b0a15bce29b7375e1e2a0cc2d6 (patch)
tree0abe6c29974a30901a019c9646f1c29de6b68d4e
parent18735960de45781a574601b603dbe803f5c490c1 (diff)
downloadserenity-536f6b8b3467e5b0a15bce29b7375e1e2a0cc2d6.zip
ChessEngine: Reset the engine state on receiving a ucinewgame command
-rw-r--r--Userland/Services/ChessEngine/ChessEngine.cpp6
-rw-r--r--Userland/Services/ChessEngine/ChessEngine.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Services/ChessEngine/ChessEngine.cpp b/Userland/Services/ChessEngine/ChessEngine.cpp
index b1195590a1..e68e45e67b 100644
--- a/Userland/Services/ChessEngine/ChessEngine.cpp
+++ b/Userland/Services/ChessEngine/ChessEngine.cpp
@@ -74,3 +74,9 @@ void ChessEngine::handle_unexpected_eof()
if (on_quit)
on_quit(EPIPE);
}
+
+void ChessEngine::handle_ucinewgame()
+{
+ m_board = Chess::Board();
+ m_last_tree = {};
+}
diff --git a/Userland/Services/ChessEngine/ChessEngine.h b/Userland/Services/ChessEngine/ChessEngine.h
index 1ffd6ea237..9afc0fc394 100644
--- a/Userland/Services/ChessEngine/ChessEngine.h
+++ b/Userland/Services/ChessEngine/ChessEngine.h
@@ -19,6 +19,7 @@ public:
virtual void handle_position(Chess::UCI::PositionCommand const&) override;
virtual void handle_go(Chess::UCI::GoCommand const&) override;
virtual void handle_quit() override;
+ virtual void handle_ucinewgame() override;
virtual void handle_unexpected_eof() override;
Function<void(int)> on_quit;