diff --git a/CHANGELOG.md b/CHANGELOG.md index 66cbfb0..5fd5caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] * Evaluate passed pawns (38.30 +- 13.27) +* Don't consider mobility for squares that are attacked by opponent pawns (14.90 +- 7.93) ## [5.0] diff --git a/src/engine/eval/mobility_and_king_safety.rs b/src/engine/eval/mobility_and_king_safety.rs index 803c5f6..988139d 100644 --- a/src/engine/eval/mobility_and_king_safety.rs +++ b/src/engine/eval/mobility_and_king_safety.rs @@ -11,30 +11,42 @@ fn mobility_and_opp_king_safety_for(game: &Game, player: Player) -> PhasedEval { let mut eval = PhasedEval::ZERO; let blockers = game.board.occupancy(); + let their_pawns = game.board.pawns(player.other()).forward(player.other()); + let their_pawn_attacks = their_pawns.west() | their_pawns.east(); + let mobility_safe_squares = !their_pawn_attacks; + let mut attacked_squares = Bitboard::EMPTY; for p in game.board.knights(player) { let moves = tables::knight_attacks(p); attacked_squares |= moves; - eval += KNIGHT_MOBILITY[moves.count() as usize]; + + let mobility_squares = (moves & mobility_safe_squares).count() as usize; + eval += KNIGHT_MOBILITY[mobility_squares]; } for p in game.board.bishops(player) { let moves = tables::bishop_attacks(p, blockers); attacked_squares |= moves; - eval += BISHOP_MOBILITY[moves.count() as usize]; + + let mobility_squares = (moves & mobility_safe_squares).count() as usize; + eval += BISHOP_MOBILITY[mobility_squares]; } for p in game.board.rooks(player) { let moves = tables::rook_attacks(p, blockers); attacked_squares |= moves; - eval += ROOK_MOBILITY[moves.count() as usize]; + + let mobility_squares = (moves & mobility_safe_squares).count() as usize; + eval += ROOK_MOBILITY[mobility_squares]; } for p in game.board.queens(player) { let moves = tables::bishop_attacks(p, blockers) | tables::rook_attacks(p, blockers); attacked_squares |= moves; - eval += QUEEN_MOBILITY[moves.count() as usize]; + + let mobility_squares = (moves & mobility_safe_squares).count() as usize; + eval += QUEEN_MOBILITY[mobility_squares]; } let enemy_king = game.board.king(player.other()).single(); diff --git a/src/engine/eval/params.rs b/src/engine/eval/params.rs index 351f9e1..3c092fc 100644 --- a/src/engine/eval/params.rs +++ b/src/engine/eval/params.rs @@ -10,179 +10,179 @@ pub const fn s(mg: i16, eg: i16) -> PhasedEval { pub type PieceSquareTableDefinition = [[PhasedEval; File::N]; Rank::N]; pub const PIECE_VALUES: [PhasedEval; 6] = [ - s( 116, 169), - s( 266, 316), - s( 280, 348), - s( 368, 603), - s( 755, 1150), + s( 101, 169), + s( 274, 329), + s( 283, 345), + s( 376, 603), + s( 771, 1148), s( 0, 0), ]; pub const PAWNS: PieceSquareTableDefinition = [ [s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0)], - [s( 7, 87), s( 26, 79), s( 13, 78), s( 31, 42), s( 19, 41), s( 9, 52), s( -36, 81), s( -58, 92)], - [s( -19, 22), s( 0, 24), s( 24, -15), s( 29, 8), s( 38, -31), s( 89, -27), s( 82, 22), s( 25, 7)], - [s( -37, 12), s( -5, 6), s( -11, -16), s( -5, -35), s( 23, -35), s( 10, -30), s( 24, -8), s( -6, -20)], - [s( -49, -6), s( -14, 1), s( -14, -23), s( 5, -25), s( 9, -28), s( -1, -27), s( 4, -14), s( -25, -31)], - [s( -46, -12), s( -19, -4), s( -18, -26), s( -11, -15), s( 6, -16), s( -7, -24), s( 25, -19), s( -12, -35)], - [s( -42, -7), s( -15, 0), s( -26, -19), s( -20, -4), s( -7, 2), s( 13, -18), s( 40, -20), s( -22, -35)], + [s( 8, 86), s( 24, 79), s( 7, 78), s( 24, 41), s( 11, 41), s( 4, 52), s( -36, 80), s( -55, 91)], + [s( -10, 20), s( -11, 26), s( 10, -12), s( 16, 9), s( 34, -29), s( 82, -28), s( 78, 23), s( 30, 8)], + [s( -34, 13), s( -13, 7), s( -17, -17), s( -17, -33), s( 11, -33), s( 9, -32), s( 13, -6), s( -2, -19)], + [s( -39, -8), s( -18, 2), s( -14, -25), s( 0, -28), s( 2, -29), s( -3, -27), s( 2, -14), s( -17, -32)], + [s( -40, -12), s( -11, -7), s( -18, -26), s( -10, -16), s( 10, -18), s( -11, -23), s( 31, -20), s( -8, -34)], + [s( -30, -9), s( -6, -2), s( -11, -23), s( -11, -10), s( 5, -2), s( 26, -20), s( 49, -21), s( -10, -37)], [s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0)], ]; pub const KNIGHTS: PieceSquareTableDefinition = [ - [s( -110, -62), s( -133, 3), s( -78, -11), s( -30, -22), s( 12, -17), s( -69, -48), s( -106, 8), s( -47, -91)], - [s( 1, 3), s( 7, -14), s( -1, -5), s( 17, -4), s( -14, -12), s( 65, -31), s( 5, -18), s( 43, -16)], - [s( 6, -24), s( 17, -7), s( 56, 41), s( 62, 46), s( 91, 31), s( 96, 19), s( 21, -10), s( 19, -30)], - [s( 10, -7), s( -12, 17), s( 39, 56), s( 71, 57), s( 32, 64), s( 69, 57), s( -20, 24), s( 50, -16)], - [s( -8, -3), s( -24, 5), s( 21, 55), s( 24, 57), s( 39, 62), s( 28, 45), s( -1, 3), s( 6, -18)], - [s( -32, -27), s( -38, -6), s( 6, 28), s( 17, 48), s( 35, 42), s( 15, 20), s( -10, -14), s( -8, -27)], - [s( -20, 3), s( -28, -19), s( -43, -10), s( -16, -10), s( -19, -9), s( -17, -17), s( -8, -33), s( 14, 14)], - [s( -36, 10), s( 6, -10), s( -36, -28), s( -14, -25), s( -10, -22), s( 0, -38), s( 9, -2), s( 9, -9)], + [s( -136, -49), s( -144, -11), s( -81, 4), s( -31, -7), s( 6, -2), s( -63, -32), s( -119, -5), s( -76, -77)], + [s( -4, -6), s( 5, 3), s( 34, -2), s( 47, -2), s( 22, -9), s( 95, -29), s( 13, -2), s( 39, -24)], + [s( 4, -8), s( 36, -5), s( 35, 16), s( 49, 19), s( 71, 7), s( 82, -7), s( 39, -8), s( 19, -12)], + [s( 12, 11), s( 12, 15), s( 31, 28), s( 69, 29), s( 34, 34), s( 59, 28), s( 5, 24), s( 53, 2)], + [s( -1, 18), s( 3, 6), s( 9, 28), s( 24, 29), s( 29, 35), s( 27, 18), s( 30, 6), s( 16, 11)], + [s( -27, -4), s( -14, -4), s( -10, 2), s( -8, 22), s( 12, 19), s( -8, -5), s( 12, -8), s( -6, -2)], + [s( -28, -2), s( -25, 1), s( -17, -11), s( 7, -6), s( 2, -7), s( 3, -13), s( -7, -9), s( -3, 15)], + [s( -81, 15), s( -8, -16), s( -38, -13), s( -17, -11), s( -11, -6), s( -8, -20), s( -6, -8), s( -37, 1)], ]; pub const BISHOPS: PieceSquareTableDefinition = [ - [s( -19, 9), s( -65, 23), s( -57, 14), s( -118, 29), s( -88, 21), s( -71, 9), s( -36, 11), s( -60, 6)], - [s( -16, -4), s( 2, -6), s( -9, -4), s( -33, 0), s( 2, -13), s( -14, -6), s( -20, 3), s( -20, -3)], - [s( 1, 17), s( 22, -1), s( 17, -4), s( 27, -14), s( 7, -7), s( 51, -1), s( 29, 1), s( 22, 20)], - [s( -4, 11), s( 3, 6), s( 13, -3), s( 30, 14), s( 22, 2), s( 18, 4), s( 6, 0), s( -8, 12)], - [s( -3, 7), s( -10, 7), s( -8, 6), s( 22, 3), s( 17, 2), s( -1, -3), s( -8, 3), s( 14, -8)], - [s( 7, 8), s( 8, 5), s( 8, 0), s( 6, -2), s( 10, 3), s( 10, -2), s( 14, -8), s( 29, -4)], - [s( 24, 12), s( 19, -10), s( 22, -22), s( 1, -5), s( 10, -7), s( 26, -16), s( 42, -2), s( 25, -12)], - [s( 11, -3), s( 30, 4), s( 19, -6), s( 0, -2), s( 12, -2), s( 7, 7), s( 29, -15), s( 34, -26)], + [s( -21, -1), s( -75, 14), s( -61, 7), s( -125, 22), s( -100, 14), s( -82, 0), s( -48, 3), s( -63, -6)], + [s( -15, -14), s( 1, -9), s( -12, -5), s( -27, 0), s( 0, -12), s( -16, -6), s( -23, 0), s( -14, -13)], + [s( -2, 8), s( 17, -5), s( 15, 0), s( 24, -10), s( 5, -1), s( 49, 3), s( 22, -1), s( 14, 11)], + [s( -11, 3), s( 8, 7), s( 14, 2), s( 36, 21), s( 26, 9), s( 21, 10), s( 10, 2), s( -14, 8)], + [s( -1, -2), s( -14, 8), s( -1, 14), s( 25, 12), s( 22, 11), s( 1, 5), s( -7, 6), s( 22, -16)], + [s( 6, 1), s( 14, 6), s( 7, 6), s( 13, 9), s( 14, 13), s( 11, 6), s( 15, -9), s( 30, -6)], + [s( 36, 12), s( 12, -13), s( 26, -17), s( 1, -4), s( 9, -1), s( 26, -14), s( 36, -5), s( 33, -10)], + [s( 14, -4), s( 35, 2), s( 17, -12), s( -3, -8), s( 6, -11), s( 3, 3), s( 29, -19), s( 42, -22)], ]; pub const ROOKS: PieceSquareTableDefinition = [ - [s( 17, 14), s( -15, 28), s( -19, 42), s( -30, 39), s( -14, 31), s( 20, 21), s( 23, 16), s( 51, 8)], - [s( 5, 17), s( -7, 33), s( 17, 39), s( 38, 27), s( 18, 28), s( 38, 15), s( 39, 5), s( 75, -9)], - [s( -17, 15), s( 16, 13), s( 6, 17), s( 8, 14), s( 44, -3), s( 41, -8), s( 107, -22), s( 65, -24)], - [s( -24, 17), s( -9, 12), s( -11, 21), s( -5, 15), s( -1, -3), s( 7, -9), s( 17, -10), s( 22, -18)], - [s( -41, 9), s( -42, 10), s( -32, 10), s( -18, 7), s( -16, 2), s( -35, 1), s( -8, -13), s( -20, -14)], - [s( -43, 3), s( -40, -2), s( -27, -5), s( -23, -2), s( -12, -10), s( -17, -19), s( 18, -42), s( -5, -36)], - [s( -42, -6), s( -32, -5), s( -10, -8), s( -10, -7), s( -4, -17), s( -4, -24), s( 12, -34), s( -19, -23)], - [s( -18, -5), s( -15, -7), s( -1, -1), s( 8, -6), s( 14, -16), s( 2, -12), s( 13, -23), s( -12, -23)], + [s( 8, 14), s( -19, 27), s( -28, 42), s( -38, 39), s( -21, 31), s( 17, 20), s( 18, 16), s( 44, 7)], + [s( -2, 15), s( -8, 31), s( 12, 37), s( 34, 25), s( 15, 26), s( 34, 14), s( 37, 4), s( 69, -10)], + [s( -15, 15), s( 24, 13), s( 18, 17), s( 26, 14), s( 58, -3), s( 58, -9), s( 114, -22), s( 71, -25)], + [s( -23, 19), s( -1, 13), s( 0, 22), s( 5, 17), s( 16, -1), s( 15, -8), s( 29, -10), s( 25, -17)], + [s( -41, 10), s( -40, 12), s( -29, 12), s( -15, 8), s( -15, 5), s( -34, 4), s( 0, -12), s( -18, -13)], + [s( -48, 2), s( -38, -3), s( -28, -6), s( -26, -2), s( -17, -9), s( -20, -19), s( 19, -42), s( -8, -36)], + [s( -49, -8), s( -36, -7), s( -14, -11), s( -13, -11), s( -7, -20), s( -9, -26), s( 8, -35), s( -26, -25)], + [s( -26, -10), s( -19, -10), s( -3, -5), s( 5, -9), s( 12, -19), s( -3, -16), s( 9, -25), s( -20, -26)], ]; pub const QUEENS: PieceSquareTableDefinition = [ - [s( -29, -2), s( -64, 29), s( -52, 62), s( -26, 48), s( -44, 57), s( -36, 58), s( 39, -27), s( -16, 15)], - [s( 6, -19), s( -33, 15), s( -35, 59), s( -50, 81), s( -68, 115), s( -18, 59), s( -25, 43), s( 45, 31)], - [s( 8, -19), s( -3, -10), s( -11, 30), s( -10, 45), s( -8, 61), s( 11, 47), s( 36, 10), s( 12, 27)], - [s( -9, -3), s( -7, 4), s( -13, 20), s( -18, 43), s( -17, 53), s( -4, 43), s( 6, 41), s( 12, 28)], - [s( 0, -13), s( -15, 16), s( -11, 6), s( -3, 27), s( -1, 23), s( -4, 17), s( 9, 13), s( 17, 8)], - [s( -3, -26), s( 5, -19), s( 2, -6), s( 2, -12), s( 9, -7), s( 12, -9), s( 25, -26), s( 21, -27)], - [s( 13, -38), s( 9, -42), s( 21, -50), s( 28, -45), s( 22, -36), s( 36, -77), s( 42, -109), s( 67, -130)], - [s( 7, -41), s( 9, -49), s( 21, -54), s( 30, -34), s( 26, -57), s( 4, -56), s( 33, -85), s( 29, -79)], + [s( -25, -16), s( -69, 25), s( -56, 61), s( -34, 51), s( -51, 58), s( -40, 52), s( 31, -30), s( -12, 0)], + [s( 8, -33), s( -35, 13), s( -40, 60), s( -54, 84), s( -73, 118), s( -21, 60), s( -29, 41), s( 53, 17)], + [s( 11, -23), s( -1, -8), s( -10, 40), s( -11, 56), s( -9, 71), s( 17, 53), s( 36, 13), s( 16, 23)], + [s( -6, -7), s( -3, 9), s( -15, 30), s( -18, 57), s( -17, 68), s( -3, 53), s( 11, 49), s( 18, 23)], + [s( 6, -20), s( -15, 18), s( -12, 19), s( -5, 40), s( -5, 41), s( -8, 33), s( 11, 17), s( 23, 6)], + [s( 0, -36), s( 6, -19), s( -5, 4), s( -4, 5), s( 2, 8), s( 8, -2), s( 24, -25), s( 27, -38)], + [s( 18, -52), s( 6, -47), s( 17, -48), s( 22, -43), s( 18, -36), s( 30, -74), s( 38, -111), s( 67, -141)], + [s( 8, -57), s( 13, -58), s( 22, -62), s( 30, -43), s( 26, -65), s( 5, -64), s( 32, -92), s( 34, -97)], ]; pub const KING: PieceSquareTableDefinition = [ - [s( 31, -125), s( 24, -53), s( 63, -34), s( -116, 31), s( -63, 9), s( 7, 8), s( 85, -7), s( 183, -149)], - [s( -130, 8), s( -25, 44), s( -68, 60), s( 63, 40), s( -1, 64), s( -4, 83), s( 52, 63), s( -11, 26)], - [s( -150, 28), s( 30, 51), s( -64, 79), s( -93, 95), s( -40, 94), s( 64, 83), s( 26, 79), s( -33, 37)], - [s( -108, 15), s( -87, 59), s( -113, 86), s( -174, 104), s( -165, 105), s( -111, 96), s( -109, 81), s( -174, 47)], - [s( -114, 4), s( -83, 40), s( -121, 74), s( -169, 97), s( -153, 93), s( -106, 74), s( -113, 57), s( -196, 42)], - [s( -53, -11), s( -4, 20), s( -69, 49), s( -85, 65), s( -71, 63), s( -72, 50), s( -23, 25), s( -82, 14)], - [s( 53, -32), s( 16, 3), s( -2, 20), s( -48, 34), s( -46, 37), s( -27, 26), s( 33, 1), s( 27, -23)], - [s( 30, -85), s( 75, -55), s( 39, -24), s( -81, -3), s( -3, -28), s( -47, -6), s( 48, -42), s( 38, -86)], + [s( 24, -123), s( 18, -51), s( 53, -32), s( -119, 33), s( -55, 9), s( 5, 9), s( 84, -6), s( 184, -148)], + [s( -133, 9), s( -30, 45), s( -76, 61), s( 60, 41), s( -1, 65), s( -4, 83), s( 50, 65), s( -9, 26)], + [s( -151, 28), s( 25, 52), s( -66, 80), s( -95, 95), s( -40, 95), s( 67, 82), s( 25, 80), s( -31, 38)], + [s( -108, 15), s( -88, 59), s( -114, 87), s( -173, 105), s( -162, 105), s( -110, 97), s( -107, 81), s( -171, 48)], + [s( -112, 4), s( -85, 41), s( -120, 74), s( -167, 97), s( -151, 93), s( -105, 74), s( -109, 57), s( -194, 42)], + [s( -53, -11), s( -2, 20), s( -69, 49), s( -86, 65), s( -72, 63), s( -74, 51), s( -21, 25), s( -81, 14)], + [s( 53, -32), s( 15, 4), s( -2, 20), s( -48, 34), s( -48, 38), s( -27, 26), s( 34, 1), s( 27, -23)], + [s( 30, -85), s( 75, -55), s( 40, -24), s( -79, -3), s( 0, -27), s( -45, -7), s( 47, -42), s( 37, -87)], ]; pub const PASSED_PAWNS: PieceSquareTableDefinition = [ [s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0)], - [s( 49, 170), s( 68, 162), s( 55, 161), s( 73, 125), s( 61, 124), s( 51, 135), s( 6, 164), s( -16, 175)], - [s( 21, 185), s( 37, 184), s( 28, 158), s( 10, 87), s( 13, 119), s( 7, 140), s( -44, 151), s( -67, 184)], - [s( 11, 91), s( 7, 85), s( 24, 66), s( 18, 58), s( 1, 56), s( 15, 64), s( -36, 87), s( -30, 98)], - [s( -10, 48), s( -19, 36), s( -29, 33), s( -17, 22), s( -26, 27), s( -13, 32), s( -34, 51), s( -24, 50)], - [s( -18, -4), s( -27, 4), s( -36, 11), s( -31, -1), s( -27, 0), s( -18, 3), s( -29, 24), s( -9, 4)], - [s( -28, -5), s( -15, -4), s( -26, 6), s( -32, 1), s( -11, -20), s( -8, -6), s( 4, -4), s( -19, 4)], + [s( 43, 170), s( 59, 163), s( 42, 162), s( 59, 125), s( 46, 125), s( 39, 136), s( -1, 164), s( -20, 175)], + [s( 18, 186), s( 41, 182), s( 27, 157), s( 15, 86), s( 4, 118), s( 3, 142), s( -48, 151), s( -67, 183)], + [s( 13, 90), s( 4, 85), s( 24, 65), s( 21, 56), s( 2, 54), s( 11, 66), s( -39, 88), s( -29, 97)], + [s( -11, 48), s( -18, 35), s( -31, 34), s( -18, 24), s( -27, 28), s( -14, 32), s( -31, 50), s( -25, 49)], + [s( -16, -5), s( -33, 6), s( -35, 11), s( -31, -1), s( -29, 2), s( -14, 2), s( -33, 25), s( -7, 3)], + [s( -28, -5), s( -19, -4), s( -31, 7), s( -29, 1), s( -14, -18), s( -12, -5), s( 1, -3), s( -20, 4)], [s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0), s( 0, 0)], ]; pub const KNIGHT_MOBILITY: [PhasedEval; 9] = [ - s( 0, 0), - s( 0, 0), - s( 38, 139), - s( 90, 154), - s( 114, 195), - s( 0, 0), - s( 153, 201), - s( 0, 0), - s( 134, 178), + s( -89, -19), + s( 55, 79), + s( 87, 122), + s( 101, 155), + s( 117, 168), + s( 119, 184), + s( 134, 188), + s( 149, 192), + s( 165, 185), ]; pub const BISHOP_MOBILITY: [PhasedEval; 14] = [ - s( 0, 0), - s( 60, 67), - s( 76, 70), - s( 86, 114), - s( 103, 127), - s( 111, 141), - s( 127, 164), - s( 137, 173), - s( 146, 189), - s( 146, 196), - s( 152, 205), - s( 153, 202), - s( 151, 204), - s( 175, 197), + s( 58, -94), + s( 34, 29), + s( 84, 101), + s( 99, 137), + s( 117, 152), + s( 129, 163), + s( 138, 177), + s( 145, 184), + s( 149, 193), + s( 153, 194), + s( 156, 198), + s( 169, 189), + s( 173, 193), + s( 175, 181), ]; pub const ROOK_MOBILITY: [PhasedEval; 15] = [ - s( 0, 0), - s( 0, 0), - s( 133, 261), - s( 144, 277), - s( 154, 288), - s( 161, 293), - s( 164, 298), - s( 168, 305), - s( 175, 307), - s( 184, 311), - s( 192, 317), - s( 199, 321), - s( 203, 329), - s( 212, 333), - s( 212, 334), + s( 79, 78), + s( 105, 194), + s( 135, 255), + s( 147, 274), + s( 157, 285), + s( 163, 294), + s( 168, 301), + s( 174, 308), + s( 182, 309), + s( 193, 313), + s( 203, 318), + s( 211, 324), + s( 218, 330), + s( 222, 330), + s( 215, 330), ]; pub const QUEEN_MOBILITY: [PhasedEval; 28] = [ s( 0, 0), s( 0, 0), - s( 0, 0), - s( 355, 100), - s( 331, 266), - s( 363, 336), - s( 362, 388), - s( 361, 464), - s( 368, 485), - s( 368, 507), - s( 374, 515), - s( 378, 529), - s( 381, 546), - s( 384, 550), - s( 389, 558), - s( 389, 570), - s( 389, 580), - s( 391, 590), - s( 390, 600), - s( 391, 607), - s( 392, 619), - s( 395, 619), - s( 397, 623), - s( 406, 620), - s( 407, 620), - s( 419, 621), - s( 480, 587), - s( 548, 559), + s( -46, -17), + s( 326, 123), + s( 292, 404), + s( 328, 450), + s( 338, 473), + s( 346, 491), + s( 354, 512), + s( 359, 546), + s( 366, 552), + s( 373, 560), + s( 378, 571), + s( 385, 572), + s( 387, 578), + s( 389, 588), + s( 390, 592), + s( 388, 605), + s( 388, 612), + s( 388, 615), + s( 397, 618), + s( 408, 603), + s( 427, 601), + s( 447, 584), + s( 450, 592), + s( 609, 511), + s( 510, 550), + s( 425, 578), ]; pub const ATTACKED_KING_SQUARES: [PhasedEval; 9] = [ - s( 61, -26), - s( 56, -18), - s( 27, -5), - s( -25, -8), - s( -115, 24), - s( -229, 80), - s( -347, 137), - s( -508, 190), - s( -280, -83), + s( 62, -25), + s( 55, -19), + s( 26, -6), + s( -26, -9), + s( -115, 22), + s( -229, 79), + s( -346, 135), + s( -512, 193), + s( -277, -81), ]; -pub const BISHOP_PAIR_BONUS: PhasedEval = s( 29, 86); +pub const BISHOP_PAIR_BONUS: PhasedEval = s( 31, 89); diff --git a/src/utils/tuner/trace.rs b/src/utils/tuner/trace.rs index 161eb3e..4085ec2 100644 --- a/src/utils/tuner/trace.rs +++ b/src/utils/tuner/trace.rs @@ -51,6 +51,10 @@ impl Trace { fn trace_for_player(trace: &mut Self, board: &Board, player: Player) { let mut number_of_bishops = 0; + let their_pawns = board.pawns(player.other()).forward(Player::Black); + let their_pawn_attacks = their_pawns.west() | their_pawns.east(); + let mobility_safe_squares = !their_pawn_attacks; + let mut attacked_squares = Bitboard::EMPTY; let occupancy = board.occupancy(); @@ -74,8 +78,8 @@ impl Trace { let attacks = tables::knight_attacks(sq); attacked_squares |= attacks; - let mobility = attacks.count(); - trace.knight_mobility[mobility as usize].incr(player); + let mobility_squares = (attacks & mobility_safe_squares).count() as usize; + trace.knight_mobility[mobility_squares].incr(player); } for sq in board.bishops(player) { @@ -85,8 +89,8 @@ impl Trace { let attacks = tables::bishop_attacks(sq, occupancy); attacked_squares |= attacks; - let mobility = attacks.count(); - trace.bishop_mobility[mobility as usize].incr(player); + let mobility_squares = (attacks & mobility_safe_squares).count() as usize; + trace.bishop_mobility[mobility_squares].incr(player); number_of_bishops += 1; } @@ -102,8 +106,8 @@ impl Trace { let attacks = tables::rook_attacks(sq, occupancy); attacked_squares |= attacks; - let mobility = attacks.count(); - trace.rook_mobility[mobility as usize].incr(player); + let mobility_squares = (attacks & mobility_safe_squares).count() as usize; + trace.rook_mobility[mobility_squares].incr(player); } for sq in board.queens(player) { @@ -114,8 +118,8 @@ impl Trace { tables::rook_attacks(sq, occupancy) | tables::bishop_attacks(sq, occupancy); attacked_squares |= attacks; - let mobility = attacks.count(); - trace.queen_mobility[mobility as usize].incr(player); + let mobility_squares = (attacks & mobility_safe_squares).count() as usize; + trace.queen_mobility[mobility_squares].incr(player); } for sq in board.king(player) {