aboutsummaryrefslogtreecommitdiff
path: root/src/attacks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/attacks.rs')
-rw-r--r--src/attacks.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/attacks.rs b/src/attacks.rs
index 1074037..eafaf01 100644
--- a/src/attacks.rs
+++ b/src/attacks.rs
@@ -253,7 +253,7 @@ impl Attacks {
/// Given a square and occupancy masked for rank, diagonal or anti-diagonal (note: not a file!)
/// return an attack bitboard that considers blocking pieces
fn kindergarten_attacks_base(&self, occupancy: Bitboard, mask: Bitboard, square: Square) -> Bitboard {
- let file = square as u8 % 8;
+ let file = square.file();
let masked_occupancy = occupancy & mask;
let occupancy_rank = ((masked_occupancy as u128 * B_FILE as u128) >> 58 & 0b111111) << 1;
let rank_attacks = self.first_rank_attacks[occupancy_rank as usize][file as usize] as Bitboard;
@@ -267,8 +267,8 @@ impl Attacks {
/// https://www.chessprogramming.org/Kindergarten_Bitboards
fn kindergarten_attacks_file(&self, occupancy: Bitboard, mask: Bitboard, square: Square) -> Bitboard {
- let file = square as u8 % 8;
- let rank = square as u8 / 8;
+ let file = square.file();
+ let rank = square.rank();
let masked_occupancy = (occupancy & mask) >> file; // Shift occupancy to A file
let occupancy_rank = ((masked_occupancy as u128 * DIAG_C2_H7 as u128) >> 58 & 0b111111) << 1;