/* * Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2023, Tim Ledbetter * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "MCTSTree.h" #include #include class ChessEngine : public Chess::UCI::Endpoint { C_OBJECT(ChessEngine) public: virtual ~ChessEngine() override = default; 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; virtual void handle_ucinewgame() override; virtual void handle_unexpected_eof() override; Function on_quit; private: ChessEngine(NonnullRefPtr in, NonnullRefPtr out) : Endpoint(in, out) { on_command_read_error = [](auto command, auto error) { outln("{}: '{}'", error, command); }; } Chess::Board m_board; Optional m_last_tree; };