Add State struct as part of Board struct

This commit is contained in:
2024-06-09 15:21:11 +03:00
parent a6d6347270
commit 2133fb3cad
3 changed files with 33 additions and 20 deletions

View File

@@ -7,14 +7,12 @@ use String as FenError;
#[derive(Debug, PartialEq, Eq)]
pub struct Game {
pub board: Board,
pub state: State,
}
impl Game {
pub const fn new() -> Self {
Self {
board: Board::new(),
state: State::new(),
}
}
@@ -33,7 +31,7 @@ impl Default for Game {
}
}
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct State {
side_to_move: Color,
castling_ability: u8,
@@ -68,6 +66,10 @@ impl State {
fullmove_counter,
}
}
pub const fn get_en_passant_target_square(&self) -> u8 {
self.en_passant_target_square
}
}
use std::fmt;