BenBot
1.7.5
A chess engine
Loading...
Searching...
No Matches
KillerMoves.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 <algorithm>
23
#include <array>
24
#include <cassert>
25
#include <cstddef>
// IWYU pragma: keep - for size_t
26
#include <
libbenbot/search/Constants.hpp
>
27
#include <
libchess/moves/Move.hpp
>
28
#include <
libchess/moves/MoveGen.hpp
>
29
#include <span>
30
#include <vector>
31
32
namespace
ben_bot
{
33
34
using
chess::moves::Move;
35
using
std::size_t;
36
44
struct
KillerMoves
final {
46
static
constexpr
auto
MAX_KILLERS
{ 2uz };
47
49
void
clear
()
50
{
51
for
(
auto
& list : lists)
52
list.clear();
53
}
54
58
void
store
(
const
size_t
plyFromRoot,
const
Move
move)
59
{
60
assert(plyFromRoot <
search::MAX_PLY
);
61
62
auto
& list = lists.at(plyFromRoot);
63
64
if
(std::ranges::contains(list, move))
65
return
;
66
67
list.insert(list.begin(), move);
68
69
if
(list.size() >
MAX_KILLERS
)
70
list.pop_back();
71
}
72
74
[[nodiscard]]
auto
get
(
const
size_t
plyFromRoot)
const
noexcept
-> std::span<const Move>
75
{
76
return
lists.at(plyFromRoot);
77
}
78
79
private
:
80
using
Killers = std::vector<Move>;
81
82
std::array<Killers, search::MAX_PLY + 1uz> lists { };
83
};
84
85
}
// namespace ben_bot
Constants.hpp
MoveGen.hpp
Move.hpp
ben_bot::search::MAX_PLY
constexpr auto MAX_PLY
Definition
Constants.hpp:27
ben_bot
ben_bot::KillerMoves
Definition
KillerMoves.hpp:44
ben_bot::KillerMoves::clear
void clear()
Definition
KillerMoves.hpp:49
ben_bot::KillerMoves::store
void store(const size_t plyFromRoot, const Move move)
Definition
KillerMoves.hpp:58
ben_bot::KillerMoves::get
auto get(const size_t plyFromRoot) const noexcept -> std::span< const Move >
Definition
KillerMoves.hpp:74
ben_bot::KillerMoves::MAX_KILLERS
static constexpr auto MAX_KILLERS
Definition
KillerMoves.hpp:46
chess::moves::Move
Definition
Move.hpp:75
libbenbot
include
libbenbot
data-structures
KillerMoves.hpp
Generated on
for BenBot by
1.16.1