Skip to content

Commit 2024e35

Browse files
authored
Simplify movegen (#1042)
Probably pretty neutral. STC Elo | 8.00 +- 4.07 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 2.91 (-2.25, 2.89) [-2.75, 0.25] Games | N: 6600 W: 1756 L: 1604 D: 3240 Penta | [11, 645, 1850, 769, 25] https://recklesschess.space/test/14940/ No functional change. Bench: 3466720
1 parent 33b0051 commit 2024e35

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/board/movegen.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ impl super::Board {
146146

147147
let target = target & self.colors(!stm);
148148

149-
let up_right = up + Square::RIGHT;
150-
let right_pin_mask = relative_diagonal(stm, king_sq);
151-
let right_pawns = pawns & (!pinned | right_pin_mask) & !Bitboard::file(File::H);
152-
self.collect_pawn_captures(list, right_pawns, up_right, target, seventh_rank);
153-
154-
let up_left = up + Square::LEFT;
155-
let left_pin_mask = relative_diagonal(!stm, king_sq);
156-
let left_pawns = pawns & (!pinned | left_pin_mask) & !Bitboard::file(File::A);
157-
self.collect_pawn_captures(list, left_pawns, up_left, target, seventh_rank);
149+
let dirs = [up + Square::RIGHT, up + Square::LEFT];
150+
let pin_masks = [relative_diagonal(stm, king_sq), relative_diagonal(!stm, king_sq)];
151+
let shift_masks = [!Bitboard::file(File::H), !Bitboard::file(File::A)];
152+
153+
for i in 0..2 {
154+
let the_pawns = pawns & (!pinned | pin_masks[i]) & shift_masks[i];
155+
self.collect_pawn_captures(list, the_pawns, dirs[i], target, seventh_rank);
156+
}
158157
}
159158
}
160159
}

0 commit comments

Comments
 (0)