diff --git a/src/movegen/magic/mod.rs b/src/movegen/magic/mod.rs deleted file mode 100644 index 242a0b4..0000000 --- a/src/movegen/magic/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::board::Bitboard; - -/// A type representing the magic board indexing a given [crate::board::Square]. -pub struct Magic { - /// Magic number. - pub(crate) magic: u64, - /// Base offset into the magic square table. - pub(crate) offset: usize, - /// Mask to apply to the blocker board before applying the magic. - pub(crate) mask: Bitboard, - /// Length of the resulting mask after applying the magic. - pub(crate) shift: u8, -} - -impl Magic { - /// Compute the index into the magics database for this set of `blockers`. - pub fn get_index(&self, blockers: Bitboard) -> usize { - let relevant_occupancy = (blockers & self.mask).0; - let base_index = ((relevant_occupancy.wrapping_mul(self.magic)) >> self.shift) as usize; - base_index + self.offset - } -} diff --git a/src/movegen/mod.rs b/src/movegen/mod.rs index 9ddbf36..50262d2 100644 --- a/src/movegen/mod.rs +++ b/src/movegen/mod.rs @@ -1,7 +1,3 @@ -// Magic bitboard -pub mod magic; -pub use magic::*; - // Naive move generation pub mod naive; diff --git a/src/movegen/wizardry/generation.rs b/src/movegen/wizardry/generation.rs index 23da62a..c7c73dd 100644 --- a/src/movegen/wizardry/generation.rs +++ b/src/movegen/wizardry/generation.rs @@ -1,8 +1,8 @@ use crate::board::{Bitboard, Square}; use crate::movegen::naive::{bishop_moves, rook_moves}; -use crate::movegen::Magic; use super::mask::{generate_bishop_mask, generate_rook_mask}; +use super::Magic; /// A trait to represent RNG for u64 values. #[allow(unused)] // FIXME: remove when used diff --git a/src/movegen/wizardry/mod.rs b/src/movegen/wizardry/mod.rs index dfd732d..2405710 100644 --- a/src/movegen/wizardry/mod.rs +++ b/src/movegen/wizardry/mod.rs @@ -1,2 +1,25 @@ pub(crate) mod generation; mod mask; + +use crate::board::Bitboard; + +/// A type representing the magic board indexing a given [crate::board::Square]. +pub struct Magic { + /// Magic number. + pub(crate) magic: u64, + /// Base offset into the magic square table. + pub(crate) offset: usize, + /// Mask to apply to the blocker board before applying the magic. + pub(crate) mask: Bitboard, + /// Length of the resulting mask after applying the magic. + pub(crate) shift: u8, +} + +impl Magic { + /// Compute the index into the magics database for this set of `blockers`. + pub fn get_index(&self, blockers: Bitboard) -> usize { + let relevant_occupancy = (blockers & self.mask).0; + let base_index = ((relevant_occupancy.wrapping_mul(self.magic)) >> self.shift) as usize; + base_index + self.offset + } +}