1
0
Fork 0

impl Default for Bitboard, Setup & Position

This commit is contained in:
Paul-Nicolas Madelaine 2025-11-29 14:12:20 +01:00
parent ebab07f5ae
commit f7c47c4d85
3 changed files with 16 additions and 2 deletions

View file

@ -3,7 +3,7 @@
use crate::board::*; use crate::board::*;
/// A set of squares. /// A set of squares.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Bitboard(pub u64); pub struct Bitboard(pub u64);
impl Bitboard { impl Bitboard {

View file

@ -196,7 +196,7 @@ impl Position {
.as_setup() .as_setup()
.en_passant .en_passant
.map(|square| square.bitboard()) .map(|square| square.bitboard())
.unwrap_or(Bitboard::new()), .unwrap_or_default(),
}; };
self.generate_moves(&mut moves).is_break() self.generate_moves(&mut moves).is_break()
} }
@ -478,6 +478,13 @@ impl core::fmt::Debug for Position {
} }
} }
impl Default for Position {
#[inline]
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub(crate) struct RawMove { pub(crate) struct RawMove {
pub kind: MoveType, pub kind: MoveType,

View file

@ -541,6 +541,13 @@ impl core::fmt::Debug for Setup {
} }
} }
impl Default for Setup {
#[inline]
fn default() -> Self {
Self::new()
}
}
/// An invalid position. /// An invalid position.
/// ///
/// This is an illegal position that can't be represented with the [`Position`] type. /// This is an illegal position that can't be represented with the [`Position`] type.