[board] Remove BoardSide enum; use Castle everywhere

Move Castle to a castle module inside the move module.
Implement into_index() on Castle to turn it into a usize.
This commit is contained in:
Eryn Wells 2024-01-21 10:38:50 -08:00
parent 21b5266789
commit fa1c6b452e
8 changed files with 95 additions and 63 deletions

View file

@ -1,6 +1,5 @@
// Eryn Wells <eryn@erynwells.me>
use super::position::BoardSide;
use crate::{r#move::Castle, Color};
use std::fmt;
@ -9,9 +8,8 @@ pub(super) struct Flags(u8);
impl Flags {
#[inline]
pub(super) fn player_has_right_to_castle_flag_offset(color: Color, castle: Castle) -> u8 {
let board_side: BoardSide = castle.into();
((color as u8) << 1) + board_side as u8
pub(super) fn player_has_right_to_castle_flag_offset(color: Color, castle: Castle) -> usize {
((color as usize) << 1) + castle.into_index()
}
pub(super) fn player_has_right_to_castle(&self, color: Color, castle: Castle) -> bool {