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>
24#include <string>
25
26namespace ben_bot::search {
27
28struct Options;
29struct Result;
30
31using chess::moves::Move;
32
40struct Callbacks final {
42 using Callback = std::function<void(const Result&)>;
43
45 std::function<void(const Options&)> onSearchStart;
46
49
54
59 std::function<void(Move, size_t)> onRootMove;
60
62 void search_start(const Options& options) const
63 {
64 if (onSearchStart != nullptr)
65 onSearchStart(options);
66 }
67
69 void search_complete(const Result& result) const
70 {
71 if (onSearchComplete != nullptr) {
72 [[likely]];
73 onSearchComplete(result);
74 }
75 }
76
78 void iteration_complete(const Result& result) const
79 {
80 if (onIteration != nullptr) {
81 [[likely]];
82 onIteration(result);
83 }
84 }
85
87 void root_move(const Move move, const size_t idx) const
88 {
89 if (onRootMove != nullptr) {
90 onRootMove(move, idx);
91 }
92 }
93
100 [[nodiscard]] static auto make_uci_printer(
101 std::function<bool()> isDebugMode)
102 -> Callbacks;
103
112 [[nodiscard]] static auto make_pretty_printer(
113 std::function<std::string(Move)>&& printMove)
114 -> Callbacks;
115};
116
117} // namespace ben_bot::search
std::function< void(const Result &)> Callback
Definition Callbacks.hpp:42
static auto make_uci_printer(std::function< bool()> isDebugMode) -> Callbacks
void root_move(const Move move, const size_t idx) const
Definition Callbacks.hpp:87
void search_complete(const Result &result) const
Definition Callbacks.hpp:69
static auto make_pretty_printer(std::function< std::string(Move)> &&printMove) -> Callbacks
void search_start(const Options &options) const
Definition Callbacks.hpp:62
std::function< void(const Options &)> onSearchStart
Definition Callbacks.hpp:45
std::function< void(Move, size_t)> onRootMove
Definition Callbacks.hpp:59
void iteration_complete(const Result &result) const
Definition Callbacks.hpp:78