[board] Get king moves from the bitboard library
This commit is contained in:
parent
b95c34f51e
commit
769886086c
3 changed files with 172 additions and 50 deletions
|
@ -9,6 +9,14 @@ use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not};
|
|||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||
pub(crate) struct BitBoard(pub(super) u64);
|
||||
|
||||
macro_rules! moves_getter {
|
||||
($getter_name:ident) => {
|
||||
pub fn $getter_name(sq: Square) -> BitBoard {
|
||||
library().$getter_name(sq)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl BitBoard {
|
||||
pub const fn empty() -> BitBoard {
|
||||
BitBoard(0)
|
||||
|
@ -28,9 +36,11 @@ impl BitBoard {
|
|||
FILES[file]
|
||||
}
|
||||
|
||||
pub fn knight_moves(sq: Square) -> BitBoard {
|
||||
library().knight_moves(sq)
|
||||
}
|
||||
moves_getter!(knight_moves);
|
||||
moves_getter!(bishop_moves);
|
||||
moves_getter!(rook_moves);
|
||||
moves_getter!(queen_moves);
|
||||
moves_getter!(king_moves);
|
||||
|
||||
pub fn from_square(sq: Square) -> BitBoard {
|
||||
BitBoard(1 << sq.index())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue