From 21cee897e9dee76233f6d14e727745aaace6d2cf Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Thu, 19 Feb 2026 02:10:58 +0100 Subject: [PATCH 1/5] tentative --- src/eval_constants.hpp | 14 +++++++++----- src/evaltune_main.cpp | 8 ++++++++ src/evaluation.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/position.hpp | 9 +++++++++ 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/eval_constants.hpp b/src/eval_constants.hpp index a48a47a3..5291ae93 100644 --- a/src/eval_constants.hpp +++ b/src/eval_constants.hpp @@ -75,11 +75,15 @@ inline const std::array PT_OUTER_RING_ATTACKS = { S(3, -23), S(5, -35), S(5, -21), S(5, -5), S(5, 20), }; -inline const PParam KS_NO_QUEEN = S(-70, -732); -inline const PParam PAWN_THREAT_KNIGHT = S(213, 92); -inline const PParam PAWN_THREAT_BISHOP = S(193, 136); -inline const PParam PAWN_THREAT_ROOK = S(189, 129); -inline const PParam PAWN_THREAT_QUEEN = S(171, -23); +inline const PParam KS_FLANK_ATTACK = S(211, 92); +inline const PParam KS_FLANK_DEFENSE = S(189, 141); +inline const PParam KS_FLANK_DOUBLE_ATTACK = S(190, 126); +inline const PParam KS_FLANK_DOUBLE_DEFENSE = S(166, -14); + +inline const PParam PAWN_THREAT_KNIGHT = S(211, 92); +inline const PParam PAWN_THREAT_BISHOP = S(189, 141); +inline const PParam PAWN_THREAT_ROOK = S(190, 126); +inline const PParam PAWN_THREAT_QUEEN = S(166, -14); inline const PParam KNIGHT_THREAT_BISHOP = S(107, 102); inline const PParam KNIGHT_THREAT_ROOK = S(227, 69); diff --git a/src/evaltune_main.cpp b/src/evaltune_main.cpp index 68a53ae3..cc6fce9e 100644 --- a/src/evaltune_main.cpp +++ b/src/evaltune_main.cpp @@ -333,6 +333,14 @@ int main() { std::cout << std::endl; std::cout << "inline const PParam KS_NO_QUEEN = " << KS_NO_QUEEN << ";" << std::endl; + std::cout << "inline const PParam KS_FLANK_ATTACK = " << KS_FLANK_ATTACK << ";" + << std::endl; + std::cout << "inline const PParam KS_FLANK_DEFENSE = " << KS_FLANK_DEFENSE << ";" + << std::endl; + std::cout << "inline const PParam KS_DLANK_DOUBLE_ATTACK = " << KS_FLANK_DOUBLE_ATTACK << ";" + << std::endl; + std::cout << "inline const PParam KS_FLANK_DOUBLE_DEFENSE = " << KS_FLANK_DOUBLE_DEFENSE << ";" + << std::endl; std::cout << "inline const PParam PAWN_THREAT_KNIGHT = " << PAWN_THREAT_KNIGHT << ";" << std::endl; diff --git a/src/evaluation.cpp b/src/evaluation.cpp index b87ad8c6..d98b04b4 100644 --- a/src/evaluation.cpp +++ b/src/evaluation.cpp @@ -70,6 +70,31 @@ std::array king_ring_table = []() { return king_ring_table; }(); +std::array, 2> king_flank = []() { + std::array, 2> king_flank{}; + + Bitboard flank = Bitboard::file_mask(0) + & (Bitboard::rank_mask(0) | Bitboard::rank_mask(1) | Bitboard::rank_mask(2) + | Bitboard::rank_mask(3) | Bitboard::rank_mask(4)); + + king_flank[0][0] = king_flank[0][1] = king_flank[0][2] = flank; + + flank = flank.shift(Direction::East).shift(Direction::East); + king_flank[0][3] = king_flank[0][4] = flank; + + flank = flank.shift(Direction::East).shift(Direction::East); + king_flank[0][5] = king_flank[0][6] = king_flank[0][7] = flank; + + Bitboard mirror_mask = Bitboard::rank_mask(7) | Bitboard::rank_mask(6) | Bitboard::rank_mask(5); + + for (i32 file_idx = 0; file_idx < 8; file_idx++) { + king_flank[1][file_idx] = king_flank[0][file_idx] ^ mirror_mask; + } + + return king_flank; +}(); + + std::array extended_ring_table = []() { std::array extended_ring_table{}; for (u8 sq_idx = 0; sq_idx < 64; sq_idx++) { @@ -342,6 +367,9 @@ PScore evaluate_king_safety(const Position& pos) { Bitboard king_ring = king_ring_table[pos.king_sq(color).raw]; Bitboard extended_ring = extended_ring_table[pos.king_sq(color).raw]; + Bitboard flank = king_flank[static_cast(color)][static_cast(pos.king_sq(color).file())]; + + // Piece attacks in inner/outer ring for (PieceType pt : {PieceType::Pawn, PieceType::Knight, PieceType::Bishop, PieceType::Rook, PieceType::Queen}) { Bitboard attacked = pos.attacked_by(opp, pt); @@ -353,6 +381,19 @@ PScore evaluate_king_safety(const Position& pos) { * outer.ipopcount(); } + // Flank attack / defense status + Bitboard defended_by_us = pos.attack_table(color).get_attacked_bitboard(); + Bitboard double_defended_by_us = pos.attacked_by_two_or_more(color); + + Bitboard attacked_by_them = pos.attack_table(opp).get_attacked_bitboard(); + Bitboard double_attacked_by_them = pos.attacked_by_two_or_more(opp); + + eval += KS_FLANK_DEFENSE * (defended_by_us & flank).ipopcount(); + eval += KS_FLANK_ATTACK * (attacked_by_them & flank).ipopcount(); + eval += KS_FLANK_DOUBLE_DEFENSE * (double_defended_by_us & flank).ipopcount(); + eval += KS_FLANK_DOUBLE_ATTACK * (double_attacked_by_them & flank).ipopcount(); + + // King shelter evaluation eval += king_shelter(pos); eval += KS_NO_QUEEN * (pos.bitboard_for(opp, PieceType::Queen).empty()); diff --git a/src/position.hpp b/src/position.hpp index 249014ed..a83b3f16 100644 --- a/src/position.hpp +++ b/src/position.hpp @@ -202,6 +202,15 @@ struct Position { return attack_table(color).get_piece_mask_bitboard(piece_list(color).mask_eq(ptype)); } + [[nodiscard]] Bitboard attacked_by_two_or_more(Color color) const { + const auto& wb = attack_table(color).raw; + + u16x64 minus_one = wb - u16x64::splat(1u); + u16x64 at_least_two = wb & minus_one; + + return Bitboard{at_least_two.nonzeros().to_bits()}; + } + [[nodiscard]] usize mobility_of(Color color, PieceId id) const { return attack_table(color).count_matching_mask(id.to_piece_mask()); } From e14aa69a603f82556e705c9d65c9b4187239a791 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Tue, 7 Apr 2026 16:07:27 +0200 Subject: [PATCH 2/5] Format, debug, de-bug --- src/evaltune_main.cpp | 8 ++++---- src/evaluation.cpp | 30 +++--------------------------- src/evaluation.hpp | 27 +++++++++++++++++++++++++++ src/uci.cpp | 8 ++++++++ src/uci.hpp | 1 + 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/evaltune_main.cpp b/src/evaltune_main.cpp index cc6fce9e..b5c7f84e 100644 --- a/src/evaltune_main.cpp +++ b/src/evaltune_main.cpp @@ -337,10 +337,10 @@ int main() { << std::endl; std::cout << "inline const PParam KS_FLANK_DEFENSE = " << KS_FLANK_DEFENSE << ";" << std::endl; - std::cout << "inline const PParam KS_DLANK_DOUBLE_ATTACK = " << KS_FLANK_DOUBLE_ATTACK << ";" - << std::endl; - std::cout << "inline const PParam KS_FLANK_DOUBLE_DEFENSE = " << KS_FLANK_DOUBLE_DEFENSE << ";" - << std::endl; + std::cout << "inline const PParam KS_DLANK_DOUBLE_ATTACK = " << KS_FLANK_DOUBLE_ATTACK + << ";" << std::endl; + std::cout << "inline const PParam KS_FLANK_DOUBLE_DEFENSE = " << KS_FLANK_DOUBLE_DEFENSE + << ";" << std::endl; std::cout << "inline const PParam PAWN_THREAT_KNIGHT = " << PAWN_THREAT_KNIGHT << ";" << std::endl; diff --git a/src/evaluation.cpp b/src/evaluation.cpp index d98b04b4..118f4184 100644 --- a/src/evaluation.cpp +++ b/src/evaluation.cpp @@ -70,31 +70,6 @@ std::array king_ring_table = []() { return king_ring_table; }(); -std::array, 2> king_flank = []() { - std::array, 2> king_flank{}; - - Bitboard flank = Bitboard::file_mask(0) - & (Bitboard::rank_mask(0) | Bitboard::rank_mask(1) | Bitboard::rank_mask(2) - | Bitboard::rank_mask(3) | Bitboard::rank_mask(4)); - - king_flank[0][0] = king_flank[0][1] = king_flank[0][2] = flank; - - flank = flank.shift(Direction::East).shift(Direction::East); - king_flank[0][3] = king_flank[0][4] = flank; - - flank = flank.shift(Direction::East).shift(Direction::East); - king_flank[0][5] = king_flank[0][6] = king_flank[0][7] = flank; - - Bitboard mirror_mask = Bitboard::rank_mask(7) | Bitboard::rank_mask(6) | Bitboard::rank_mask(5); - - for (i32 file_idx = 0; file_idx < 8; file_idx++) { - king_flank[1][file_idx] = king_flank[0][file_idx] ^ mirror_mask; - } - - return king_flank; -}(); - - std::array extended_ring_table = []() { std::array extended_ring_table{}; for (u8 sq_idx = 0; sq_idx < 64; sq_idx++) { @@ -367,7 +342,8 @@ PScore evaluate_king_safety(const Position& pos) { Bitboard king_ring = king_ring_table[pos.king_sq(color).raw]; Bitboard extended_ring = extended_ring_table[pos.king_sq(color).raw]; - Bitboard flank = king_flank[static_cast(color)][static_cast(pos.king_sq(color).file())]; + Bitboard flank = + king_flank[static_cast(color)][static_cast(pos.king_sq(color).file())]; // Piece attacks in inner/outer ring for (PieceType pt : {PieceType::Pawn, PieceType::Knight, PieceType::Bishop, PieceType::Rook, @@ -382,7 +358,7 @@ PScore evaluate_king_safety(const Position& pos) { } // Flank attack / defense status - Bitboard defended_by_us = pos.attack_table(color).get_attacked_bitboard(); + Bitboard defended_by_us = pos.attack_table(color).get_attacked_bitboard(); Bitboard double_defended_by_us = pos.attacked_by_two_or_more(color); Bitboard attacked_by_them = pos.attack_table(opp).get_attacked_bitboard(); diff --git a/src/evaluation.hpp b/src/evaluation.hpp index 8f528b13..b844ad6d 100644 --- a/src/evaluation.hpp +++ b/src/evaluation.hpp @@ -18,4 +18,31 @@ inline Score evaluate_stm_pov(const Position& pos) { return evaluate_stm_pov(pos, PsqtState{pos}); } +static constexpr std::array, 2> king_flank = []() { + std::array, 2> result{}; + + // Queenside files (0-2), Center files (3-4), Kingside files (5-7) + constexpr std::array flank_start = {0, 0, 0, 2, 2, 4, 4, 4}; + constexpr std::array flank_width = {4, 4, 4, 4, 4, 4, 4, 4}; + constexpr Bitboard white_ranks = Bitboard::rank_mask(0) | Bitboard::rank_mask(1) + | Bitboard::rank_mask(2) | Bitboard::rank_mask(3) + | Bitboard::rank_mask(4); + constexpr Bitboard black_ranks = Bitboard::rank_mask(3) | Bitboard::rank_mask(4) + | Bitboard::rank_mask(5) | Bitboard::rank_mask(6) + | Bitboard::rank_mask(7); + + for (i8 file_idx = 0; file_idx < 8; file_idx++) { + Bitboard flank{}; + for (i8 f = flank_start[file_idx]; f < flank_start[file_idx] + flank_width[file_idx]; f++) { + flank |= Bitboard::file_mask(f); + } + + result[0][file_idx] = flank & white_ranks; + result[1][file_idx] = flank & black_ranks; + } + + return result; +}(); + + }; // namespace Clockwork diff --git a/src/uci.cpp b/src/uci.cpp index 15393f1b..25b163a4 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -96,6 +96,8 @@ void UCIHandler::execute_command(const std::string& line) { handle_bench(is); } else if (command == "speedtest") { handle_speedtest(is); + } else if (command == "debug") { + handle_debug(is); } #ifndef EVAL_TUNING else if (command == "eval") { @@ -119,6 +121,12 @@ void UCIHandler::handle_bench(std::istringstream& is) { Bench::benchmark(searcher, depth); } +// Note: This function is left here so that one doesn't need to reimplement it every time we need to expose a function through uci. +// The professional thing to do is to empty the body of the function / put a placeholder in here when finished (and before pr). +void UCIHandler::handle_debug(std::istringstream& is) { + std::cout << "readyok" << std::endl; +} + void UCIHandler::handle_go(std::istringstream& is) { // Clear any previous settings settings = {}; diff --git a/src/uci.hpp b/src/uci.hpp index 9e72a9f1..9c9a9bcb 100644 --- a/src/uci.hpp +++ b/src/uci.hpp @@ -40,6 +40,7 @@ class UCIHandler { void handle_speedtest(std::istringstream&); void handle_genfens(std::istringstream&); + void handle_debug(std::istringstream&); }; } // namespace Clockwork::UCI From d11fec3d3fcb1d4ac95b2b1feb7aaffce8fd88f9 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Tue, 7 Apr 2026 19:02:48 +0200 Subject: [PATCH 3/5] kekks --- src/eval_constants.hpp | 1 + src/evaltune_main.cpp | 1 + src/evaluation.hpp | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/eval_constants.hpp b/src/eval_constants.hpp index 5291ae93..b4e661ff 100644 --- a/src/eval_constants.hpp +++ b/src/eval_constants.hpp @@ -74,6 +74,7 @@ inline const std::array PT_INNER_RING_ATTACKS = { inline const std::array PT_OUTER_RING_ATTACKS = { S(3, -23), S(5, -35), S(5, -21), S(5, -5), S(5, 20), }; +inline const PParam KS_NO_QUEEN = S(211, 92); inline const PParam KS_FLANK_ATTACK = S(211, 92); inline const PParam KS_FLANK_DEFENSE = S(189, 141); diff --git a/src/evaltune_main.cpp b/src/evaltune_main.cpp index b5c7f84e..4c6fadfc 100644 --- a/src/evaltune_main.cpp +++ b/src/evaltune_main.cpp @@ -333,6 +333,7 @@ int main() { std::cout << std::endl; std::cout << "inline const PParam KS_NO_QUEEN = " << KS_NO_QUEEN << ";" << std::endl; + std::cout << "inline const PParam KS_FLANK_ATTACK = " << KS_FLANK_ATTACK << ";" << std::endl; std::cout << "inline const PParam KS_FLANK_DEFENSE = " << KS_FLANK_DEFENSE << ";" diff --git a/src/evaluation.hpp b/src/evaluation.hpp index b844ad6d..8204492f 100644 --- a/src/evaluation.hpp +++ b/src/evaluation.hpp @@ -22,8 +22,8 @@ static constexpr std::array, 2> king_flank = []() { std::array, 2> result{}; // Queenside files (0-2), Center files (3-4), Kingside files (5-7) - constexpr std::array flank_start = {0, 0, 0, 2, 2, 4, 4, 4}; - constexpr std::array flank_width = {4, 4, 4, 4, 4, 4, 4, 4}; + constexpr std::array flank_start = {0, 0, 0, 2, 2, 4, 4, 4}; + constexpr std::array flank_width = {4, 4, 4, 4, 4, 4, 4, 4}; constexpr Bitboard white_ranks = Bitboard::rank_mask(0) | Bitboard::rank_mask(1) | Bitboard::rank_mask(2) | Bitboard::rank_mask(3) | Bitboard::rank_mask(4); @@ -31,9 +31,10 @@ static constexpr std::array, 2> king_flank = []() { | Bitboard::rank_mask(5) | Bitboard::rank_mask(6) | Bitboard::rank_mask(7); - for (i8 file_idx = 0; file_idx < 8; file_idx++) { + for (usize file_idx = 0; file_idx < 8; file_idx++) { Bitboard flank{}; - for (i8 f = flank_start[file_idx]; f < flank_start[file_idx] + flank_width[file_idx]; f++) { + for (i32 f = flank_start[file_idx]; f < flank_start[file_idx] + flank_width[file_idx]; + f++) { flank |= Bitboard::file_mask(f); } From 1f79021e223f1884295d0c25cdcbc44e967827c7 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Tue, 7 Apr 2026 23:20:31 +0200 Subject: [PATCH 4/5] Bench: 18377860 --- src/eval_constants.hpp | 229 ++++++++++++++++++++--------------------- src/evaltune_main.cpp | 6 +- 2 files changed, 118 insertions(+), 117 deletions(-) diff --git a/src/eval_constants.hpp b/src/eval_constants.hpp index b4e661ff..d621223f 100644 --- a/src/eval_constants.hpp +++ b/src/eval_constants.hpp @@ -5,185 +5,184 @@ namespace Clockwork { // clang-format off -inline const PParam PAWN_MAT = S(134, 207); -inline const PParam KNIGHT_MAT = S(574, 615); -inline const PParam BISHOP_MAT = S(611, 631); -inline const PParam ROOK_MAT = S(482, 665); -inline const PParam QUEEN_MAT = S(1035, 464); -inline const PParam TEMPO_VAL = S(58, 20); - -inline const PParam BISHOP_PAIR_VAL = S(57, 192); -inline const PParam ROOK_OPEN_VAL = S(106, -12); -inline const PParam ROOK_SEMIOPEN_VAL = S(42, 24); -inline const PParam MINOR_BEHIND_PAWN = S(11, 38); - -inline const PParam DOUBLED_PAWN_VAL = S(-6, -74); -inline const PParam ISOLATED_PAWN_VAL = S(-19, -16); - -inline const PParam POTENTIAL_CHECKER_VAL = S(-49, -26); -inline const PParam OUTPOST_KNIGHT_VAL = S(45, 48); -inline const PParam OUTPOST_BISHOP_VAL = S(52, 39); - -inline const PParam PAWN_PUSH_THREAT_KNIGHT = S(42, 6); -inline const PParam PAWN_PUSH_THREAT_BISHOP = S(52, -21); -inline const PParam PAWN_PUSH_THREAT_ROOK = S(26, 55); -inline const PParam PAWN_PUSH_THREAT_QUEEN = S(70, -46); +inline const PParam PAWN_MAT = S(137, 200); +inline const PParam KNIGHT_MAT = S(584, 581); +inline const PParam BISHOP_MAT = S(613, 586); +inline const PParam ROOK_MAT = S(492, 629); +inline const PParam QUEEN_MAT = S(898, 1186); +inline const PParam TEMPO_VAL = S(59, 19); + +inline const PParam BISHOP_PAIR_VAL = S(50, 196); +inline const PParam ROOK_OPEN_VAL = S(107, -14); +inline const PParam ROOK_SEMIOPEN_VAL = S(39, 25); +inline const PParam MINOR_BEHIND_PAWN = S(11, 41); + +inline const PParam DOUBLED_PAWN_VAL = S(-14, -72); +inline const PParam ISOLATED_PAWN_VAL = S(-21, -18); + +inline const PParam POTENTIAL_CHECKER_VAL = S(-46, -28); +inline const PParam OUTPOST_KNIGHT_VAL = S(41, 56); +inline const PParam OUTPOST_BISHOP_VAL = S(57, 34); + +inline const PParam PAWN_PUSH_THREAT_KNIGHT = S(43, 5); +inline const PParam PAWN_PUSH_THREAT_BISHOP = S(49, -21); +inline const PParam PAWN_PUSH_THREAT_ROOK = S(30, 50); +inline const PParam PAWN_PUSH_THREAT_QUEEN = S(68, -45); inline const std::array PAWN_PHALANX = { - S(16, 2), S(39, 24), S(60, 48), S(136, 146), S(382, 213), S(609, 596), + S(15, -2), S(35, 27), S(61, 46), S(138, 138), S(373, 200), S(595, 613), }; inline const std::array DEFENDED_PAWN = { - S(55, 32), S(45, 27), S(55, 53), S(121, 138), S(432, 72), + S(51, 34), S(45, 25), S(62, 48), S(122, 134), S(428, 73), }; inline const std::array PASSED_PAWN = { - S(-80, -105), S(-76, -87), S(-47, 13), S(15, 105), S(105, 246), S(281, 358), + S(-69, -125), S(-71, -96), S(-49, 14), S(8, 113), S(102, 247), S(272, 364), }; inline const std::array DEFENDED_PASSED_PUSH = { - S(36, -41), S(38, -6), S(25, 30), S(4, 108), S(64, 202), S(224, 262), + S(30, -40), S(27, -3), S(17, 30), S(4, 106), S(70, 205), S(240, 253), }; inline const std::array BLOCKED_PASSED_PAWN = { - S(17, -23), S(2, 23), S(1, -9), S(1, -40), S(-5, -119), S(-227, -208), + S(16, -21), S(6, 17), S(3, -15), S(4, -43), S(6, -129), S(-234, -218), }; inline const std::array FRIENDLY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(1, 145), S(-19, 117), S(-11, 42), S(-3, 5), S(2, 6), S(38, 5), S(16, -7), + S(0, 0), S(-3, 139), S(-17, 110), S(-10, 41), S(-3, 8), S(4, 8), S(39, 6), S(30, -8), }; inline const std::array ENEMY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(-319, -33), S(-36, 28), S(-30, 73), S(18, 85), S(37, 102), S(54, 102), S(31, 99), + S(0, 0), S(-296, -71), S(-31, 13), S(-24, 61), S(14, 94), S(35, 115), S(48, 119), S(31, 111), }; inline const std::array KNIGHT_MOBILITY = { - S(77, 4), S(145, 176), S(179, 269), S(207, 304), S(246, 321), S(270, 353), S(302, 351), S(332, 364), S(376, 293), + S(82, -4), S(147, 164), S(179, 256), S(207, 290), S(246, 306), S(270, 336), S(301, 333), S(331, 341), S(386, 248), }; inline const std::array BISHOP_MOBILITY = { - S(96, 10), S(141, 177), S(193, 243), S(219, 290), S(244, 322), S(259, 347), S(267, 366), S(281, 376), S(288, 392), S(310, 377), S(321, 376), S(372, 325), S(379, 325), S(404, 292), + S(113, 2), S(152, 169), S(200, 233), S(223, 281), S(247, 311), S(261, 335), S(269, 352), S(283, 359), S(290, 372), S(315, 352), S(325, 349), S(381, 289), S(379, 298), S(429, 232), }; inline const std::array ROOK_MOBILITY = { - S(326, 254), S(235, 424), S(260, 451), S(277, 461), S(287, 474), S(293, 486), S(298, 497), S(307, 498), S(312, 509), S(323, 510), S(334, 511), S(341, 516), S(347, 513), S(364, 485), S(442, 390), + S(325, 255), S(243, 411), S(265, 439), S(282, 448), S(292, 462), S(296, 474), S(301, 485), S(308, 488), S(313, 498), S(322, 500), S(331, 501), S(336, 505), S(342, 502), S(360, 471), S(453, 362), }; inline const std::array QUEEN_MOBILITY = { - S(447, 126), S(594, 204), S(618, 323), S(637, 439), S(652, 485), S(661, 529), S(666, 562), S(673, 574), S(676, 598), S(679, 613), S(686, 618), S(689, 627), S(697, 623), S(699, 628), S(703, 624), S(702, 627), S(703, 625), S(710, 617), S(716, 610), S(721, 606), S(728, 585), S(748, 549), S(737, 557), S(741, 493), S(722, 493), S(721, 452), S(654, 499), S(678, 433), + S(479, 228), S(608, 348), S(632, 457), S(650, 575), S(664, 619), S(669, 668), S(674, 700), S(680, 713), S(682, 739), S(683, 758), S(688, 766), S(690, 777), S(695, 777), S(695, 788), S(696, 789), S(693, 794), S(691, 794), S(694, 791), S(699, 781), S(697, 782), S(694, 773), S(709, 739), S(694, 747), S(676, 705), S(658, 691), S(644, 669), S(582, 701), S(588, 656), }; inline const std::array KING_MOBILITY = { - S(461, -217), S(103, -118), S(22, -25), S(9, 6), S(-8, 3), S(-14, 1), S(-16, 5), S(-33, 17), S(-29, 2), + S(506, -231), S(94, -91), S(30, -22), S(13, 12), S(-4, 8), S(-17, 6), S(-24, 12), S(-49, 21), S(-38, -22), }; inline const std::array PT_INNER_RING_ATTACKS = { - S(10, -35), S(13, -24), S(12, -5), S(6, -11), S(2, -7), + S(12, -8), S(9, 8), S(9, 4), S(4, -1), S(4, -10), }; inline const std::array PT_OUTER_RING_ATTACKS = { - S(3, -23), S(5, -35), S(5, -21), S(5, -5), S(5, 20), + S(5, -6), S(4, 2), S(3, 0), S(3, -1), S(4, -3), }; -inline const PParam KS_NO_QUEEN = S(211, 92); -inline const PParam KS_FLANK_ATTACK = S(211, 92); -inline const PParam KS_FLANK_DEFENSE = S(189, 141); -inline const PParam KS_FLANK_DOUBLE_ATTACK = S(190, 126); -inline const PParam KS_FLANK_DOUBLE_DEFENSE = S(166, -14); +inline const PParam KS_NO_QUEEN = S(-89, -1455); +inline const PParam KS_FLANK_ATTACK = S(2, -2); +inline const PParam KS_FLANK_DEFENSE = S(-3, 0); +inline const PParam KS_FLANK_DOUBLE_ATTACK = S(4, -0); +inline const PParam KS_FLANK_DOUBLE_DEFENSE = S(-3, 3); +inline const PParam PAWN_THREAT_KNIGHT = S(216, 86); +inline const PParam PAWN_THREAT_BISHOP = S(200, 128); +inline const PParam PAWN_THREAT_ROOK = S(200, 121); +inline const PParam PAWN_THREAT_QUEEN = S(169, 5); -inline const PParam PAWN_THREAT_KNIGHT = S(211, 92); -inline const PParam PAWN_THREAT_BISHOP = S(189, 141); -inline const PParam PAWN_THREAT_ROOK = S(190, 126); -inline const PParam PAWN_THREAT_QUEEN = S(166, -14); +inline const PParam KNIGHT_THREAT_BISHOP = S(108, 101); +inline const PParam KNIGHT_THREAT_ROOK = S(230, 67); +inline const PParam KNIGHT_THREAT_QUEEN = S(159, -28); -inline const PParam KNIGHT_THREAT_BISHOP = S(107, 102); -inline const PParam KNIGHT_THREAT_ROOK = S(227, 69); -inline const PParam KNIGHT_THREAT_QUEEN = S(155, -15); - -inline const PParam BISHOP_THREAT_KNIGHT = S(106, 58); -inline const PParam BISHOP_THREAT_ROOK = S(212, 126); +inline const PParam BISHOP_THREAT_KNIGHT = S(106, 55); +inline const PParam BISHOP_THREAT_ROOK = S(214, 124); inline const PParam BISHOP_THREAT_QUEEN = S(178, 90); inline const std::array BISHOP_PAWNS = { - S(9, -31), S(-2, -6), S(-4, -15), S(-7, -24), S(-11, -32), S(-15, -38), S(-17, -48), S(-23, -48), S(-38, -43), + S(9, -31), S(-4, -3), S(-5, -11), S(-8, -20), S(-12, -28), S(-15, -34), S(-17, -45), S(-23, -45), S(-38, -41), }; -inline const PParam ROOK_LINEUP = S(12, 69); +inline const PParam ROOK_LINEUP = S(13, 70); inline const std::array PAWN_PSQT = { - S(326, 313), S(169, 400), S(302, 374), S(311, 287), S(330, 239), S(218, 331), S(148, 384), S(273, 314), // - S(119, 215), S(163, 234), S(189, 176), S(162, 136), S(146, 112), S(111, 171), S(88, 221), S(42, 244), // - S(91, 164), S(80, 177), S(114, 129), S(107, 112), S(97, 103), S(69, 131), S(22, 177), S(10, 200), // - S(64, 115), S(55, 146), S(80, 118), S(76, 112), S(53, 113), S(36, 134), S(-20, 171), S(-22, 162), // - S(60, 93), S(97, 97), S(78, 137), S(70, 133), S(43, 129), S(18, 137), S(-17, 155), S(-23, 146), // - S(74, 92), S(156, 112), S(136, 159), S(89, 167), S(61, 153), S(40, 142), S(11, 161), S(-7, 159), // + S(314, 324), S(131, 429), S(271, 383), S(270, 325), S(324, 251), S(228, 322), S(161, 363), S(282, 311), // + S(124, 202), S(146, 240), S(165, 191), S(135, 153), S(132, 121), S(107, 160), S(90, 206), S(50, 227), // + S(95, 165), S(80, 182), S(118, 139), S(102, 117), S(95, 100), S(74, 120), S(27, 162), S(20, 183), // + S(60, 118), S(49, 152), S(87, 123), S(74, 114), S(50, 110), S(41, 123), S(-18, 157), S(-15, 148), // + S(59, 88), S(97, 91), S(86, 130), S(71, 128), S(40, 123), S(26, 123), S(-12, 140), S(-15, 131), // + S(70, 98), S(152, 101), S(127, 138), S(92, 160), S(63, 147), S(44, 131), S(16, 148), S(-1, 147), // }; inline const std::array KNIGHT_PSQT = { - S(-240, -108), S(-161, 203), S(-32, -36), S(112, 197), S(45, 195), S(-99, 188), S(-277, 266), S(-309, -9), // - S(74, 167), S(121, 187), S(217, 156), S(206, 181), S(200, 188), S(123, 201), S(75, 203), S(50, 190), // - S(159, 162), S(199, 157), S(217, 210), S(212, 220), S(173, 248), S(116, 245), S(119, 191), S(87, 178), // - S(228, 188), S(230, 215), S(231, 235), S(212, 273), S(218, 273), S(178, 253), S(167, 223), S(162, 197), // - S(208, 191), S(248, 173), S(219, 227), S(212, 246), S(190, 249), S(189, 234), S(184, 188), S(145, 201), // - S(160, 148), S(185, 163), S(176, 197), S(184, 219), S(179, 220), S(143, 199), S(134, 171), S(106, 140), // - S(167, 155), S(181, 152), S(155, 161), S(158, 188), S(151, 186), S(123, 142), S(105, 168), S(91, 80), // - S(97, 99), S(144, 164), S(157, 136), S(177, 137), S(158, 160), S(125, 130), S(111, 151), S(73, 56), // + S(-202, -137), S(-132, 189), S(-168, 121), S(126, 166), S(45, 180), S(-103, 197), S(-260, 256), S(-274, -30), // + S(88, 156), S(121, 173), S(217, 135), S(214, 140), S(205, 158), S(148, 175), S(93, 193), S(74, 173), // + S(156, 148), S(176, 140), S(188, 198), S(198, 197), S(163, 229), S(124, 228), S(138, 166), S(103, 160), // + S(227, 171), S(234, 185), S(229, 206), S(219, 238), S(226, 243), S(189, 231), S(185, 200), S(178, 176), // + S(210, 170), S(247, 148), S(216, 205), S(217, 221), S(191, 228), S(195, 218), S(199, 165), S(157, 186), // + S(150, 145), S(167, 160), S(163, 198), S(177, 214), S(170, 215), S(141, 198), S(140, 166), S(112, 135), // + S(174, 144), S(183, 139), S(148, 160), S(157, 182), S(154, 180), S(129, 133), S(117, 156), S(107, 67), // + S(99, 95), S(146, 159), S(170, 125), S(189, 131), S(168, 153), S(135, 123), S(123, 143), S(83, 51), // }; inline const std::array BISHOP_PSQT = { - S(-5, 307), S(-12, 303), S(-303, 364), S(-140, 301), S(-133, 308), S(-159, 310), S(-48, 308), S(31, 291), // - S(122, 217), S(64, 293), S(108, 240), S(44, 274), S(63, 271), S(89, 262), S(125, 261), S(105, 234), // - S(182, 244), S(200, 249), S(198, 263), S(170, 265), S(142, 269), S(148, 271), S(167, 252), S(153, 238), // - S(156, 233), S(191, 243), S(197, 263), S(190, 304), S(221, 290), S(155, 264), S(168, 232), S(128, 229), // - S(188, 189), S(206, 226), S(211, 253), S(214, 276), S(191, 290), S(175, 272), S(145, 242), S(141, 204), // - S(214, 198), S(254, 211), S(260, 238), S(205, 266), S(198, 246), S(196, 252), S(205, 232), S(142, 229), // - S(178, 165), S(278, 176), S(235, 200), S(205, 220), S(185, 227), S(192, 197), S(191, 189), S(181, 182), // - S(210, 166), S(193, 197), S(195, 219), S(212, 193), S(202, 203), S(200, 242), S(200, 218), S(189, 189), // + S(10, 298), S(14, 290), S(-280, 352), S(-129, 293), S(-131, 304), S(-146, 297), S(-41, 296), S(35, 284), // + S(124, 215), S(85, 284), S(113, 235), S(49, 261), S(72, 255), S(93, 260), S(139, 251), S(111, 232), // + S(186, 234), S(184, 248), S(186, 258), S(167, 256), S(145, 259), S(159, 261), S(174, 250), S(169, 231), // + S(171, 216), S(199, 229), S(198, 253), S(195, 295), S(232, 278), S(174, 254), S(190, 215), S(153, 219), // + S(202, 175), S(207, 211), S(220, 240), S(223, 265), S(202, 280), S(202, 255), S(173, 226), S(168, 195), // + S(222, 183), S(248, 203), S(255, 233), S(211, 256), S(202, 238), S(211, 244), S(226, 222), S(172, 208), // + S(185, 155), S(280, 169), S(237, 195), S(217, 208), S(195, 217), S(206, 187), S(208, 179), S(203, 172), // + S(211, 162), S(190, 198), S(206, 213), S(231, 184), S(213, 198), S(211, 234), S(211, 209), S(204, 180), // }; inline const std::array ROOK_PSQT = { - S(424, 396), S(433, 418), S(430, 420), S(438, 392), S(416, 402), S(384, 409), S(383, 422), S(372, 426), // - S(311, 476), S(374, 479), S(465, 438), S(409, 449), S(398, 456), S(370, 459), S(301, 490), S(295, 487), // - S(279, 471), S(385, 455), S(441, 416), S(415, 409), S(368, 438), S(327, 459), S(328, 459), S(268, 491), // - S(282, 438), S(357, 445), S(395, 418), S(367, 418), S(367, 417), S(322, 450), S(315, 449), S(245, 475), // - S(262, 372), S(326, 389), S(315, 409), S(299, 398), S(281, 414), S(268, 435), S(236, 432), S(216, 431), // - S(253, 318), S(313, 346), S(304, 365), S(287, 360), S(276, 367), S(247, 399), S(247, 374), S(213, 381), // - S(145, 336), S(278, 294), S(289, 322), S(281, 342), S(268, 346), S(257, 354), S(242, 338), S(217, 349), // - S(213, 308), S(231, 334), S(290, 326), S(303, 319), S(292, 327), S(273, 344), S(264, 339), S(247, 346), // + S(424, 399), S(468, 395), S(419, 417), S(426, 383), S(468, 369), S(426, 385), S(434, 399), S(408, 416), // + S(308, 471), S(391, 460), S(452, 428), S(394, 439), S(434, 427), S(403, 433), S(337, 470), S(320, 479), // + S(265, 467), S(378, 443), S(419, 404), S(396, 397), S(392, 416), S(349, 439), S(353, 443), S(290, 481), // + S(244, 439), S(324, 434), S(357, 405), S(334, 411), S(359, 406), S(320, 436), S(316, 440), S(249, 467), // + S(224, 373), S(295, 382), S(287, 393), S(268, 392), S(272, 405), S(263, 424), S(234, 425), S(216, 425), // + S(232, 314), S(303, 331), S(298, 345), S(281, 345), S(289, 350), S(258, 380), S(260, 363), S(222, 372), // + S(136, 324), S(277, 278), S(284, 306), S(277, 328), S(281, 328), S(267, 338), S(256, 323), S(227, 338), // + S(198, 306), S(220, 327), S(286, 312), S(298, 308), S(297, 316), S(277, 333), S(272, 326), S(253, 335), // }; inline const std::array QUEEN_PSQT = { - S(489, 462), S(554, 395), S(483, 501), S(461, 561), S(449, 528), S(470, 499), S(482, 432), S(431, 483), // - S(500, 502), S(465, 594), S(455, 622), S(322, 704), S(332, 683), S(385, 646), S(423, 531), S(437, 507), // - S(464, 569), S(518, 582), S(458, 669), S(406, 685), S(380, 675), S(433, 588), S(467, 515), S(477, 443), // - S(512, 468), S(511, 564), S(458, 619), S(440, 659), S(431, 661), S(451, 555), S(495, 482), S(478, 451), // - S(526, 434), S(510, 514), S(487, 556), S(456, 597), S(456, 599), S(458, 543), S(477, 465), S(501, 391), // - S(507, 373), S(541, 418), S(532, 486), S(502, 482), S(498, 472), S(496, 489), S(506, 419), S(486, 392), // - S(484, 254), S(527, 253), S(529, 324), S(539, 375), S(527, 401), S(522, 366), S(483, 403), S(492, 378), // - S(466, 264), S(497, 100), S(518, 133), S(535, 242), S(531, 325), S(531, 267), S(521, 284), S(488, 320), // + S(518, 575), S(605, 525), S(506, 665), S(437, 775), S(487, 703), S(495, 655), S(540, 532), S(468, 602), // + S(508, 591), S(502, 678), S(441, 769), S(306, 870), S(349, 848), S(405, 765), S(477, 604), S(473, 595), // + S(450, 664), S(464, 709), S(405, 811), S(360, 839), S(374, 831), S(444, 709), S(481, 620), S(505, 531), // + S(478, 562), S(458, 657), S(402, 737), S(389, 793), S(404, 787), S(440, 676), S(496, 572), S(488, 531), // + S(491, 524), S(468, 583), S(442, 647), S(420, 698), S(432, 709), S(458, 633), S(484, 554), S(517, 471), // + S(486, 452), S(516, 473), S(510, 538), S(491, 541), S(492, 549), S(503, 564), S(525, 498), S(509, 478), // + S(474, 311), S(507, 315), S(514, 382), S(539, 405), S(530, 446), S(534, 421), S(506, 457), S(519, 446), // + S(462, 320), S(487, 192), S(525, 174), S(545, 265), S(544, 342), S(546, 303), S(538, 333), S(509, 375), // }; inline const std::array KING_PSQT = { - S(-179, -158), S(178, 285), S(102, 284), S(-61, 214), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(112, 53), S(253, 205), S(159, 233), S(119, 111), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(108, 106), S(265, 152), S(229, 156), S(177, 82), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-14, 36), S(232, 62), S(156, 95), S(139, 83), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-78, -34), S(164, -8), S(130, 36), S(49, 86), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-30, -67), S(174, -49), S(100, 10), S(57, 53), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(6, -84), S(85, -43), S(11, 4), S(-43, 36), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-109, -117), S(-12, -73), S(-107, -35), S(-97, -57), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(27, -321), S(367, 166), S(275, 127), S(160, 11), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(295, -49), S(385, 172), S(268, 159), S(215, 35), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(211, 39), S(292, 141), S(226, 137), S(183, 50), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(24, 6), S(183, 77), S(93, 106), S(65, 105), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-119, -13), S(24, 45), S(-15, 85), S(-91, 133), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-75, -36), S(32, 15), S(-27, 65), S(-68, 103), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-3, -78), S(38, -15), S(-13, 28), S(-75, 70), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-80, -139), S(-9, -82), S(-80, -39), S(-81, -48), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // }; inline const std::array, 4> KING_SHELTER = {{ - {{ S(10, 24), S(-5, 27), S(-9, 25), S(-2, -11), S(-3, -15), S(-9, 26), S(-4, 26), }}, - {{ S(2, 142), S(-23, 122), S(-19, 106), S(-9, 71), S(-9, 67), S(-18, 108), S(-21, 125), }}, - {{ S(-8, 112), S(-20, 103), S(-16, 80), S(-13, 52), S(-12, 49), S(-15, 79), S(-18, 102), }}, - {{ S(3, 114), S(-13, 59), S(-5, 70), S(-2, 65), S(-3, 63), S(-6, 68), S(-10, 68), }}, + {{ S(28, -9), S(4, 15), S(9, 2), S(19, -6), S(18, -6), S(8, 3), S(6, 13), }}, + {{ S(11, 7), S(-12, 10), S(-9, 16), S(-1, 23), S(-0, 21), S(-9, 19), S(-12, 12), }}, + {{ S(10, 9), S(0, 2), S(0, 22), S(3, 27), S(4, 26), S(-1, 25), S(1, 2), }}, + {{ S(16, 18), S(1, 20), S(4, 38), S(7, 44), S(5, 47), S(2, 41), S(2, 25), }}, }}; inline const std::array BLOCKED_SHELTER_STORM = { - S(0, 0), S(0, 0), S(3, 83), S(-16, -117), S(-14, 51), S(-7, 98), S(-8, 66), + S(0, 0), S(0, 0), S(-8, 6), S(-18, -17), S(-20, -8), S(-16, 4), S(-3, -26), }; inline const std::array, 4> SHELTER_STORM = {{ - {{ S(-4, 158), S(-13, 146), S(-12, 124), S(-11, 122), S(-12, 128), S(-11, 123), S(-13, 147), }}, - {{ S(-4, 48), S(-10, 32), S(-16, 24), S(-12, 1), S(-13, -10), S(-15, 12), S(-9, 30), }}, - {{ S(-9, 78), S(-13, 60), S(-14, 60), S(-11, 50), S(-10, 40), S(-15, 55), S(-13, 62), }}, - {{ S(-9, 79), S(-15, 72), S(-17, 55), S(-10, 49), S(-9, 53), S(-16, 59), S(-16, 71), }}, + {{ S(-6, -12), S(-16, -12), S(-18, -9), S(-14, -14), S(-15, -14), S(-18, -7), S(-17, -10), }}, + {{ S(-1, -21), S(-9, -15), S(-19, -11), S(-14, -16), S(-15, -15), S(-17, -13), S(-9, -15), }}, + {{ S(-10, -12), S(-15, -3), S(-18, -5), S(-15, -9), S(-14, -12), S(-18, -7), S(-15, -4), }}, + {{ S(-9, -20), S(-18, -7), S(-20, -11), S(-16, -11), S(-15, -12), S(-20, -11), S(-21, -1), }}, }}; inline TunableSigmoid<32> KING_SAFETY_ACTIVATION( - 1387, 1642, -29, 134 + 1453, 882, -15, 20 ); inline VParam WINNABLE_PAWNS = V(-15); -inline VParam WINNABLE_SYM = V(137); -inline VParam WINNABLE_ASYM = V(124); -inline VParam WINNABLE_PAWN_ENDGAME = V(234); -inline VParam WINNABLE_BIAS = V(-654); +inline VParam WINNABLE_SYM = V(135); +inline VParam WINNABLE_ASYM = V(125); +inline VParam WINNABLE_PAWN_ENDGAME = V(208); +inline VParam WINNABLE_BIAS = V(-644); -// Epoch duration: 8.89058s +// Epoch duration: 9.72937s // clang-format on } // namespace Clockwork diff --git a/src/evaltune_main.cpp b/src/evaltune_main.cpp index 4c6fadfc..befde406 100644 --- a/src/evaltune_main.cpp +++ b/src/evaltune_main.cpp @@ -333,15 +333,17 @@ int main() { std::cout << std::endl; std::cout << "inline const PParam KS_NO_QUEEN = " << KS_NO_QUEEN << ";" << std::endl; - + std::cout << std::endl; + std::cout << "inline const PParam KS_FLANK_ATTACK = " << KS_FLANK_ATTACK << ";" << std::endl; std::cout << "inline const PParam KS_FLANK_DEFENSE = " << KS_FLANK_DEFENSE << ";" << std::endl; - std::cout << "inline const PParam KS_DLANK_DOUBLE_ATTACK = " << KS_FLANK_DOUBLE_ATTACK + std::cout << "inline const PParam KS_FLANK_DOUBLE_ATTACK = " << KS_FLANK_DOUBLE_ATTACK << ";" << std::endl; std::cout << "inline const PParam KS_FLANK_DOUBLE_DEFENSE = " << KS_FLANK_DOUBLE_DEFENSE << ";" << std::endl; + std::cout << std::endl; std::cout << "inline const PParam PAWN_THREAT_KNIGHT = " << PAWN_THREAT_KNIGHT << ";" << std::endl; From 105624dd07510503668998d50bab8dd4f8f120db Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Wed, 8 Apr 2026 00:41:20 +0200 Subject: [PATCH 5/5] Bench: 18377860 --- src/evaluation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evaluation.hpp b/src/evaluation.hpp index 8204492f..62dfde25 100644 --- a/src/evaluation.hpp +++ b/src/evaluation.hpp @@ -24,7 +24,7 @@ static constexpr std::array, 2> king_flank = []() { // Queenside files (0-2), Center files (3-4), Kingside files (5-7) constexpr std::array flank_start = {0, 0, 0, 2, 2, 4, 4, 4}; constexpr std::array flank_width = {4, 4, 4, 4, 4, 4, 4, 4}; - constexpr Bitboard white_ranks = Bitboard::rank_mask(0) | Bitboard::rank_mask(1) + constexpr Bitboard white_ranks = Bitboard::rank_mask(0) | Bitboard::rank_mask(1) | Bitboard::rank_mask(2) | Bitboard::rank_mask(3) | Bitboard::rank_mask(4); constexpr Bitboard black_ranks = Bitboard::rank_mask(3) | Bitboard::rank_mask(4)