[bitboard] Move everything in board::bitboard to the bitboard crate
This commit is contained in:
parent
32100b9553
commit
625bfb2446
7 changed files with 25 additions and 25 deletions
|
@ -1,8 +1,8 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
use super::library::{library, FILES, RANKS};
|
use crate::library::{library, FILES, RANKS};
|
||||||
use super::LeadingBitScanner;
|
use crate::LeadingBitScanner;
|
||||||
use crate::{square::Direction, Square};
|
use chess_core::{Direction, Square};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Not;
|
use std::ops::Not;
|
||||||
|
|
||||||
|
@ -72,13 +72,13 @@ impl BitBoard {
|
||||||
/// Return an Iterator over the occupied squares, starting from the leading
|
/// Return an Iterator over the occupied squares, starting from the leading
|
||||||
/// (most-significant bit) end of the field.
|
/// (most-significant bit) end of the field.
|
||||||
pub(crate) fn occupied_squares(&self) -> impl Iterator<Item = Square> {
|
pub(crate) fn occupied_squares(&self) -> impl Iterator<Item = Square> {
|
||||||
LeadingBitScanner::new(self.0).map(Square::from_index)
|
LeadingBitScanner::new(self.0).map(|idx| unsafe { Square::from_index(idx as u8) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an Iterator over the occupied squares, starting from the trailing
|
/// Return an Iterator over the occupied squares, starting from the trailing
|
||||||
/// (least-significant bit) end of the field.
|
/// (least-significant bit) end of the field.
|
||||||
pub(crate) fn occupied_squares_trailing(&self) -> impl Iterator<Item = Square> {
|
pub(crate) fn occupied_squares_trailing(&self) -> impl Iterator<Item = Square> {
|
||||||
LeadingBitScanner::new(self.0).map(Square::from_index)
|
LeadingBitScanner::new(self.0).map(|idx| unsafe { Square::from_index(idx as u8) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,8 @@ impl BitBoardBuilder {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{bitboard, Square};
|
use crate::bitboard;
|
||||||
|
use chess_core::Square;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_and_debug() {
|
fn display_and_debug() {
|
|
@ -1 +1,18 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
|
mod bit_scanner;
|
||||||
|
mod bitboard;
|
||||||
|
mod library;
|
||||||
|
mod shifts;
|
||||||
|
|
||||||
|
pub(crate) use bit_scanner::{LeadingBitScanner, TrailingBitScanner};
|
||||||
|
pub(crate) use bitboard::{BitBoard, BitBoardBuilder};
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! bitboard {
|
||||||
|
($($sq:ident),* $(,)?) => {
|
||||||
|
$crate::bitboard::BitBoardBuilder::empty()
|
||||||
|
$(.square(chess_core::Square::$sq))*
|
||||||
|
.build()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
use super::BitBoard;
|
use super::BitBoard;
|
||||||
use crate::{square::Direction, Square};
|
use chess_core::{Direction, Square};
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
||||||
pub(super) const RANKS: [BitBoard; 8] = [
|
pub(super) const RANKS: [BitBoard; 8] = [
|
|
@ -1,16 +0,0 @@
|
||||||
mod bit_scanner;
|
|
||||||
mod bitboard;
|
|
||||||
mod library;
|
|
||||||
mod shifts;
|
|
||||||
|
|
||||||
pub(crate) use bit_scanner::{LeadingBitScanner, TrailingBitScanner};
|
|
||||||
pub(crate) use bitboard::{BitBoard, BitBoardBuilder};
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! bitboard {
|
|
||||||
($($sq:ident),* $(,)?) => {
|
|
||||||
$crate::bitboard::BitBoardBuilder::empty()
|
|
||||||
$(.square($crate::Square::$sq))*
|
|
||||||
.build()
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
pub mod fen;
|
pub mod fen;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
mod bitboard;
|
|
||||||
mod display;
|
mod display;
|
||||||
mod r#move;
|
mod r#move;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue