diff --git a/src/eval_constants.hpp b/src/eval_constants.hpp index 8ee54738..048b1ef2 100644 --- a/src/eval_constants.hpp +++ b/src/eval_constants.hpp @@ -5,183 +5,170 @@ namespace Clockwork { // clang-format off -inline const PParam PAWN_MAT = S(178, 136); -inline const PParam KNIGHT_MAT = S(720, 311); -inline const PParam BISHOP_MAT = S(766, 318); -inline const PParam ROOK_MAT = S(667, 346); -inline const PParam QUEEN_MAT = S(2146, -863); -inline const PParam TEMPO_VAL = S(65, 12); +inline const PParam PAWN_MAT = S(172, 149); +inline const PParam KNIGHT_MAT = S(680, 428); +inline const PParam BISHOP_MAT = S(746, 446); +inline const PParam ROOK_MAT = S(610, 479); +inline const PParam QUEEN_MAT = S(1415, 722); +inline const PParam TEMPO_VAL = S(64, 13); -inline const PParam BISHOP_PAIR_VAL = S(80, 143); -inline const PParam ROOK_OPEN_VAL = S(109, -23); -inline const PParam ROOK_SEMIOPEN_VAL = S(43, 9); +inline const PParam BISHOP_PAIR_VAL = S(78, 160); +inline const PParam ROOK_OPEN_VAL = S(107, -23); +inline const PParam ROOK_SEMIOPEN_VAL = S(44, 16); -inline const PParam DOUBLED_PAWN_VAL = S(-34, -60); +inline const PParam DOUBLED_PAWN_VAL = S(-27, -74); -inline const PParam POTENTIAL_CHECKER_VAL = S(-63, -3); -inline const PParam OUTPOST_KNIGHT_VAL = S(46, 47); -inline const PParam OUTPOST_BISHOP_VAL = S(56, 28); +inline const PParam POTENTIAL_CHECKER_VAL = S(-59, -7); +inline const PParam OUTPOST_KNIGHT_VAL = S(44, 45); +inline const PParam OUTPOST_BISHOP_VAL = S(56, 29); -inline const PParam PAWN_PUSH_THREAT_KNIGHT = S(46, 9); -inline const PParam PAWN_PUSH_THREAT_BISHOP = S(57, -22); -inline const PParam PAWN_PUSH_THREAT_ROOK = S(34, 44); -inline const PParam PAWN_PUSH_THREAT_QUEEN = S(70, -60); +inline const PParam PAWN_PUSH_THREAT_KNIGHT = S(45, 5); +inline const PParam PAWN_PUSH_THREAT_BISHOP = S(55, -23); +inline const PParam PAWN_PUSH_THREAT_ROOK = S(34, 39); +inline const PParam PAWN_PUSH_THREAT_QUEEN = S(68, -49); inline const std::array PAWN_PHALANX = { - S(20, 21), S(52, 35), S(71, 64), S(173, 139), S(498, 162), S(659, 571), + S(23, 12), S(54, 35), S(69, 68), S(166, 149), S(481, 182), S(668, 632), }; inline const std::array DEFENDED_PAWN = { - S(67, 42), S(57, 33), S(73, 61), S(164, 117), S(565, -7), + S(68, 39), S(56, 36), S(70, 65), S(162, 119), S(563, -12), }; inline const std::array PASSED_PAWN = { - S(-91, -98), S(-83, -79), S(-49, 0), S(19, 82), S(119, 194), S(334, 251), + S(-93, -100), S(-84, -80), S(-49, 1), S(20, 84), S(113, 206), S(318, 280), }; inline const std::array DEFENDED_PASSED_PUSH = { - S(33, -32), S(33, -6), S(26, 22), S(18, 75), S(80, 144), S(160, 234), + S(36, -34), S(35, -6), S(27, 20), S(21, 70), S(87, 138), S(182, 234), }; inline const std::array BLOCKED_PASSED_PAWN = { - S(17, -29), S(3, 11), S(-2, -14), S(-10, -35), S(-25, -87), S(-265, -123), + S(20, -33), S(3, 7), S(-2, -17), S(-9, -39), S(-26, -82), S(-274, -107), }; inline const std::array FRIENDLY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(33, 81), S(2, 80), S(-8, 39), S(-10, 17), S(-9, 18), S(24, 16), S(2, -4), + S(0, 0), S(14, 110), S(-8, 90), S(-11, 38), S(-7, 8), S(-1, 5), S(35, 2), S(8, -6), }; inline const std::array ENEMY_KING_PASSED_PAWN_DISTANCE = { - S(0, 0), S(-305, -42), S(-13, -1), S(-6, 35), S(20, 74), S(33, 92), S(45, 101), S(23, 91), + S(0, 0), S(-337, -8), S(-33, 19), S(-12, 43), S(23, 72), S(37, 87), S(51, 91), S(26, 87), }; inline const std::array KNIGHT_MOBILITY = { - S(91, -101), S(180, 69), S(224, 148), S(258, 186), S(302, 201), S(329, 237), S(363, 234), S(398, 239), S(446, 178), + S(90, -35), S(179, 134), S(225, 207), S(259, 241), S(304, 253), S(332, 287), S(366, 281), S(402, 285), S(449, 225), }; inline const std::array BISHOP_MOBILITY = { - S(112, -145), S(167, 60), S(232, 128), S(264, 174), S(291, 208), S(309, 230), S(318, 249), S(333, 257), S(345, 269), S(365, 258), S(382, 251), S(432, 212), S(438, 212), S(497, 163), + S(102, -77), S(159, 118), S(225, 176), S(258, 219), S(285, 251), S(305, 271), S(315, 287), S(331, 294), S(343, 306), S(363, 296), S(380, 289), S(429, 251), S(437, 249), S(490, 208), }; inline const std::array ROOK_MOBILITY = { - S(341, 106), S(287, 272), S(315, 295), S(334, 304), S(346, 319), S(353, 330), S(360, 341), S(370, 342), S(377, 350), S(388, 351), S(401, 350), S(411, 349), S(419, 347), S(438, 329), S(541, 240), + S(342, 162), S(284, 327), S(312, 347), S(331, 354), S(344, 366), S(352, 376), S(360, 384), S(370, 384), S(379, 389), S(390, 389), S(404, 387), S(415, 385), S(422, 384), S(436, 370), S(537, 280), }; inline const std::array QUEEN_MOBILITY = { - S(699, -223), S(812, -148), S(845, -52), S(867, 65), S(882, 123), S(895, 165), S(902, 199), S(912, 205), S(917, 228), S(923, 236), S(929, 245), S(935, 247), S(944, 240), S(947, 245), S(952, 240), S(953, 238), S(955, 234), S(959, 229), S(966, 215), S(981, 198), S(997, 173), S(1024, 140), S(1058, 103), S(1155, 4), S(1199, -43), S(1262, -85), S(1296, -120), S(1232, -100), + S(647, 206), S(753, 306), S(786, 404), S(808, 519), S(824, 576), S(836, 618), S(843, 653), S(852, 660), S(857, 684), S(862, 694), S(867, 703), S(873, 705), S(882, 699), S(885, 703), S(888, 698), S(890, 696), S(891, 692), S(896, 686), S(903, 672), S(919, 655), S(935, 629), S(963, 596), S(999, 556), S(1092, 460), S(1141, 408), S(1199, 371), S(1227, 340), S(1178, 350), }; inline const std::array KING_MOBILITY = { - S(558, -139), S(126, -70), S(39, 8), S(26, 26), S(4, 12), S(-21, 6), S(-22, 0), S(-40, -3), S(-43, -47), -}; - -inline const std::array KNIGHT_KING_RING = { - S(-7, 32), S(20, 38), S(30, 40), -}; -inline const std::array BISHOP_KING_RING = { - S(-4, 35), S(-6, 17), S(-9, -1), -}; -inline const std::array ROOK_KING_RING = { - S(-5, 43), S(16, 56), S(16, 63), S(23, 78), S(399, 63), -}; -inline const std::array QUEEN_KING_RING = { - S(438, 551), S(299, 327), S(162, 173), S(29, 70), S(-94, 59), S(-232, 48), + S(526, -212), S(122, -134), S(36, -46), S(24, -8), S(1, -0), S(-23, 6), S(-25, 18), S(-41, 27), S(-41, -6), }; inline const std::array PT_INNER_RING_ATTACKS = { - S(13, 4), S(1, -2), S(19, 20), S(-4, -11), S(137, 183), + S(11, -12), S(16, -17), S(14, -13), S(6, -9), S(3, 213), }; inline const std::array PT_OUTER_RING_ATTACKS = { - S(2, 2), S(8, 1), S(7, -0), S(6, 0), S(7, 265), + S(3, -2), S(7, -10), S(6, -8), S(6, -6), S(7, 464), }; -inline const PParam PAWN_THREAT_KNIGHT = S(240, 69); -inline const PParam PAWN_THREAT_BISHOP = S(215, 116); -inline const PParam PAWN_THREAT_ROOK = S(216, 97); -inline const PParam PAWN_THREAT_QUEEN = S(191, -54); +inline const PParam PAWN_THREAT_KNIGHT = S(237, 68); +inline const PParam PAWN_THREAT_BISHOP = S(215, 117); +inline const PParam PAWN_THREAT_ROOK = S(217, 87); +inline const PParam PAWN_THREAT_QUEEN = S(185, -46); -inline const PParam KNIGHT_THREAT_BISHOP = S(123, 78); -inline const PParam KNIGHT_THREAT_ROOK = S(255, 22); -inline const PParam KNIGHT_THREAT_QUEEN = S(169, -47); +inline const PParam KNIGHT_THREAT_BISHOP = S(124, 73); +inline const PParam KNIGHT_THREAT_ROOK = S(257, 16); +inline const PParam KNIGHT_THREAT_QUEEN = S(169, -43); -inline const PParam BISHOP_THREAT_KNIGHT = S(117, 51); -inline const PParam BISHOP_THREAT_ROOK = S(247, 80); -inline const PParam BISHOP_THREAT_QUEEN = S(204, 52); +inline const PParam BISHOP_THREAT_KNIGHT = S(117, 41); +inline const PParam BISHOP_THREAT_ROOK = S(247, 72); +inline const PParam BISHOP_THREAT_QUEEN = S(202, 52); inline const std::array BISHOP_PAWNS = { - S(3, -22), S(-4, -11), S(-5, -21), S(-10, -28), S(-16, -32), S(-22, -34), S(-26, -43), S(-33, -41), S(-45, -41), + S(3, -22), S(-4, -9), S(-5, -19), S(-11, -26), S(-17, -31), S(-23, -35), S(-27, -44), S(-33, -43), S(-45, -41), }; -inline const PParam ROOK_LINEUP = S(13, 79); +inline const PParam ROOK_LINEUP = S(13, 73); inline const std::array PAWN_PSQT = { - S(347, 247), S(227, 318), S(352, 291), S(316, 229), S(338, 184), S(271, 244), S(212, 272), S(307, 222), // - S(146, 157), S(208, 180), S(217, 128), S(187, 93), S(166, 79), S(146, 113), S(135, 150), S(79, 165), // - S(105, 133), S(110, 133), S(132, 82), S(122, 70), S(109, 68), S(83, 93), S(51, 136), S(33, 151), // - S(70, 105), S(82, 123), S(96, 84), S(84, 82), S(61, 85), S(50, 103), S(9, 145), S(-5, 128), // - S(61, 79), S(121, 80), S(95, 103), S(79, 103), S(49, 108), S(27, 110), S(11, 129), S(-9, 111), // - S(81, 82), S(190, 91), S(166, 134), S(112, 132), S(80, 129), S(59, 123), S(45, 137), S(11, 128), // + S(313, 289), S(187, 372), S(317, 340), S(335, 212), S(361, 162), S(281, 236), S(222, 266), S(309, 223), // + S(129, 184), S(185, 216), S(209, 136), S(202, 82), S(178, 69), S(150, 114), S(135, 153), S(75, 174), // + S(94, 149), S(97, 150), S(128, 76), S(129, 62), S(116, 63), S(85, 95), S(52, 138), S(29, 159), // + S(63, 111), S(71, 132), S(93, 76), S(92, 69), S(69, 74), S(54, 99), S(11, 142), S(-6, 132), // + S(54, 88), S(109, 96), S(84, 119), S(81, 104), S(52, 105), S(29, 110), S(12, 128), S(-11, 116), // + S(73, 93), S(180, 105), S(161, 145), S(117, 131), S(85, 125), S(61, 123), S(45, 137), S(9, 133), // }; inline const std::array KNIGHT_PSQT = { - S(-300, -6), S(-205, 220), S(-271, 219), S(48, 175), S(-11, 171), S(-134, 172), S(-312, 228), S(-356, 67), // - S(85, 156), S(155, 145), S(233, 98), S(219, 118), S(204, 136), S(154, 129), S(116, 160), S(72, 152), // - S(182, 119), S(228, 126), S(247, 150), S(234, 148), S(203, 162), S(152, 176), S(160, 135), S(112, 147), // - S(245, 139), S(267, 140), S(260, 159), S(252, 179), S(254, 186), S(208, 180), S(206, 156), S(186, 142), // - S(246, 134), S(278, 116), S(261, 150), S(256, 165), S(233, 174), S(227, 166), S(217, 133), S(185, 137), // - S(183, 110), S(215, 108), S(206, 139), S(220, 159), S(217, 157), S(176, 143), S(166, 113), S(131, 92), // - S(194, 114), S(216, 112), S(192, 107), S(196, 126), S(185, 125), S(153, 90), S(147, 111), S(111, 54), // - S(127, 84), S(173, 123), S(192, 108), S(207, 103), S(191, 113), S(152, 92), S(139, 111), S(91, 48), // + S(-277, 34), S(-179, 217), S(-272, 287), S(94, 180), S(36, 176), S(-96, 170), S(-272, 213), S(-340, 107), // + S(103, 160), S(166, 159), S(244, 121), S(242, 139), S(228, 156), S(160, 149), S(126, 171), S(88, 147), // + S(196, 130), S(232, 160), S(250, 184), S(244, 181), S(219, 187), S(155, 204), S(168, 151), S(125, 150), // + S(265, 152), S(275, 164), S(275, 189), S(268, 212), S(271, 212), S(221, 204), S(214, 171), S(204, 147), // + S(250, 152), S(280, 142), S(261, 183), S(256, 200), S(234, 204), S(229, 191), S(222, 148), S(190, 148), // + S(183, 132), S(212, 131), S(203, 165), S(216, 187), S(215, 184), S(174, 170), S(165, 134), S(132, 112), // + S(196, 121), S(220, 123), S(190, 128), S(195, 147), S(184, 146), S(152, 113), S(151, 121), S(117, 61), // + S(127, 103), S(174, 156), S(194, 118), S(209, 111), S(194, 126), S(155, 106), S(140, 133), S(90, 77), // }; inline const std::array BISHOP_PSQT = { - S(8, 254), S(-8, 247), S(-262, 292), S(-168, 271), S(-151, 286), S(-213, 298), S(-72, 294), S(31, 259), // - S(147, 173), S(104, 229), S(123, 200), S(60, 230), S(63, 234), S(108, 223), S(143, 211), S(116, 206), // - S(222, 180), S(239, 190), S(236, 204), S(207, 198), S(177, 200), S(189, 201), S(212, 197), S(187, 181), // - S(196, 171), S(229, 182), S(229, 196), S(230, 225), S(259, 211), S(187, 200), S(197, 178), S(154, 184), // - S(219, 134), S(241, 157), S(249, 181), S(254, 197), S(233, 209), S(212, 200), S(173, 183), S(167, 152), // - S(246, 134), S(285, 146), S(299, 165), S(248, 192), S(238, 178), S(232, 182), S(239, 161), S(178, 166), // - S(223, 106), S(314, 114), S(276, 131), S(244, 152), S(224, 155), S(226, 131), S(223, 129), S(216, 120), // - S(243, 117), S(230, 142), S(237, 158), S(248, 136), S(244, 136), S(244, 169), S(237, 149), S(222, 138), // + S(13, 276), S(-5, 267), S(-261, 312), S(-162, 288), S(-152, 307), S(-213, 320), S(-70, 314), S(29, 281), // + S(148, 190), S(102, 253), S(121, 225), S(58, 256), S(62, 258), S(105, 244), S(140, 230), S(118, 213), // + S(221, 201), S(235, 218), S(235, 230), S(209, 222), S(181, 219), S(188, 222), S(208, 214), S(187, 191), // + S(199, 190), S(226, 207), S(230, 224), S(232, 251), S(264, 232), S(190, 222), S(194, 195), S(156, 195), // + S(217, 157), S(237, 185), S(243, 206), S(251, 224), S(231, 234), S(208, 223), S(173, 203), S(166, 168), // + S(243, 161), S(279, 172), S(293, 190), S(240, 219), S(233, 202), S(227, 208), S(234, 184), S(176, 188), // + S(219, 127), S(309, 142), S(269, 155), S(237, 178), S(217, 181), S(219, 157), S(217, 159), S(212, 145), // + S(236, 144), S(225, 169), S(232, 190), S(245, 152), S(240, 155), S(238, 199), S(232, 176), S(216, 167), // }; inline const std::array ROOK_PSQT = { - S(457, 303), S(506, 300), S(458, 321), S(465, 307), S(466, 297), S(436, 304), S(431, 315), S(413, 329), // - S(357, 350), S(448, 332), S(511, 314), S(450, 333), S(444, 335), S(426, 337), S(359, 364), S(338, 371), // - S(338, 344), S(458, 307), S(491, 301), S(472, 299), S(441, 312), S(395, 335), S(395, 334), S(322, 372), // - S(327, 329), S(415, 320), S(446, 308), S(430, 309), S(421, 316), S(377, 340), S(364, 340), S(295, 363), // - S(295, 288), S(364, 290), S(359, 308), S(340, 308), S(323, 322), S(310, 341), S(281, 337), S(260, 334), // - S(276, 245), S(341, 254), S(335, 279), S(323, 275), S(317, 276), S(289, 303), S(279, 289), S(243, 297), // - S(184, 258), S(306, 212), S(323, 235), S(322, 246), S(311, 248), S(296, 258), S(277, 244), S(246, 258), // - S(236, 242), S(262, 255), S(321, 245), S(336, 237), S(325, 243), S(307, 256), S(293, 252), S(272, 269), // + S(493, 321), S(537, 323), S(486, 344), S(492, 331), S(491, 321), S(461, 327), S(459, 338), S(447, 348), // + S(381, 383), S(476, 362), S(544, 338), S(486, 351), S(477, 355), S(455, 359), S(384, 389), S(362, 397), // + S(354, 373), S(478, 337), S(516, 325), S(494, 320), S(457, 334), S(413, 358), S(413, 358), S(337, 397), // + S(344, 351), S(432, 346), S(462, 333), S(443, 332), S(435, 338), S(394, 358), S(382, 356), S(310, 380), // + S(312, 310), S(381, 315), S(375, 330), S(352, 333), S(337, 344), S(329, 358), S(301, 351), S(278, 350), // + S(291, 272), S(359, 280), S(350, 302), S(336, 300), S(331, 299), S(307, 323), S(298, 307), S(261, 316), // + S(199, 288), S(324, 239), S(337, 261), S(333, 274), S(323, 275), S(311, 283), S(294, 268), S(263, 285), // + S(248, 285), S(275, 296), S(335, 268), S(351, 261), S(339, 270), S(321, 286), S(307, 283), S(285, 302), // }; inline const std::array QUEEN_PSQT = { - S(642, 236), S(690, 207), S(661, 252), S(617, 329), S(627, 296), S(619, 288), S(644, 220), S(571, 285), // - S(641, 287), S(613, 367), S(600, 403), S(464, 486), S(472, 474), S(530, 430), S(565, 332), S(574, 305), // - S(615, 317), S(676, 328), S(615, 407), S(567, 434), S(539, 429), S(565, 388), S(615, 294), S(609, 249), // - S(656, 257), S(673, 312), S(614, 381), S(600, 429), S(585, 432), S(584, 361), S(633, 274), S(617, 244), // - S(656, 247), S(660, 285), S(632, 346), S(598, 399), S(596, 394), S(598, 344), S(609, 278), S(627, 212), // - S(632, 200), S(668, 236), S(667, 292), S(634, 293), S(626, 291), S(628, 300), S(635, 231), S(614, 205), // - S(612, 97), S(643, 94), S(653, 146), S(667, 181), S(653, 209), S(646, 182), S(615, 214), S(621, 188), // - S(585, 102), S(616, -33), S(638, -35), S(657, 58), S(659, 122), S(655, 81), S(645, 102), S(606, 143), // + S(658, 511), S(707, 480), S(674, 531), S(624, 616), S(634, 584), S(630, 568), S(658, 494), S(586, 558), // + S(652, 570), S(622, 652), S(603, 690), S(460, 781), S(469, 768), S(537, 713), S(577, 611), S(586, 587), // + S(626, 608), S(678, 626), S(618, 706), S(565, 739), S(539, 730), S(571, 681), S(620, 587), S(620, 537), // + S(660, 541), S(674, 604), S(614, 672), S(599, 718), S(586, 721), S(585, 653), S(639, 562), S(624, 531), // + S(665, 522), S(667, 560), S(640, 622), S(607, 675), S(606, 668), S(607, 622), S(619, 556), S(641, 484), // + S(647, 462), S(682, 504), S(683, 562), S(649, 562), S(643, 558), S(644, 570), S(652, 501), S(629, 476), // + S(629, 359), S(664, 354), S(672, 414), S(688, 450), S(673, 478), S(664, 448), S(633, 484), S(638, 464), // + S(602, 380), S(637, 228), S(658, 239), S(678, 336), S(680, 394), S(676, 351), S(664, 376), S(623, 426), // }; inline const std::array KING_PSQT = { - S(-346, -254), S(144, 88), S(131, 36), S(-166, 25), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(175, -89), S(281, 118), S(153, 126), S(75, 55), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(110, 27), S(321, 95), S(229, 99), S(100, 64), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-79, 24), S(217, 79), S(64, 99), S(-4, 98), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-141, 9), S(121, 57), S(44, 81), S(-72, 122), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-65, -17), S(163, 19), S(52, 57), S(3, 83), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(18, -62), S(112, 9), S(24, 27), S(-35, 48), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // - S(-102, -121), S(10, -57), S(-82, -62), S(-92, -98), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-255, -270), S(223, 76), S(143, 49), S(-161, 29), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(280, -109), S(357, 81), S(187, 100), S(86, 9), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(203, 27), S(419, 52), S(286, 66), S(136, 6), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-8, 30), S(315, 28), S(137, 51), S(50, 25), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-94, 21), S(206, 7), S(135, 16), S(25, 18), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-61, 23), S(194, -4), S(99, 12), S(69, -15), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-2, -5), S(90, 21), S(2, 32), S(-46, 2), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // + S(-125, -32), S(-11, -13), S(-113, 3), S(-122, -62), S(0, 0), S(0, 0), S(0, 0), S(0, 0), // }; inline const std::array, 4> KING_SHELTER = {{ - {{ S(-44, -32), S(-59, -32), S(-67, -33), S(-59, -34), S(-59, -34), S(-65, -33), S(-57, -32), }}, - {{ S(-56, -35), S(-83, -36), S(-81, -38), S(-72, -41), S(-71, -39), S(-80, -37), S(-81, -35), }}, - {{ S(-72, -47), S(-83, -46), S(-82, -49), S(-78, -52), S(-78, -51), S(-80, -49), S(-81, -46), }}, - {{ S(-56, -34), S(-76, -40), S(-67, -40), S(-63, -39), S(-64, -39), S(-68, -40), S(-72, -38), }}, + {{ S(18, -25), S(-0, 8), S(-6, 16), S(2, 2), S(2, 1), S(-5, 16), S(1, 14), }}, + {{ S(8, -7), S(-22, 32), S(-19, 27), S(-10, 6), S(-10, 9), S(-18, 34), S(-21, 45), }}, + {{ S(-10, 1), S(-23, 26), S(-22, 9), S(-19, -7), S(-18, -5), S(-21, 10), S(-21, 25), }}, + {{ S(4, -14), S(-15, -21), S(-7, -22), S(-2, -25), S(-3, -23), S(-8, -18), S(-11, -16), }}, }}; inline const std::array BLOCKED_SHELTER_STORM = { - S(0, 0), S(0, 0), S(-38, -24), S(-64, -29), S(-63, -29), S(-54, -30), S(-62, -32), + S(0, 0), S(0, 0), S(5, 19), S(-20, 34), S(-18, 23), S(-11, 10), S(-14, -3), }; inline const std::array, 4> SHELTER_STORM = {{ - {{ S(-50, -30), S(-63, -29), S(-62, -29), S(-60, -29), S(-62, -30), S(-60, -29), S(-63, -29), }}, - {{ S(-49, -30), S(-59, -29), S(-67, -28), S(-62, -32), S(-63, -32), S(-65, -28), S(-59, -28), }}, - {{ S(-55, -33), S(-62, -31), S(-63, -30), S(-57, -30), S(-57, -31), S(-63, -30), S(-61, -30), }}, - {{ S(-56, -34), S(-66, -31), S(-67, -32), S(-58, -30), S(-57, -30), S(-67, -31), S(-68, -31), }}, + {{ S(-7, 11), S(-17, 17), S(-16, 16), S(-15, 10), S(-16, 6), S(-14, 6), S(-17, 14), }}, + {{ S(-6, 9), S(-14, 14), S(-21, 21), S(-18, 9), S(-17, 7), S(-20, 16), S(-14, 13), }}, + {{ S(-12, 10), S(-17, 3), S(-17, 11), S(-13, 10), S(-13, 7), S(-17, 9), S(-16, 5), }}, + {{ S(-13, 11), S(-19, 11), S(-20, 10), S(-14, 14), S(-13, 14), S(-19, 9), S(-21, 9), }}, }}; inline TunableSigmoid<32> KING_SAFETY_ACTIVATION( - 895, 2096, -126, 37 + 1088, 417, -28, 45 ); -// Epoch duration: 9.86598s +// Epoch duration: 9.05276s // clang-format on } // namespace Clockwork diff --git a/src/eval_types.hpp b/src/eval_types.hpp index 6a30cd93..9228f486 100644 --- a/src/eval_types.hpp +++ b/src/eval_types.hpp @@ -179,11 +179,11 @@ class TunableSigmoid { #else class TunableSigmoid { private: - static constexpr i32 TABLE_SIZE = 256; - static constexpr i32 FP_SHIFT = 16; - static constexpr i32 FP_ONE = 1 << FP_SHIFT; - static constexpr f64 B = static_cast(B_SCALE); - static constexpr f64 LN_39 = 3.6635616461296463; + static constexpr usize TABLE_SIZE = 256; + static constexpr i32 FP_SHIFT = 16; + static constexpr i32 FP_ONE = 1 << FP_SHIFT; + static constexpr f64 B = static_cast(B_SCALE); + static constexpr f64 LN_39 = 3.6635616461296463; struct Table { i32 range_min; @@ -216,7 +216,7 @@ class TunableSigmoid { tbl.scale_fp = static_cast((static_cast(TABLE_SIZE - 1) << FP_SHIFT) / tbl.range_span); - for (i32 i = 0; i < TABLE_SIZE; ++i) { + for (usize i = 0; i < TABLE_SIZE; ++i) { const f64 t = static_cast(i) / (TABLE_SIZE - 1); const f64 x = tbl.range_min + t * tbl.range_span; const f64 z = (x + c) / B; @@ -230,8 +230,8 @@ class TunableSigmoid { const i32 x = std::clamp(static_cast(x_val), tbl.range_min, tbl.range_max); const i64 idx_fp = static_cast(x - tbl.range_min) * tbl.scale_fp; - const i32 idx = static_cast(idx_fp >> FP_SHIFT); - const i32 frac = static_cast(idx_fp & (FP_ONE - 1)); + const usize idx = static_cast(idx_fp >> FP_SHIFT); + const i32 frac = static_cast(idx_fp & (FP_ONE - 1)); const i32 v0 = tbl.values[idx]; const i32 v1 = tbl.values[std::min(idx + 1, TABLE_SIZE - 1)]; diff --git a/src/evaltune_main.cpp b/src/evaltune_main.cpp index ba981f70..b5bfa944 100644 --- a/src/evaltune_main.cpp +++ b/src/evaltune_main.cpp @@ -324,11 +324,6 @@ int main() { print_table("KING_MOBILITY", KING_MOBILITY); std::cout << std::endl; - print_table("KNIGHT_KING_RING", KNIGHT_KING_RING); - print_table("BISHOP_KING_RING", BISHOP_KING_RING); - print_table("ROOK_KING_RING", ROOK_KING_RING); - print_table("QUEEN_KING_RING", QUEEN_KING_RING); - std::cout << std::endl; print_table("PT_INNER_RING_ATTACKS", PT_INNER_RING_ATTACKS); print_table("PT_OUTER_RING_ATTACKS", PT_OUTER_RING_ATTACKS); std::cout << std::endl; diff --git a/src/evaluation.cpp b/src/evaluation.cpp index 0e3a05af..17097633 100644 --- a/src/evaluation.cpp +++ b/src/evaluation.cpp @@ -222,11 +222,10 @@ PScore evaluate_pawn_push_threats(const Position& pos) { } template -std::pair evaluate_pieces(const Position& pos) { - constexpr Color opp = ~color; - PScore eval = PSCORE_ZERO; - PScore king_safety_score = PSCORE_ZERO; - Bitboard own_pawns = pos.bitboard_for(color, PieceType::Pawn); +PScore evaluate_pieces(const Position& pos) { + constexpr Color opp = ~color; + PScore eval = PSCORE_ZERO; + Bitboard own_pawns = pos.bitboard_for(color, PieceType::Pawn); Bitboard blocked_pawns = own_pawns & pos.board().get_occupied_bitboard().shift_relative(color, Direction::South); constexpr Bitboard early_ranks = color == Color::White @@ -235,14 +234,11 @@ std::pair evaluate_pieces(const Position& pos) { Bitboard own_early_pawns = own_pawns & early_ranks; Bitboard bb = (blocked_pawns | own_early_pawns) | pos.attacked_by(opp, PieceType::Pawn); Bitboard bb2 = bb; - Bitboard opp_king_ring = king_ring_table[pos.king_sq(opp).raw]; for (PieceId id : pos.get_piece_mask(color, PieceType::Knight)) { eval += KNIGHT_MOBILITY[pos.mobility_of(color, id, ~bb)]; - king_safety_score += KNIGHT_KING_RING[pos.mobility_of(color, id, opp_king_ring)]; } for (PieceId id : pos.get_piece_mask(color, PieceType::Bishop)) { eval += BISHOP_MOBILITY[pos.mobility_of(color, id, ~bb)]; - king_safety_score += BISHOP_KING_RING[pos.mobility_of(color, id, opp_king_ring)]; Square sq = pos.piece_list_sq(color)[id]; eval += BISHOP_PAWNS[std::min( static_cast(8), @@ -256,7 +252,6 @@ std::pair evaluate_pieces(const Position& pos) { for (PieceId id : pos.get_piece_mask(color, PieceType::Rook)) { eval += ROOK_MOBILITY[pos.mobility_of(color, id, ~bb)]; eval += ROOK_MOBILITY[pos.mobility_of(color, id, ~bb2)]; - king_safety_score += ROOK_KING_RING[pos.mobility_of(color, id, opp_king_ring)]; // Rook lineups Bitboard rook_file = Bitboard::file_mask(pos.piece_list_sq(color)[id].file()); eval += ROOK_LINEUP @@ -269,7 +264,6 @@ std::pair evaluate_pieces(const Position& pos) { for (PieceId id : pos.get_piece_mask(color, PieceType::Queen)) { eval += QUEEN_MOBILITY[pos.mobility_of(color, id, ~bb)]; eval += QUEEN_MOBILITY[pos.mobility_of(color, id, ~bb2)]; - king_safety_score += QUEEN_KING_RING[pos.mobility_of(color, id, opp_king_ring)]; } eval += KING_MOBILITY[pos.mobility_of(color, PieceId::king(), ~bb)]; @@ -277,7 +271,7 @@ std::pair evaluate_pieces(const Position& pos) { eval += BISHOP_PAIR_VAL; } - return {eval, king_safety_score}; + return eval; } template @@ -430,12 +424,7 @@ Score evaluate_white_pov(const Position& pos, const PsqtState& psqt_state) { phase = std::min(phase, 24); PScore eval = psqt_state.score(); // Used for linear components - // Pieces - get king safety scores directly - auto [white_piece_score, white_king_attack] = evaluate_pieces(pos); - auto [black_piece_score, black_king_attack] = evaluate_pieces(pos); - eval += white_piece_score - black_piece_score; - - // Other linear components + eval += evaluate_pieces(pos) - evaluate_pieces(pos); eval += evaluate_pawns(pos) - evaluate_pawns(pos); eval += evaluate_pawn_push_threats(pos) - evaluate_pawn_push_threats(pos); @@ -446,8 +435,8 @@ Score evaluate_white_pov(const Position& pos, const PsqtState& psqt_state) { eval += evaluate_outposts(pos) - evaluate_outposts(pos); // Nonlinear king safety components - PScore white_king_attack_total = white_king_attack + evaluate_king_safety(pos); - PScore black_king_attack_total = black_king_attack + evaluate_king_safety(pos); + PScore white_king_attack_total = evaluate_king_safety(pos); + PScore black_king_attack_total = evaluate_king_safety(pos); // Nonlinear adjustment eval += king_safety_activation(pos, white_king_attack_total)