diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-02 20:51:25 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-02 20:51:53 +0300 |
commit | cae14cd6f19c40be2c30b638a51a02c4da0959ea (patch) | |
tree | 5e3cc85e5d779beeaaaa837eefed97835b89dca5 /src/attacks.rs | |
parent | ec05e8bfa3f61b86fb83d939ff6fa3ddbc51ce6d (diff) | |
download | chessnost-cae14cd6f19c40be2c30b638a51a02c4da0959ea.tar.gz |
refactor: use functions for file and rank
Diffstat (limited to 'src/attacks.rs')
-rw-r--r-- | src/attacks.rs | 6 |
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; |