aboutsummaryrefslogtreecommitdiff
path: root/src/board
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-02 20:51:25 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-02 20:51:53 +0300
commitcae14cd6f19c40be2c30b638a51a02c4da0959ea (patch)
tree5e3cc85e5d779beeaaaa837eefed97835b89dca5 /src/board
parentec05e8bfa3f61b86fb83d939ff6fa3ddbc51ce6d (diff)
downloadchessnost-cae14cd6f19c40be2c30b638a51a02c4da0959ea.tar.gz
refactor: use functions for file and rank
Diffstat (limited to 'src/board')
-rw-r--r--src/board/mod.rs5
1 files changed, 3 insertions, 2 deletions
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<Move> {
- 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<PieceType> {
+ 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)))
}