BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
DefaultWeights.hpp
Go to the documentation of this file.
1/*
2 * ======================================================================================
3 *
4 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7 * ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11 *
12 * ======================================================================================
13 */
14
15// This file is generated by ben_bot::eval::Weights::to_cpp(). The unit tests check that
16// to_cpp() reproduces it exactly, so change the weights & regenerate it instead of
17// editing it by hand.
18
23
24#pragma once
25
26#include <array>
29
30namespace ben_bot::eval {
31
32namespace detail {
33 [[nodiscard]] consteval auto S(const int mg, const int eg) noexcept -> TaperedScore
34 {
35 return { .mg = mg, .eg = eg };
36 }
37} // namespace detail
38
39// clang-format off
40
46// std::to_array() only converts to Weights::values if there are exactly NUM_WEIGHTS values here
47inline constexpr Weights DEFAULT_WEIGHTS = [] {
48 using detail::S;
49
50 return Weights { .values = std::to_array<TaperedScore>({
51 // Material
52 S(133, 142), S(552, 312), S(660, 387), S(779, 725), S(1694, 1268),
53 // Pst (pawn)
54 S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0),
55 S(-37, 9), S(-23, -9), S(-23, -5), S(-1, -23), S(-7, 1), S(46, -22), S(39, -31), S(-12, -30),
56 S(-42, 1), S(-46, -5), S(-23, -22), S(-16, -25), S(-16, -17), S(3, -26), S(5, -30), S(-17, -27),
57 S(-39, 16), S(-47, 7), S(-9, -25), S(12, -40), S(5, -30), S(12, -34), S(-27, -14), S(-33, -16),
58 S(-29, 35), S(-24, 13), S(-12, -8), S(17, -40), S(-3, -22), S(12, -18), S(-21, 5), S(-31, 3),
59 S(-2, 57), S(-4, 45), S(27, 0), S(30, -54), S(87, -67), S(96, -31), S(15, 15), S(-23, 35),
60 S(79, 91), S(91, 82), S(66, 26), S(129, -24), S(50, 12), S(-26, 26), S(-78, 80), S(-149, 138),
61 S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0), S(0, 0),
62 // Pst (knight)
63 S(-111, 10), S(6, -14), S(-7, -11), S(-10, 17), S(48, -8), S(5, -1), S(24, -18), S(-6, -46),
64 S(-8, -18), S(-21, -10), S(2, 3), S(22, 2), S(39, 3), S(25, -17), S(2, -1), S(-4, -22),
65 S(-18, 5), S(6, 4), S(9, 3), S(27, 30), S(25, 30), S(40, -5), S(33, -14), S(-7, 2),
66 S(20, 2), S(34, -6), S(37, 32), S(37, 47), S(41, 45), S(51, 34), S(51, 20), S(20, 4),
67 S(9, 2), S(38, 12), S(17, 45), S(57, 47), S(39, 55), S(81, 30), S(37, 18), S(43, -2),
68 S(-89, -2), S(50, -17), S(3, 30), S(30, 29), S(78, 13), S(131, -9), S(65, -20), S(68, -45),
69 S(-124, 3), S(-97, 26), S(-2, -7), S(4, 15), S(-42, 20), S(24, -19), S(13, -16), S(-60, -39),
70 S(-259, -31), S(-79, -44), S(-102, 21), S(-75, -19), S(71, -30), S(-163, -5), S(-46, -47), S(-134, -112),
71 // Pst (bishop)
72 S(-35, -8), S(30, 1), S(-1, 6), S(-2, 8), S(3, 6), S(4, 6), S(-51, 10), S(-23, -3),
73 S(14, -8), S(27, -21), S(22, -5), S(15, 2), S(27, 6), S(25, -6), S(52, -20), S(8, -20),
74 S(-3, -2), S(19, -1), S(24, 8), S(21, 13), S(17, 22), S(49, -10), S(17, 1), S(9, 0),
75 S(1, -4), S(28, 1), S(28, 13), S(37, 23), S(66, 0), S(23, 9), S(25, -4), S(31, 1),
76 S(-5, 0), S(43, -2), S(2, 18), S(53, 9), S(42, 17), S(63, 4), S(36, -2), S(12, 9),
77 S(-5, -1), S(24, -12), S(2, 1), S(14, -1), S(16, -2), S(77, -3), S(44, -3), S(26, 2),
78 S(-74, 8), S(-42, -4), S(-59, 15), S(-98, 14), S(18, -4), S(-17, 0), S(-58, 9), S(-113, -1),
79 S(-22, -30), S(-23, -32), S(-187, 3), S(-119, 9), S(-82, 10), S(-68, 2), S(-37, -9), S(30, -49),
80 // Pst (rook)
81 S(-11, -5), S(-1, -6), S(6, -3), S(23, -20), S(27, -24), S(37, -17), S(-19, 1), S(-7, -28),
82 S(-49, 0), S(-14, -9), S(-31, 2), S(-8, -4), S(7, -20), S(25, -18), S(14, -20), S(-75, 9),
83 S(-48, 0), S(-27, 5), S(-19, -5), S(-18, -8), S(-4, -15), S(18, -15), S(5, -3), S(-27, -15),
84 S(-54, 11), S(-27, 10), S(-15, 7), S(3, -8), S(24, -12), S(19, -10), S(62, -20), S(-26, -3),
85 S(-40, 6), S(-19, -2), S(1, 10), S(13, -8), S(19, -2), S(68, -11), S(9, -7), S(-22, 4),
86 S(-20, 10), S(-7, 16), S(-3, 11), S(1, 0), S(-4, -3), S(56, -6), S(89, -9), S(11, -4),
87 S(-17, 19), S(-12, 20), S(42, 6), S(38, 1), S(76, -23), S(66, 0), S(-57, 38), S(20, 11),
88 S(-20, 22), S(6, 14), S(-51, 35), S(41, 0), S(7, 14), S(-60, 40), S(3, 21), S(-22, 23),
89 // Pst (queen)
90 S(76, -31), S(91, -60), S(98, -48), S(117, -55), S(100, -39), S(79, -38), S(62, -21), S(0, -15),
91 S(19, -3), S(52, -52), S(70, -54), S(76, -59), S(90, -57), S(97, -70), S(57, -71), S(67, -46),
92 S(15, 22), S(27, -49), S(11, -17), S(25, -42), S(20, -23), S(29, -10), S(32, 17), S(25, 35),
93 S(6, 22), S(-32, 36), S(-11, -9), S(-29, 12), S(-5, -22), S(-5, 0), S(0, 32), S(-13, 43),
94 S(-28, 50), S(-34, 22), S(-57, 6), S(-88, 21), S(-57, 26), S(-12, -11), S(-28, 57), S(-28, 35),
95 S(11, -8), S(-27, 2), S(-66, 2), S(-94, 57), S(-66, 28), S(21, -7), S(3, 0), S(3, 10),
96 S(-44, 18), S(-117, 54), S(-87, 52), S(-71, 30), S(-204, 103), S(-16, -18), S(-110, 50), S(-1, 15),
97 S(-38, 18), S(-20, 36), S(-34, 41), S(-59, 18), S(46, -42), S(31, -22), S(20, -15), S(6, 47),
98 // Pst (king)
99 S(-14, -88), S(71, -68), S(38, -41), S(-22, -55), S(14, -62), S(-33, -11), S(60, -51), S(37, -85),
100 S(36, -47), S(29, -17), S(-29, 22), S(0, -18), S(33, -21), S(-19, 19), S(38, -9), S(36, -29),
101 S(-5, -23), S(-1, -3), S(-43, 31), S(-14, 1), S(-4, 3), S(-51, 38), S(2, 14), S(-40, -1),
102 S(-98, -12), S(45, -5), S(-74, 51), S(-88, 22), S(-98, 26), S(-108, 60), S(-85, 33), S(-132, 17),
103 S(9, -16), S(1, 33), S(22, 43), S(-22, 15), S(24, 4), S(-39, 63), S(-5, 44), S(-116, 29),
104 S(55, 9), S(52, 28), S(86, 27), S(63, -12), S(74, -13), S(123, 51), S(107, 56), S(-24, 28),
105 S(112, -43), S(57, 19), S(13, 31), S(71, -12), S(19, -4), S(-20, 64), S(-25, 37), S(-74, 20),
106 S(-69, -86), S(54, -58), S(60, -9), S(23, -51), S(-61, -25), S(-63, 49), S(25, -8), S(-12, -3),
107 // PassedPawn
108 S(-25, 246), S(-22, 171), S(4, 55), S(-18, 14), S(2, -24), S(16, -35),
109 // PasserProtectedByPasser
110 S(23, 13),
111 // PasserProtectedByPawn
112 S(26, -6),
113 // IsolatedPawn
114 S(-6, -12),
115 // DoubledPawn
116 S(-4, -21),
117 // BackwardPawn
118 S(-18, 0),
119 // PawnChain
120 S(12, 5),
121 // RookBehindPasser
122 S(33, 20),
123 // KingEscortsPasser
124 S(-7, 10),
125 // EnemyKingBlocksPasser
126 S(91, -110),
127 // RookHalfOpenFile
128 S(19, 23),
129 // RookOpenFile
130 S(71, 2),
131 // ConnectedRooksOpenFile
132 S(38, 11),
133 // KingHalfOpenFile
134 S(-36, 38),
135 // KingOpenLine
136 S(-7, 7),
137 // KingStranded
138 S(-77, 52),
139 // KnightTropism
140 S(-13, -10),
141 // QueenTropism
142 S(-32, -14),
143 // KnightMobility
144 S(-63, -82), S(-36, -21), S(-20, 0), S(-14, 14), S(3, 18), S(11, 28), S(22, 24), S(29, 22),
145 S(67, -2),
146 // BishopMobility
147 S(-63, -82), S(-45, -51), S(-31, -26), S(-21, -9), S(-13, 1), S(-6, 9), S(-2, 18), S(-2, 21),
148 S(0, 26), S(7, 22), S(35, 10), S(63, 10), S(-4, 43), S(82, 9),
149 // RookMobility
150 S(-56, -90), S(-41, -49), S(-38, -20), S(-28, -14), S(-25, -5), S(-17, 5), S(-12, 15), S(-3, 11),
151 S(11, 12), S(13, 16), S(24, 18), S(39, 21), S(41, 26), S(36, 31), S(55, 23),
152 // QueenMobility
153 S(-37, -56), S(-48, -60), S(-43, -126), S(-45, -133), S(-36, -138), S(-30, -117), S(-34, -83), S(-33, -54),
154 S(-29, -50), S(-27, -22), S(-26, -10), S(-20, 0), S(-25, 19), S(-14, 19), S(-11, 32), S(-12, 46),
155 S(-13, 56), S(16, 37), S(17, 53), S(68, 29), S(48, 57), S(59, 62), S(44, 61), S(97, 57),
156 S(16, 78), S(44, 70), S(41, 101), S(33, 73),
157 // KingAreaControl
158 S(10, -5),
159 // CenterControl
160 S(2, 6),
161 // Space
162 S(1, 1),
163 // PawnThreat
164 S(91, 1),
165 // MinorOnRook
166 S(50, -17),
167 // MinorOnQueen
168 S(38, -34),
169 // RookOnQueen
170 S(87, -44),
171 // Hanging
172 S(-4, 13),
173 // PushThreat
174 S(37, 9),
175 // LastPiece
176 S(500, 500),
177 // MopUpEdge
178 S(0, 10),
179 // MopUpKingDistance
180 S(0, 4),
181 }) };
182}();
183
184// these fail if the term registry changes, until this file is regenerated
185static_assert(offset_of(Term::Material) == 0uz);
186static_assert(offset_of(Term::Pst) == 5uz);
187static_assert(offset_of(Term::PassedPawn) == 389uz);
188static_assert(offset_of(Term::PasserProtectedByPasser) == 395uz);
189static_assert(offset_of(Term::PasserProtectedByPawn) == 396uz);
190static_assert(offset_of(Term::IsolatedPawn) == 397uz);
191static_assert(offset_of(Term::DoubledPawn) == 398uz);
192static_assert(offset_of(Term::BackwardPawn) == 399uz);
193static_assert(offset_of(Term::PawnChain) == 400uz);
194static_assert(offset_of(Term::RookBehindPasser) == 401uz);
195static_assert(offset_of(Term::KingEscortsPasser) == 402uz);
196static_assert(offset_of(Term::EnemyKingBlocksPasser) == 403uz);
197static_assert(offset_of(Term::RookHalfOpenFile) == 404uz);
198static_assert(offset_of(Term::RookOpenFile) == 405uz);
199static_assert(offset_of(Term::ConnectedRooksOpenFile) == 406uz);
200static_assert(offset_of(Term::KingHalfOpenFile) == 407uz);
201static_assert(offset_of(Term::KingOpenLine) == 408uz);
202static_assert(offset_of(Term::KingStranded) == 409uz);
203static_assert(offset_of(Term::KnightTropism) == 410uz);
204static_assert(offset_of(Term::QueenTropism) == 411uz);
205static_assert(offset_of(Term::KnightMobility) == 412uz);
206static_assert(offset_of(Term::BishopMobility) == 421uz);
207static_assert(offset_of(Term::RookMobility) == 435uz);
208static_assert(offset_of(Term::QueenMobility) == 450uz);
209static_assert(offset_of(Term::KingAreaControl) == 478uz);
210static_assert(offset_of(Term::CenterControl) == 479uz);
211static_assert(offset_of(Term::Space) == 480uz);
212static_assert(offset_of(Term::PawnThreat) == 481uz);
213static_assert(offset_of(Term::MinorOnRook) == 482uz);
214static_assert(offset_of(Term::MinorOnQueen) == 483uz);
215static_assert(offset_of(Term::RookOnQueen) == 484uz);
216static_assert(offset_of(Term::Hanging) == 485uz);
217static_assert(offset_of(Term::PushThreat) == 486uz);
218static_assert(offset_of(Term::LastPiece) == 487uz);
219static_assert(offset_of(Term::MopUpEdge) == 488uz);
220static_assert(offset_of(Term::MopUpKingDistance) == 489uz);
221static_assert(NUM_WEIGHTS == 490uz);
222
223// clang-format on
224
225} // namespace ben_bot::eval
constexpr auto NUM_WEIGHTS
Definition Weights.hpp:185
constexpr Weights DEFAULT_WEIGHTS
constexpr auto offset_of(const Term term) noexcept -> size_t
Definition Weights.hpp:190
@ BackwardPawn
Bonus (penalty) for each backward pawn.
Definition Weights.hpp:52
@ KnightTropism
Bonus (penalty) per square that an enemy knight is closer than 6 to the king.
Definition Weights.hpp:63
@ KingStranded
Bonus (penalty) for the king on the d/e file with no castling rights.
Definition Weights.hpp:62
@ KingEscortsPasser
Bonus per square that our king is closer than 7 to our passer.
Definition Weights.hpp:55
@ MopUpEdge
Mop-up bonus per square that the enemy king is from the center.
Definition Weights.hpp:79
@ RookHalfOpenFile
Bonus for each rook on a file with an enemy pawn but none of ours.
Definition Weights.hpp:57
@ RookOnQueen
Bonus for each enemy queen attacked by one of our rooks.
Definition Weights.hpp:75
@ Pst
Piece square tables: [piece type][square], from White's point of view.
Definition Weights.hpp:46
@ MinorOnQueen
Bonus for each enemy queen attacked by one of our knights or bishops.
Definition Weights.hpp:74
@ IsolatedPawn
Bonus (penalty) for each isolated pawn.
Definition Weights.hpp:50
@ MinorOnRook
Bonus for each enemy rook attacked by one of our knights or bishops.
Definition Weights.hpp:73
@ PawnThreat
Bonus for each enemy piece attacked by one of our pawns.
Definition Weights.hpp:72
@ KingOpenLine
Bonus (penalty) for the king on an open file or a pawnless diagonal.
Definition Weights.hpp:61
@ BishopMobility
Bishop mobility, indexed by the number of safe squares.
Definition Weights.hpp:66
@ QueenMobility
Queen mobility, indexed by the number of safe squares.
Definition Weights.hpp:68
@ PassedPawn
Passed pawn bonus, indexed by squares from promoting minus 1.
Definition Weights.hpp:47
@ DoubledPawn
Bonus (penalty) for each file with more than one of our pawns.
Definition Weights.hpp:51
@ PawnChain
Bonus for each pawn defended by a friendly pawn (counted per defender).
Definition Weights.hpp:53
@ RookMobility
Rook mobility, indexed by the number of safe squares.
Definition Weights.hpp:67
@ QueenTropism
Bonus (penalty) per square that an enemy queen is closer than 7 to the king.
Definition Weights.hpp:64
@ PasserProtectedByPasser
Bonus for each passed pawn defending a passed pawn.
Definition Weights.hpp:48
@ PushThreat
Bonus for each enemy piece that one of our pawns could attack with a safe push.
Definition Weights.hpp:77
@ PasserProtectedByPawn
Bonus for each non-passed pawn defending a passed pawn.
Definition Weights.hpp:49
@ KingHalfOpenFile
Bonus (penalty) for the king on a file with an enemy pawn but none of ours.
Definition Weights.hpp:60
@ Hanging
Bonus for each hanging enemy piece or pawn.
Definition Weights.hpp:76
@ EnemyKingBlocksPasser
Bonus (penalty) for the enemy king on our passer's promotion square.
Definition Weights.hpp:56
@ KnightMobility
Knight mobility, indexed by the number of safe squares.
Definition Weights.hpp:65
@ CenterControl
Bonus per center square controlled.
Definition Weights.hpp:70
@ KingAreaControl
Bonus per square around each king that we control more of than they do.
Definition Weights.hpp:69
@ RookOpenFile
Bonus for each rook on an open file.
Definition Weights.hpp:58
@ Space
Bonus per square behind our pawns that we control more of than they do.
Definition Weights.hpp:71
@ MopUpKingDistance
Mop-up bonus per square that the kings are closer than 14.
Definition Weights.hpp:80
@ Material
Pawn, knight, bishop, rook & queen values.
Definition Weights.hpp:45
@ ConnectedRooksOpenFile
Bonus for each open file with two of our rooks on it.
Definition Weights.hpp:59
@ LastPiece
Bonus for having a non-pawn piece left when the opponent has none.
Definition Weights.hpp:78
@ RookBehindPasser
Bonus for our rook behind our passer (penalty for their rook behind it).
Definition Weights.hpp:54
consteval auto S(const int mg, const int eg) noexcept -> TaperedScore