diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-22 03:03:36 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-22 03:03:36 +0300 |
commit | 1336c7022d0ffd82bca4d9442ea52ec5741fd370 (patch) | |
tree | 47a6c4cbc1975cb75a9e5f4d0f959da2cce01383 /src | |
parent | 094e88235484377808140f0455202f53379272f3 (diff) | |
download | chessnost-1336c7022d0ffd82bca4d9442ea52ec5741fd370.tar.gz |
feat: compute queen attacks
Diffstat (limited to 'src')
-rw-r--r-- | src/attacks.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/attacks.rs b/src/attacks.rs index 6cf2a66..4562f25 100644 --- a/src/attacks.rs +++ b/src/attacks.rs @@ -265,6 +265,10 @@ impl Attacks { self.kindergarten_attacks_file(occupancy, vertical, square) | self.kindergarten_attacks_base(occupancy, horizontal, square) } + + fn queen(&self, occupancy: Bitboard, square: u8) -> Bitboard { + self.rook(occupancy, square) | self.bishop(occupancy, square) + } } #[cfg(test)] @@ -393,4 +397,19 @@ mod tests { print(bb); } + + #[test] + fn test_queen_attacks() { + let attacks = Attacks::new(); + let square = Square::E4 as u8; + let occupancy = + 1 << Square::B7 as usize | + 1 << Square::B1 as usize | + 1 << Square::C2 as usize | + 1 << Square::E3 as usize | + 1 << Square::F3 as usize; + let bb = attacks.queen(occupancy, square); + print(occupancy); + print(bb); + } } |