From ebed5c05ed5d19c828fdc3265777bcc2831558bd Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 19 Dec 2023 11:13:06 -0800 Subject: [PATCH] [bitboard] Add a BitBoard and a Position struct --- bitboard/src/bitboard.rs | 4 ++++ bitboard/src/lib.rs | 4 ---- bitboard/src/position.rs | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 bitboard/src/bitboard.rs create mode 100644 bitboard/src/position.rs diff --git a/bitboard/src/bitboard.rs b/bitboard/src/bitboard.rs new file mode 100644 index 0000000..72687bf --- /dev/null +++ b/bitboard/src/bitboard.rs @@ -0,0 +1,4 @@ +// Eryn Wells + +#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct BitBoard(u64); diff --git a/bitboard/src/lib.rs b/bitboard/src/lib.rs index 7d12d9a..05aaacb 100644 --- a/bitboard/src/lib.rs +++ b/bitboard/src/lib.rs @@ -1,7 +1,3 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - #[cfg(test)] mod tests { use super::*; diff --git a/bitboard/src/position.rs b/bitboard/src/position.rs new file mode 100644 index 0000000..4bedbf7 --- /dev/null +++ b/bitboard/src/position.rs @@ -0,0 +1,33 @@ +// Eryn Wells + +mod color { + const WHITE = 0; + const BLACK = 1; +} + +mod piece { + const PAWN = 0; + const KNIGHT = 1; + const BISHOP = 2; + const ROOK = 3; + const QUEEN = 4; + const KING = 5; +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Position { + /// Composite bitboards for all the pieces of a particular color. + pieces_per_color: [BitBoard; 2], + + /// Bitboards representing positions of particular piece types per color. + pieces_per_type: [[BitBoard; 6]; 2], +} + +impl Position { + static fn empty() -> Position { + Position { + pieces_per_color = [], + pieces_per_type = [], + } + } +}