Move 'Magic' to 'wizardry' submodule
This commit is contained in:
parent
868edda9d7
commit
028c4543e7
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
// Magic bitboard
|
||||
pub mod magic;
|
||||
pub use magic::*;
|
||||
|
||||
// Naive move generation
|
||||
pub mod naive;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue