Replace crate::r#move::castle::Castle with moves::Castle

This commit is contained in:
Eryn Wells 2024-02-25 09:44:25 -08:00
parent 36db46ac18
commit aaad991899
5 changed files with 8 additions and 8 deletions

View file

@ -4,9 +4,10 @@
//! generating the possible moves for the king in the given position. //! generating the possible moves for the king in the given position.
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet}; use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
use crate::{r#move::Castle, Position}; use crate::Position;
use chessfriend_bitboard::BitBoard; use chessfriend_bitboard::BitBoard;
use chessfriend_core::{PlacedPiece, Shape}; use chessfriend_core::{PlacedPiece, Shape};
use chessfriend_moves::Castle;
move_generator_declaration!(KingMoveGenerator, struct); move_generator_declaration!(KingMoveGenerator, struct);
move_generator_declaration!(KingMoveGenerator, new); move_generator_declaration!(KingMoveGenerator, new);

View file

@ -1,8 +1,8 @@
// Eryn Wells <eryn@erynwells.me> // Eryn Wells <eryn@erynwells.me>
use crate::{r#move::Castle, Move, MoveBuilder};
use chessfriend_bitboard::BitBoard; use chessfriend_bitboard::BitBoard;
use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square}; use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square};
use chessfriend_moves::{Builder as MoveBuilder, Castle, Move};
/// A set of bitboards defining the moves for a single piece on the board. /// A set of bitboards defining the moves for a single piece on the board.
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]

View file

@ -2,10 +2,10 @@
use crate::{ use crate::{
position::{flags::Flags, piece_sets::PieceBitBoards}, position::{flags::Flags, piece_sets::PieceBitBoards},
r#move::Castle,
Position, Position,
}; };
use chessfriend_core::{piece, Color, Piece, PlacedPiece, Rank, Shape, Square}; use chessfriend_core::{piece, Color, Piece, PlacedPiece, Rank, Shape, Square};
use chessfriend_moves::Castle;
use std::collections::BTreeMap; use std::collections::BTreeMap;
#[derive(Clone)] #[derive(Clone)]

View file

@ -1,7 +1,7 @@
// Eryn Wells <eryn@erynwells.me> // Eryn Wells <eryn@erynwells.me>
use crate::r#move::Castle;
use chessfriend_core::Color; use chessfriend_core::Color;
use chessfriend_moves::Castle;
use std::fmt; use std::fmt;
#[derive(Clone, Copy, Eq, Hash, PartialEq)] #[derive(Clone, Copy, Eq, Hash, PartialEq)]
@ -10,7 +10,7 @@ pub struct Flags(u8);
impl Flags { impl Flags {
#[inline] #[inline]
pub(super) fn player_has_right_to_castle_flag_offset(color: Color, castle: Castle) -> usize { pub(super) fn player_has_right_to_castle_flag_offset(color: Color, castle: Castle) -> usize {
((color as usize) << 1) + castle.into_index() ((color as usize) << 1) + castle as usize
} }
pub(super) fn player_has_right_to_castle(&self, color: Color, castle: Castle) -> bool { pub(super) fn player_has_right_to_castle(&self, color: Color, castle: Castle) -> bool {

View file

@ -5,12 +5,11 @@ use crate::{
check::CheckingPieces, check::CheckingPieces,
move_generator::{MoveSet, Moves}, move_generator::{MoveSet, Moves},
position::DiagramFormatter, position::DiagramFormatter,
r#move::Castle,
sight::SightExt, sight::SightExt,
}; };
use chessfriend_bitboard::BitBoard; use chessfriend_bitboard::BitBoard;
use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square}; use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square};
use chessfriend_moves::EnPassant; use chessfriend_moves::{Castle, EnPassant};
use std::{cell::OnceCell, fmt}; use std::{cell::OnceCell, fmt};
#[derive(Clone, Debug, Eq)] #[derive(Clone, Debug, Eq)]
@ -93,7 +92,7 @@ impl Position {
return false; return false;
} }
let castling_parameters = castle.parameters(); let castling_parameters = castle.parameters(player);
let all_pieces = self.occupied_squares(); let all_pieces = self.occupied_squares();
if !(all_pieces & castling_parameters.clear_squares()).is_empty() { if !(all_pieces & castling_parameters.clear_squares()).is_empty() {