소스 검색

ChessEngine: Reset the engine state on receiving a ucinewgame command

Tim Ledbetter 2 년 전
부모
커밋
536f6b8b34
2개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      Userland/Services/ChessEngine/ChessEngine.cpp
  2. 1 0
      Userland/Services/ChessEngine/ChessEngine.h

+ 6 - 0
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 = {};
+}

+ 1 - 0
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;