Skip to content

Commit 33b0051

Browse files
authored
Simplify castling in movegen (#1041)
STC Elo | 1.93 +- 2.23 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 2.89 (-2.25, 2.89) [-2.75, 0.25] Games | N: 22516 W: 5840 L: 5715 D: 10961 Penta | [54, 2432, 6177, 2525, 70] https://recklesschess.space/test/14931/ No functional change. Bench: 3466720
1 parent 56f40d6 commit 33b0051

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/board/movegen.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,14 @@ impl super::Board {
9292

9393
fn collect_castling(&self, list: &mut MoveList) {
9494
let stm = self.side_to_move();
95-
self.collect_castling_kind(list, CastlingKind::KINDS[stm][0]); //queenside
96-
self.collect_castling_kind(list, CastlingKind::KINDS[stm][1]); //kingside
97-
}
98-
99-
fn collect_castling_kind(&self, list: &mut MoveList, kind: CastlingKind) {
100-
let stm = self.side_to_move();
101-
if self.castling().is_allowed(kind)
102-
&& (self.castling_path[kind] & self.occupancies()).is_empty()
103-
&& (self.castling_threat[kind] & self.all_threats()).is_empty()
104-
&& !self.pinned(stm).contains(self.castling_rooks[kind])
105-
{
106-
list.push(self.king_square(stm), kind.landing_square(), MoveKind::Castling);
95+
for kind in [CastlingKind::KINDS[stm][0], CastlingKind::KINDS[stm][1]] {
96+
if self.castling().is_allowed(kind)
97+
&& (self.castling_path[kind] & self.occupancies()).is_empty()
98+
&& (self.castling_threat[kind] & self.all_threats()).is_empty()
99+
&& !self.pinned(stm).contains(self.castling_rooks[kind])
100+
{
101+
list.push(self.king_square(stm), kind.landing_square(), MoveKind::Castling);
102+
}
107103
}
108104
}
109105

0 commit comments

Comments
 (0)