From f234e3fef5a71932766b1f0661c2b23766212f62 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Wed, 6 May 2026 00:50:24 +0200 Subject: [PATCH 1/4] me when i commit unspeakable incorrectness (yay) --- src/bitboard.hpp | 4 ++-- src/square.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bitboard.hpp b/src/bitboard.hpp index 18cc005b..0fcade53 100644 --- a/src/bitboard.hpp +++ b/src/bitboard.hpp @@ -7,6 +7,7 @@ #include "square.hpp" #include "util/bit.hpp" #include "util/types.hpp" +#include namespace Clockwork { @@ -71,9 +72,8 @@ struct Bitboard { } [[nodiscard]] Square msb() const { - return Square{static_cast(std::countl_zero(m_raw))}; + return Square{static_cast(std::bit_width(m_raw) - 1)}; } - [[nodiscard]] Square lsb() const { return Square{static_cast(std::countr_zero(m_raw))}; } diff --git a/src/square.hpp b/src/square.hpp index 8bbfd2ac..3f4df0a2 100644 --- a/src/square.hpp +++ b/src/square.hpp @@ -55,7 +55,7 @@ struct Square { } [[nodiscard]] constexpr i32 relative_rank(Color c) const { - return c == Color::White ? rank() : 7 - rank(); + return c == Color::White ? rank() : rank() ^ 7; } [[nodiscard]] constexpr std::tuple to_file_and_rank() const { From c123e34892bfeacbb4d496a7d0012eef8a335842 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Wed, 6 May 2026 01:19:31 +0200 Subject: [PATCH 2/4] tools for the future generations --- scripts/reflectiveness.py | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 scripts/reflectiveness.py diff --git a/scripts/reflectiveness.py b/scripts/reflectiveness.py new file mode 100644 index 00000000..4d7a3b4d --- /dev/null +++ b/scripts/reflectiveness.py @@ -0,0 +1,132 @@ +import subprocess +import chess +import random +import time +import sys + +ENGINE_PATH = sys.argv[1] if len(sys.argv) > 1 else "./clockwork" + +NUM_POSITIONS = 10000 +MAX_RANDOM_PLIES = 40 + + +class Engine: + def __init__(self, path): + self.proc = subprocess.Popen( + path, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + text=True, + bufsize=1 + ) + self._init_uci() + + def send(self, cmd): + self.proc.stdin.write(cmd + "\n") + self.proc.stdin.flush() + + def read_until(self, keyword): + while True: + line = self.proc.stdout.readline() + if keyword in line: + return line.strip() + + def _init_uci(self): + self.send("uci") + self.read_until("uciok") + self.send("isready") + self.read_until("readyok") + + def eval(self, board): + fen = board.fen() + self.send(f"position fen {fen}") + self.send("eval") + + # Expect: "Evaluation (stm): xxxx" + while True: + line = self.proc.stdout.readline() + if "Evaluation" in line: + try: + val = int(line.strip().split()[-1]) + return val + except: + continue + + def quit(self): + self.send("quit") + self.proc.kill() + + +def random_position(): + board = chess.Board() + + n_moves = random.randint(0, MAX_RANDOM_PLIES) + + for _ in range(n_moves): + if board.is_game_over(): + break + + moves = list(board.legal_moves) + if not moves: + break + + move = random.choice(moves) + board.push(move) + + # No positions in check + if board.is_check(): + return None + + return board + + +def mirror_board(board): + return board.mirror() + +def main(): + engine = Engine(ENGINE_PATH) + + tested = 0 + failures = 0 + + start_time = time.time() + + while tested < NUM_POSITIONS: + board = random_position() + if board is None: + continue + + mirrored = mirror_board(board) + + eval1 = engine.eval(board) + eval2 = engine.eval(mirrored) + + if eval1 is None or eval2 is None: + continue + + if eval1 != eval2: + failures += 1 + print() + print("Asymmetry detected!") + print("FEN:", board.fen(), " --- ", mirrored.fen()) + print("Eval:", eval1) + print("Mirrored Eval:", eval2) + print("Sum:", eval1 - eval2) + + tested += 1 + + if tested % 100 == 0: + elapsed = time.time() - start_time + print(f"Tested: {tested}, Failures: {failures}, Time: {elapsed:.1f}s") + + engine.quit() + + print("\n==== DONE ====") + print(f"Positions tested: {tested}") + print(f"Failures: {failures}") + print(f"Failure rate: {failures / tested:.6f}") + + +if __name__ == "__main__": + main() \ No newline at end of file From dae72e98e918496f1f9087859054282f111f41de Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Wed, 6 May 2026 01:31:28 +0200 Subject: [PATCH 3/4] Surely passer with lots of elo! Exalted spiritual prowess. Bench: 14793132 --- src/eval_constants.hpp | 198 ++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/src/eval_constants.hpp b/src/eval_constants.hpp index 1d0a188a..dada4502 100644 --- a/src/eval_constants.hpp +++ b/src/eval_constants.hpp @@ -5,185 +5,185 @@ namespace Clockwork { // clang-format off -inline const PParam PAWN_MAT = S(183, 436); +inline const PParam PAWN_MAT = S(182, 438); inline const PParam KNIGHT_MAT = S(836, 1255); -inline const PParam BISHOP_MAT = S(870, 1315); -inline const PParam ROOK_MAT = S(1037, 2101); -inline const PParam QUEEN_MAT = S(2539, 3257); -inline const PParam TEMPO_VAL = S(60, 21); +inline const PParam BISHOP_MAT = S(873, 1314); +inline const PParam ROOK_MAT = S(1041, 2101); +inline const PParam QUEEN_MAT = S(2548, 3250); +inline const PParam TEMPO_VAL = S(61, 21); inline const PParam BISHOP_XRAY_PAWNS = S(-13, 14); -inline const PParam BISHOP_PAIR_VAL = S(53, 220); -inline const PParam ROOK_OPEN_VAL = S(114, -12); +inline const PParam BISHOP_PAIR_VAL = S(52, 221); +inline const PParam ROOK_OPEN_VAL = S(115, -13); inline const PParam ROOK_SEMIOPEN_VAL = S(44, 31); inline const PParam MINOR_BEHIND_PAWN = S(14, 40); inline const PParam RESTRICTED_SQUARES = S(-23, -7); -inline const PParam DOUBLED_PAWN_VAL = S(-13, -77); +inline const PParam DOUBLED_PAWN_VAL = S(-14, -77); inline const PParam ISOLATED_PAWN_VAL = S(-17, -24); inline const PParam POTENTIAL_CHECKER_VAL = S(-50, -24); -inline const PParam OUTPOST_KNIGHT_VAL = S(52, 55); +inline const PParam OUTPOST_KNIGHT_VAL = S(51, 56); inline const PParam OUTPOST_BISHOP_VAL = S(57, 39); inline const PParam PAWN_PUSH_THREAT_KNIGHT = S(37, 5); -inline const PParam PAWN_PUSH_THREAT_BISHOP = S(45, -15); -inline const PParam PAWN_PUSH_THREAT_ROOK = S(24, 53); -inline const PParam PAWN_PUSH_THREAT_QUEEN = S(62, -42); +inline const PParam PAWN_PUSH_THREAT_BISHOP = S(44, -15); +inline const PParam PAWN_PUSH_THREAT_ROOK = S(25, 52); +inline const PParam PAWN_PUSH_THREAT_QUEEN = S(60, -39); inline const std::array PAWN_PHALANX = { - S(16, 3), S(29, 35), S(58, 59), S(137, 167), S(364, 257), S(469, 510), + S(16, 3), S(29, 35), S(57, 60), S(126, 170), S(398, 241), S(464, 507), }; inline const std::array DEFENDED_PAWN = { - S(44, 42), S(44, 34), S(60, 60), S(117, 162), S(413, 92), + S(44, 42), S(43, 35), S(62, 59), S(116, 159), S(420, 85), }; inline const std::array PASSED_PAWN = { - S(-101, -216), S(-102, -183), S(-77, -62), S(-24, 50), S(64, 211), S(246, 301), + S(-97, -216), S(-98, -183), S(-75, -61), S(-27, 53), S(83, 208), S(244, 312), }; inline const std::array DEFENDED_PASSED_PUSH = { - S(27, -41), S(23, -2), S(16, 33), S(5, 119), S(75, 236), S(171, 380), + S(26, -40), S(23, -2), S(17, 33), S(10, 115), S(77, 231), S(140, 385), }; inline const std::array BLOCKED_PASSED_PAWN = { - S(15, -25), S(4, 19), S(1, -18), S(1, -46), S(-9, -136), S(-242, -244), + S(15, -25), S(4, 19), S(-0, -17), S(-0, -49), S(-19, -133), S(-206, -253), }; inline const std::array FRIENDLY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(18, 206), S(-6, 176), S(1, 97), S(8, 58), S(15, 59), S(52, 55), S(43, 38), + S(0, 0), S(21, 203), S(-3, 173), S(1, 97), S(7, 59), S(18, 57), S(57, 52), S(45, 40), }; inline const std::array ENEMY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(-265, -48), S(-8, 34), S(-2, 96), S(35, 126), S(55, 150), S(65, 156), S(43, 155), + S(0, 0), S(-209, -59), S(-9, 31), S(-2, 95), S(34, 125), S(51, 149), S(60, 157), S(37, 155), }; inline const std::array KNIGHT_MOBILITY = { - S(-102, -298), S(-40, -105), S(-11, -4), S(15, 33), S(44, 54), S(60, 88), S(80, 88), S(100, 98), S(132, 26), + S(-100, -298), S(-38, -106), S(-9, -5), S(15, 33), S(46, 54), S(61, 88), S(81, 88), S(101, 99), S(133, 26), }; inline const std::array BISHOP_MOBILITY = { - S(-68, -274), S(-20, -99), S(31, -24), S(54, 25), S(75, 62), S(87, 90), S(92, 111), S(100, 123), S(102, 139), S(114, 129), S(118, 129), S(154, 80), S(159, 73), S(183, 26), + S(-70, -275), S(-22, -100), S(29, -25), S(52, 24), S(74, 61), S(86, 88), S(91, 109), S(99, 121), S(101, 137), S(113, 127), S(117, 126), S(154, 76), S(161, 65), S(186, 17), }; inline const std::array ROOK_MOBILITY = { - S(105, -146), S(24, 26), S(45, 56), S(61, 67), S(71, 82), S(76, 95), S(81, 107), S(88, 110), S(93, 122), S(101, 125), S(108, 129), S(111, 136), S(113, 136), S(121, 112), S(191, 8), + S(103, -141), S(23, 27), S(45, 57), S(61, 68), S(71, 83), S(76, 95), S(81, 107), S(88, 110), S(93, 122), S(100, 126), S(108, 129), S(110, 137), S(113, 136), S(120, 113), S(191, 7), }; inline const std::array QUEEN_MOBILITY = { - S(-163, -72), S(-33, 21), S(-8, 144), S(12, 256), S(27, 300), S(36, 344), S(41, 377), S(49, 385), S(52, 410), S(55, 426), S(61, 431), S(63, 441), S(68, 439), S(68, 446), S(70, 442), S(66, 446), S(64, 442), S(69, 428), S(73, 416), S(77, 403), S(75, 386), S(91, 343), S(73, 349), S(56, 299), S(27, 297), S(12, 268), S(-37, 286), S(-26, 222), + S(-162, -72), S(-33, 23), S(-8, 145), S(12, 255), S(27, 298), S(36, 343), S(41, 375), S(49, 384), S(53, 408), S(55, 425), S(60, 430), S(63, 440), S(69, 437), S(68, 446), S(70, 441), S(65, 445), S(63, 442), S(68, 428), S(71, 418), S(78, 400), S(76, 383), S(91, 341), S(71, 351), S(56, 298), S(29, 292), S(13, 267), S(-36, 285), S(-26, 222), }; -inline const PParam PAWN_THREAT_KNIGHT = S(205, 106); -inline const PParam PAWN_THREAT_BISHOP = S(192, 157); -inline const PParam PAWN_THREAT_ROOK = S(197, 133); -inline const PParam PAWN_THREAT_QUEEN = S(179, -15); +inline const PParam PAWN_THREAT_KNIGHT = S(204, 107); +inline const PParam PAWN_THREAT_BISHOP = S(192, 156); +inline const PParam PAWN_THREAT_ROOK = S(200, 130); +inline const PParam PAWN_THREAT_QUEEN = S(179, -14); inline const PParam KNIGHT_THREAT_BISHOP = S(108, 114); -inline const PParam KNIGHT_THREAT_ROOK = S(222, 86); -inline const PParam KNIGHT_THREAT_QUEEN = S(153, -7); +inline const PParam KNIGHT_THREAT_ROOK = S(222, 87); +inline const PParam KNIGHT_THREAT_QUEEN = S(154, -9); -inline const PParam BISHOP_THREAT_KNIGHT = S(97, 72); +inline const PParam BISHOP_THREAT_KNIGHT = S(98, 72); inline const PParam BISHOP_THREAT_ROOK = S(207, 142); -inline const PParam BISHOP_THREAT_QUEEN = S(167, 112); +inline const PParam BISHOP_THREAT_QUEEN = S(167, 108); inline const std::array BISHOP_PAWNS = { - S(8, -26), S(0, -8), S(-3, -17), S(-6, -27), S(-11, -37), S(-14, -44), S(-16, -57), S(-21, -59), S(-34, -57), + S(8, -27), S(-0, -8), S(-3, -17), S(-6, -27), S(-11, -37), S(-14, -45), S(-16, -57), S(-21, -60), S(-35, -57), }; -inline const PParam ROOK_LINEUP = S(16, 65); +inline const PParam ROOK_LINEUP = S(16, 63); inline const std::array PAWN_PSQT = { - S(206, 227), S(51, 280), S(194, 212), S(177, 182), S(221, 108), S(117, 201), S(53, 252), S(193, 191), // - S(42, 30), S(70, 44), S(75, 13), S(54, -52), S(48, -83), S(27, -34), S(7, 23), S(-23, 51), // - S(25, -24), S(3, -18), S(34, -59), S(20, -84), S(16, -99), S(-6, -71), S(-51, -24), S(-48, 3), // - S(-7, -77), S(-26, -49), S(2, -73), S(-11, -80), S(-33, -82), S(-38, -67), S(-92, -31), S(-82, -38), // - S(-6, -108), S(28, -110), S(11, -54), S(-4, -58), S(-32, -67), S(-48, -64), S(-80, -50), S(-80, -56), // - S(15, -107), S(94, -110), S(71, -61), S(30, -25), S(2, -45), S(-20, -58), S(-50, -43), S(-62, -42), // + S(214, 203), S(84, 296), S(136, 265), S(153, 193), S(195, 117), S(109, 203), S(87, 234), S(211, 176), // + S(31, 40), S(41, 83), S(36, 13), S(38, -48), S(30, -80), S(-5, -23), S(-13, 32), S(-37, 56), // + S(29, -22), S(9, -16), S(33, -59), S(21, -86), S(17, -101), S(-6, -71), S(-47, -26), S(-48, 4), // + S(-7, -77), S(-26, -53), S(5, -75), S(-7, -83), S(-28, -86), S(-34, -68), S(-91, -34), S(-80, -39), // + S(-6, -110), S(30, -114), S(16, -57), S(-1, -61), S(-29, -70), S(-45, -66), S(-77, -52), S(-78, -57), // + S(14, -108), S(92, -112), S(71, -63), S(31, -28), S(3, -47), S(-19, -59), S(-48, -44), S(-61, -42), // }; inline const std::array KNIGHT_PSQT = { - S(-300, -394), S(-283, 45), S(-234, -188), S(-30, 42), S(-99, 38), S(-235, 34), S(-402, 107), S(-376, -272), // - S(-44, -14), S(-28, 31), S(85, -5), S(85, 28), S(88, 24), S(21, 30), S(-43, 35), S(-63, 6), // - S(25, -20), S(36, 11), S(72, 63), S(90, 59), S(61, 83), S(16, 80), S(5, 19), S(-41, 11), // - S(88, 10), S(96, 42), S(105, 70), S(106, 107), S(112, 109), S(71, 87), S(45, 53), S(30, 27), // - S(68, 12), S(108, -4), S(94, 60), S(89, 79), S(70, 81), S(74, 68), S(57, 18), S(13, 31), // - S(10, -33), S(37, -9), S(37, 32), S(50, 58), S(44, 55), S(16, 33), S(7, -1), S(-33, -34), // - S(27, -25), S(36, -26), S(14, -14), S(21, 10), S(19, 8), S(-7, -39), S(-32, -7), S(-44, -102), // - S(-46, -86), S(6, -26), S(24, -51), S(40, -44), S(23, -24), S(-11, -50), S(-23, -33), S(-66, -129), // + S(-302, -389), S(-283, 46), S(-236, -182), S(-29, 44), S(-99, 41), S(-233, 34), S(-397, 103), S(-376, -271), // + S(-41, -14), S(-24, 30), S(88, -7), S(86, 28), S(87, 27), S(23, 32), S(-41, 36), S(-60, 6), // + S(27, -21), S(36, 13), S(75, 61), S(92, 59), S(64, 82), S(18, 81), S(7, 19), S(-37, 9), // + S(89, 12), S(97, 43), S(105, 70), S(108, 107), S(114, 109), S(71, 89), S(47, 54), S(32, 27), // + S(69, 12), S(109, -3), S(95, 61), S(91, 79), S(72, 82), S(75, 68), S(59, 17), S(15, 31), // + S(11, -33), S(38, -9), S(38, 33), S(51, 58), S(46, 55), S(18, 33), S(10, -2), S(-32, -34), // + S(27, -24), S(37, -26), S(15, -14), S(23, 10), S(20, 8), S(-5, -40), S(-30, -7), S(-43, -102), // + S(-45, -84), S(6, -25), S(25, -51), S(41, -44), S(24, -23), S(-11, -49), S(-22, -32), S(-66, -126), // }; inline const std::array BISHOP_PSQT = { - S(-149, 73), S(-170, 105), S(-460, 177), S(-310, 111), S(-317, 126), S(-343, 126), S(-236, 119), S(-125, 54), // - S(-46, -5), S(-85, 86), S(-56, 46), S(-112, 76), S(-89, 64), S(-59, 46), S(-21, 36), S(-58, 14), // - S(21, 24), S(7, 57), S(23, 62), S(17, 56), S(0, 47), S(11, 40), S(10, 36), S(4, 15), // - S(9, 2), S(45, 15), S(58, 39), S(68, 71), S(102, 52), S(38, 29), S(40, -6), S(-8, 2), // - S(43, -52), S(51, -7), S(75, 17), S(90, 39), S(72, 51), S(61, 33), S(18, 9), S(9, -28), // - S(62, -37), S(83, -21), S(99, 10), S(65, 33), S(61, 13), S(60, 22), S(64, 3), S(10, -4), // - S(31, -79), S(112, -56), S(72, -29), S(50, -7), S(34, -5), S(46, -38), S(44, -49), S(42, -54), // - S(52, -74), S(34, -38), S(31, -4), S(48, -31), S(34, -19), S(39, 18), S(48, -14), S(44, -49), // + S(-148, 74), S(-167, 107), S(-456, 175), S(-307, 111), S(-318, 129), S(-340, 126), S(-230, 114), S(-124, 53), // + S(-44, -4), S(-81, 84), S(-52, 42), S(-109, 75), S(-87, 64), S(-55, 45), S(-18, 34), S(-55, 13), // + S(22, 24), S(10, 54), S(25, 62), S(18, 57), S(4, 44), S(13, 39), S(12, 36), S(6, 16), // + S(11, 1), S(47, 15), S(59, 40), S(69, 73), S(103, 53), S(39, 30), S(43, -6), S(-6, 3), // + S(44, -52), S(54, -9), S(76, 18), S(91, 41), S(73, 52), S(63, 35), S(20, 10), S(11, -26), // + S(63, -36), S(84, -21), S(99, 11), S(66, 34), S(63, 13), S(61, 23), S(67, 3), S(11, -4), // + S(33, -78), S(112, -54), S(74, -29), S(51, -7), S(35, -4), S(47, -37), S(46, -48), S(43, -52), // + S(54, -72), S(35, -37), S(32, -3), S(49, -30), S(35, -18), S(40, 19), S(49, -13), S(44, -47), // }; inline const std::array ROOK_PSQT = { - S(187, 99), S(236, 95), S(184, 119), S(184, 84), S(226, 68), S(181, 94), S(203, 98), S(178, 115), // - S(82, 170), S(168, 160), S(225, 127), S(169, 137), S(206, 127), S(168, 145), S(116, 172), S(97, 178), // - S(48, 167), S(180, 125), S(211, 101), S(185, 95), S(182, 115), S(132, 148), S(135, 149), S(68, 190), // - S(24, 132), S(106, 137), S(134, 107), S(111, 116), S(142, 102), S(95, 143), S(99, 139), S(26, 170), // - S(4, 53), S(80, 61), S(70, 77), S(40, 82), S(48, 94), S(36, 121), S(13, 116), S(-3, 111), // - S(20, -32), S(92, -6), S(79, 14), S(58, 14), S(68, 21), S(36, 58), S(45, 33), S(5, 43), // - S(-74, -26), S(64, -64), S(67, -37), S(55, -10), S(57, -5), S(45, 6), S(35, -7), S(4, 7), // - S(-10, -46), S(16, -24), S(71, -35), S(81, -37), S(81, -27), S(61, -6), S(57, -12), S(37, -6), // + S(186, 100), S(233, 98), S(182, 119), S(180, 87), S(223, 71), S(178, 96), S(201, 101), S(177, 116), // + S(81, 171), S(165, 162), S(224, 127), S(168, 135), S(204, 129), S(166, 147), S(115, 174), S(97, 178), // + S(47, 168), S(179, 125), S(208, 101), S(186, 92), S(183, 113), S(131, 149), S(134, 149), S(67, 191), // + S(23, 131), S(105, 135), S(131, 108), S(110, 115), S(142, 101), S(95, 143), S(99, 138), S(25, 169), // + S(4, 49), S(81, 58), S(69, 76), S(40, 80), S(48, 93), S(38, 119), S(13, 114), S(-3, 110), // + S(21, -36), S(92, -9), S(80, 10), S(59, 11), S(69, 18), S(37, 55), S(46, 30), S(5, 40), // + S(-73, -30), S(64, -67), S(66, -39), S(54, -12), S(57, -8), S(45, 4), S(35, -10), S(4, 5), // + S(-10, -48), S(15, -26), S(71, -37), S(81, -39), S(81, -28), S(61, -8), S(57, -14), S(37, -7), // }; inline const std::array QUEEN_PSQT = { - S(51, 170), S(144, 97), S(71, 199), S(20, 281), S(55, 236), S(53, 212), S(74, 129), S(1, 203), // - S(50, 195), S(59, 290), S(32, 308), S(-95, 390), S(-59, 388), S(-10, 331), S(38, 208), S(16, 206), // - S(17, 237), S(41, 296), S(20, 343), S(-24, 370), S(-16, 374), S(37, 284), S(55, 215), S(62, 132), // - S(34, 134), S(36, 220), S(-12, 296), S(-25, 357), S(-13, 374), S(20, 255), S(62, 176), S(35, 152), // - S(37, 97), S(24, 156), S(1, 222), S(-21, 286), S(-8, 312), S(6, 262), S(30, 172), S(48, 99), // - S(30, 20), S(45, 66), S(40, 147), S(22, 154), S(25, 180), S(28, 211), S(45, 148), S(38, 97), // - S(3, -96), S(19, -43), S(27, 6), S(53, 36), S(45, 85), S(45, 63), S(18, 101), S(35, 72), // - S(-9, -93), S(15, -226), S(40, -213), S(55, -107), S(50, -7), S(56, -54), S(51, -22), S(26, 6), // + S(52, 167), S(143, 97), S(71, 196), S(15, 288), S(53, 237), S(55, 209), S(75, 127), S(0, 203), // + S(51, 192), S(59, 290), S(32, 310), S(-96, 390), S(-57, 384), S(-9, 329), S(39, 207), S(17, 206), // + S(16, 238), S(41, 295), S(20, 340), S(-24, 368), S(-15, 372), S(38, 283), S(56, 216), S(63, 131), // + S(34, 132), S(37, 216), S(-12, 295), S(-24, 357), S(-12, 374), S(21, 256), S(62, 177), S(35, 154), // + S(36, 95), S(23, 157), S(0, 223), S(-20, 284), S(-6, 312), S(8, 263), S(28, 176), S(49, 100), // + S(31, 18), S(45, 65), S(41, 144), S(23, 153), S(26, 179), S(29, 212), S(46, 148), S(39, 97), // + S(4, -98), S(20, -45), S(27, 6), S(53, 35), S(46, 83), S(46, 63), S(19, 101), S(36, 71), // + S(-9, -92), S(14, -221), S(39, -211), S(55, -107), S(50, -6), S(56, -54), S(50, -19), S(25, 10), // }; inline const std::array KING_PSQT = { - S(-62, -294), S(275, 288), S(155, 285), S(-18, 194), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(213, 6), S(265, 239), S(108, 287), S(12, 192), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(132, 116), S(170, 220), S(66, 257), S(-14, 196), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-30, 58), S(63, 152), S(-70, 220), S(-104, 232), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-107, -12), S(-31, 72), S(-110, 143), S(-201, 211), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-24, -60), S(31, 5), S(-71, 88), S(-130, 145), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(36, -114), S(44, -42), S(-32, 15), S(-97, 68), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-9, -214), S(16, -110), S(-66, -64), S(-60, -78), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-65, -284), S(271, 292), S(153, 287), S(-31, 204), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(199, 20), S(261, 250), S(97, 306), S(-5, 210), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(118, 134), S(157, 235), S(48, 280), S(-35, 215), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-44, 73), S(52, 164), S(-91, 240), S(-128, 248), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-107, -13), S(-34, 74), S(-124, 150), S(-222, 221), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-15, -69), S(37, -3), S(-72, 85), S(-139, 148), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(43, -126), S(51, -52), S(-28, 7), S(-98, 65), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-1, -227), S(24, -122), S(-60, -72), S(-57, -85), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // }; -inline const PParam KS_NO_QUEEN = S(-86, -542); +inline const PParam KS_NO_QUEEN = S(-83, -491); inline const std::array PT_INNER_RING_ATTACKS = { - S(10, -20), S(15, -27), S(14, -4), S(6, -9), S(1, -30), + S(8, -6), S(15, -24), S(14, -2), S(6, -9), S(1, -26), }; inline const std::array PT_OUTER_RING_ATTACKS = { - S(4, -12), S(6, -23), S(4, -13), S(4, -0), S(4, 7), + S(3, -9), S(6, -22), S(4, -12), S(4, -1), S(4, 5), }; -inline const PParam KS_FLANK_ATTACK = S(4, -9); +inline const PParam KS_FLANK_ATTACK = S(4, -8); inline const PParam KS_FLANK_DEFENSE = S(-5, 1); -inline const PParam KS_FLANK_DOUBLE_ATTACK = S(3, -4); +inline const PParam KS_FLANK_DOUBLE_ATTACK = S(3, -5); inline const PParam KS_FLANK_DOUBLE_DEFENSE = S(-2, -7); inline const std::array, 4> KING_SHELTER = {{ - {{ S(17, 44), S(-4, 54), S(-2, -17), S(9, -20), S(8, -8), S(-3, -4), S(-3, 56), }}, - {{ S(-2, 160), S(-21, -235), S(-21, -4), S(-8, 55), S(-8, 77), S(-19, -12), S(-19, -225), }}, - {{ S(-4, 139), S(-9, -221), S(-10, 131), S(-4, 111), S(-3, 110), S(-10, 136), S(-8, -200), }}, - {{ S(6, 124), S(-11, 85), S(0, 95), S(7, 77), S(5, 79), S(-2, 93), S(-8, 85), }}, + {{ S(17, 25), S(-5, 28), S(-3, -46), S(8, -30), S(8, -22), S(-10, 14), S(-20, 15), }}, + {{ S(-2, 116), S(-20, -238), S(-20, -49), S(-8, 30), S(-9, 54), S(-22, 89), S(-36, 90), }}, + {{ S(-3, 99), S(-8, -207), S(-8, 91), S(-2, 69), S(-3, 63), S(-13, 70), S(-38, 81), }}, + {{ S(5, 110), S(-10, 75), S(-1, 84), S(6, 67), S(3, 56), S(7, 73), S(1, 76), }}, }}; inline const std::array BLOCKED_SHELTER_STORM = { - S(0, 0), S(0, 0), S(9, 61), S(-11, 47), S(-11, 73), S(-1, 78), S(3, 37), + S(0, 0), S(0, 0), S(15, 106), S(-8, 67), S(-10, 88), S(-1, 101), S(14, 69), }; inline const std::array, 4> SHELTER_STORM = {{ - {{ S(2, 116), S(-9, 41), S(-9, 43), S(-6, 37), S(-7, 28), S(-8, 41), S(-9, 49), }}, - {{ S(9, 9), S(1, -24), S(-9, -16), S(-3, -54), S(-4, -51), S(-7, -15), S(1, -19), }}, - {{ S(0, 59), S(-4, 36), S(-7, 40), S(-4, 33), S(-3, 17), S(-8, 37), S(-4, 27), }}, - {{ S(-1, 54), S(-7, 37), S(-11, 37), S(-5, 42), S(-4, 41), S(-10, 32), S(-9, 38), }}, + {{ S(3, 132), S(-51, -346), S(-11, -281), S(8, -316), S(-5, 56), S(-10, 79), S(-9, 82), }}, + {{ S(9, 50), S(-29, -460), S(-9, -163), S(-3, -46), S(-2, 8), S(-9, 32), S(1, 28), }}, + {{ S(0, 72), S(-12, -313), S(5, -13), S(3, 2), S(-4, 35), S(-9, 58), S(-4, 52), }}, + {{ S(-1, 64), S(-2, -98), S(7, -14), S(6, 26), S(-6, 43), S(-13, 53), S(-8, 55), }}, }}; inline TunableSigmoid<32> KING_SAFETY_ACTIVATION( - 1056, 267, -15, 92 + 1051, 284, -14, 72 ); -inline VParam WINNABLE_PAWNS = V(-24); -inline VParam WINNABLE_SYM = V(126); +inline VParam WINNABLE_PAWNS = V(-23); +inline VParam WINNABLE_SYM = V(125); inline VParam WINNABLE_ASYM = V(108); -inline VParam WINNABLE_PAWN_ENDGAME = V(191); -inline VParam WINNABLE_BIAS = V(-487); +inline VParam WINNABLE_PAWN_ENDGAME = V(193); +inline VParam WINNABLE_BIAS = V(-490); -// Epoch duration: 5.23206s +// Epoch duration: 4.71661s // clang-format on } // namespace Clockwork From 2728de817e4fc82e6073bea9e8d10c6bd32f9215 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Wed, 6 May 2026 08:39:25 +0200 Subject: [PATCH 4/4] Bench: 14793132 --- src/board.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/board.hpp b/src/board.hpp index 727e35c0..80a41c25 100644 --- a/src/board.hpp +++ b/src/board.hpp @@ -55,7 +55,7 @@ struct PieceMask { } [[nodiscard]] PieceId msb() const { - return PieceId{static_cast(std::countl_zero(m_raw))}; + return PieceId{static_cast(std::bit_width(m_raw) - 1)}; } [[nodiscard]] PieceId lsb() const {