[bitboard] Make the bitboard crate more crate-like
Export symbols needed to use BitBoard and BitBoardBuilder. Fix build errors.
This commit is contained in:
parent
d901be53d2
commit
3cec64d686
4 changed files with 9 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chess_bitboard"
|
name = "chessfriend_bitboard"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::fmt;
|
||||||
use std::ops::Not;
|
use std::ops::Not;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||||
pub(crate) struct BitBoard(pub(super) u64);
|
pub struct BitBoard(pub(crate) u64);
|
||||||
|
|
||||||
macro_rules! moves_getter {
|
macro_rules! moves_getter {
|
||||||
($getter_name:ident) => {
|
($getter_name:ident) => {
|
||||||
|
@ -71,13 +71,13 @@ impl BitBoard {
|
||||||
impl BitBoard {
|
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 fn occupied_squares(&self) -> impl Iterator<Item = Square> {
|
||||||
LeadingBitScanner::new(self.0).map(|idx| unsafe { Square::from_index(idx as u8) })
|
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 fn occupied_squares_trailing(&self) -> impl Iterator<Item = Square> {
|
||||||
LeadingBitScanner::new(self.0).map(|idx| unsafe { Square::from_index(idx as u8) })
|
LeadingBitScanner::new(self.0).map(|idx| unsafe { Square::from_index(idx as u8) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ impl BitBoardBuilder {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::bitboard;
|
use crate::bitboard;
|
||||||
use chess_core::Square;
|
use chessfriend_core::Square;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_and_debug() {
|
fn display_and_debug() {
|
||||||
|
|
|
@ -5,13 +5,14 @@ mod bitboard;
|
||||||
mod library;
|
mod library;
|
||||||
mod shifts;
|
mod shifts;
|
||||||
|
|
||||||
|
pub use bitboard::{BitBoard, BitBoardBuilder};
|
||||||
|
|
||||||
pub(crate) use bit_scanner::{LeadingBitScanner, TrailingBitScanner};
|
pub(crate) use bit_scanner::{LeadingBitScanner, TrailingBitScanner};
|
||||||
pub(crate) use bitboard::{BitBoard, BitBoardBuilder};
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! bitboard {
|
macro_rules! bitboard {
|
||||||
($($sq:ident),* $(,)?) => {
|
($($sq:ident),* $(,)?) => {
|
||||||
$crate::bitboard::BitBoardBuilder::empty()
|
$crate::BitBoardBuilder::empty()
|
||||||
$(.square(chessfriend_core::Square::$sq))*
|
$(.square(chessfriend_core::Square::$sq))*
|
||||||
.build()
|
.build()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
use super::BitBoard;
|
use crate::BitBoard;
|
||||||
use chessfriend_core::{Direction, Square};
|
use chessfriend_core::{Direction, Square};
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue