BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Callbacks.hpp
Go to the documentation of this file.
1/*
2 * ======================================================================================
3 *
4 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7 * ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11 *
12 * ======================================================================================
13 */
14
19
20#pragma once
21
22#include <functional>
23#include <string>
24
25namespace chess::moves {
26struct Move;
27}
28
29namespace ben_bot::search {
30
31struct Options;
32struct Result;
33
41struct Callbacks final {
43 using Callback = std::function<void(const Result&)>;
44
46 std::function<void(const Options&)> onSearchStart;
47
50
55
57 void search_start(const Options& options) const
58 {
59 if (onSearchStart != nullptr)
60 onSearchStart(options);
61 }
62
64 void search_complete(const Result& result) const
65 {
66 if (onSearchComplete != nullptr) {
67 [[likely]];
68 onSearchComplete(result);
69 }
70 }
71
73 void iteration_complete(const Result& result) const
74 {
75 if (onIteration != nullptr) {
76 [[likely]];
77 onIteration(result);
78 }
79 }
80
87 [[nodiscard]] static auto make_uci_printer(
88 std::function<bool()>&& isDebugMode)
89 -> Callbacks;
90
99 [[nodiscard]] static auto make_pretty_printer(
100 std::function<std::string(chess::moves::Move)>&& printMove)
101 -> Callbacks;
102};
103
104} // namespace ben_bot::search
std::function< void(const Result &)> Callback
Definition Callbacks.hpp:43
void search_complete(const Result &result) const
Definition Callbacks.hpp:64
static auto make_pretty_printer(std::function< std::string(chess::moves::Move)> &&printMove) -> Callbacks
static auto make_uci_printer(std::function< bool()> &&isDebugMode) -> Callbacks
void search_start(const Options &options) const
Definition Callbacks.hpp:57
std::function< void(const Options &)> onSearchStart
Definition Callbacks.hpp:46
void iteration_complete(const Result &result) const
Definition Callbacks.hpp:73