[bitboard] Add a BitBoard and a Position struct

This commit is contained in:
Eryn Wells 2023-12-19 11:13:06 -08:00
parent 8fd01e4f11
commit ebed5c05ed
3 changed files with 37 additions and 4 deletions

4
bitboard/src/bitboard.rs Normal file
View file

@ -0,0 +1,4 @@
// Eryn Wells <eryn@erynwells.me>
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BitBoard(u64);

View file

@ -1,7 +1,3 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;

33
bitboard/src/position.rs Normal file
View file

@ -0,0 +1,33 @@
// Eryn Wells <eryn@erynwells.me>
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 = [],
}
}
}