From cae14cd6f19c40be2c30b638a51a02c4da0959ea Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 2 Feb 2023 20:51:25 +0300 Subject: refactor: use functions for file and rank --- src/board/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/board') diff --git a/src/board/mod.rs b/src/board/mod.rs index 2bb1147..a1166d6 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -255,7 +255,7 @@ impl Board { } pub fn generate_pseudolegal_moves(&self, color: Color) -> Vec { - let mut moves = Vec::with_capacity(1024); + let mut moves = Vec::with_capacity(256); let capture_targets = self.color_occupancy(color.flip()) ^ match color { // Exclude opponent king because we can't capture it Color::White => self.pieces[PieceType::KingBlack as usize], @@ -555,10 +555,11 @@ impl Board { } fn piece_by_square(&self, square: Square) -> Option { + let square_bb = square.to_bitboard(); self.pieces .iter() .enumerate() - .find(|(_, bitboard)| *bitboard & square.to_bitboard() > 0) + .find(|(_, bitboard)| *bitboard & square_bb > 0) .and_then(|(pt, _)| Some(PieceType::from(pt))) } -- cgit v1.2.3