Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/board/movegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,20 @@ impl super::Board {

fn collect_castling(&self, list: &mut MoveList) {
let stm = self.side_to_move();
self.collect_castling_kind(list, CastlingKind::KINDS[stm][0]); //queenside
self.collect_castling_kind(list, CastlingKind::KINDS[stm][1]); //kingside
}

fn collect_castling_kind(&self, list: &mut MoveList, kind: CastlingKind) {
let stm = self.side_to_move();
if self.castling().is_allowed(kind)
&& (self.castling_path[kind] & self.occupancies()).is_empty()
&& (self.castling_threat[kind] & self.all_threats()).is_empty()
&& !self.pinned(stm).contains(self.castling_rooks[kind])
{
list.push(self.king_square(stm), kind.landing_square(), MoveKind::Castling);
for kind in [CastlingKind::KINDS[stm][0], CastlingKind::KINDS[stm][1]] {
if self.castling().is_allowed(kind)
&& (self.castling_path[kind] & self.occupancies()).is_empty()
&& (self.castling_threat[kind] & self.all_threats()).is_empty()
&& !self.pinned(stm).contains(self.castling_rooks[kind])
{
list.push(self.king_square(stm), kind.landing_square(), MoveKind::Castling);
}
}
}

fn collect_pawn_captures(&self, list: &mut MoveList, pawns: Bitboard, dir: i8, target: Bitboard, seventh_rank: Bitboard) {
fn collect_pawn_captures(
&self, list: &mut MoveList, pawns: Bitboard, dir: i8, target: Bitboard, seventh_rank: Bitboard,
) {
let promos = (pawns & seventh_rank).shift(dir);
list.push_promotion_capture_setwise(dir, promos & target);
let captures = (pawns & !seventh_rank).shift(dir);
Expand Down
Loading