ladybird/Userland/Games/Chess/Engine.h
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

39 lines
956 B
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibChess/UCIEndpoint.h>
#include <sys/types.h>
class Engine : public Chess::UCI::Endpoint {
C_OBJECT(Engine)
public:
virtual ~Engine() override;
Engine(const StringView& command);
Engine(const Engine&) = delete;
Engine& operator=(const Engine&) = delete;
virtual void handle_bestmove(const Chess::UCI::BestMoveCommand&);
template<typename Callback>
void get_best_move(const Chess::Board& board, int time_limit, Callback&& callback)
{
send_command(Chess::UCI::PositionCommand({}, board.moves()));
Chess::UCI::GoCommand go_command;
go_command.movetime = time_limit;
send_command(go_command);
m_bestmove_callback = move(callback);
}
private:
Function<void(Chess::Move)> m_bestmove_callback;
pid_t m_pid { -1 };
};