From 6591619e32301a9fe7c209dc3b1cd34e61c541d7 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 19 May 2025 17:00:48 -0700 Subject: [PATCH] [position] Misc changes - Add a captures list to the Position struct - Implement ToFenStr - Update the imports list, which has been sorely out-of-date in the tree for many commits now. --- position/src/position/position.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/position/src/position/position.rs b/position/src/position/position.rs index 9095aa7..b0e4c8a 100644 --- a/position/src/position/position.rs +++ b/position/src/position/position.rs @@ -1,25 +1,25 @@ // Eryn Wells -use crate::{ - check::CheckingPieces, - move_generator::{MoveSet, Moves}, - sight::SightExt, +use crate::{movement::Movement, sight::Sight}; +use chessfriend_bitboard::{BitBoard, IterationDirection}; +use chessfriend_board::{ + display::DiagramFormatter, en_passant::EnPassant, fen::ToFenStr, Board, PlacePieceError, + PlacePieceStrategy, }; -use chessfriend_bitboard::BitBoard; -use chessfriend_board::{castle::Castle, display::DiagramFormatter, en_passant::EnPassant, Board}; -use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square}; -use chessfriend_moves::Move; -use std::{cell::OnceCell, fmt}; +use chessfriend_core::{Color, Piece, Square}; +use std::{cell::OnceCell, fmt, ops::BitOr}; +#[must_use] #[derive(Clone, Debug, Eq)] pub struct Position { pub board: Board, moves: OnceCell, + pub(super) captures: [Vec; Color::NUM], } impl Position { pub fn empty() -> Self { - Default::default() + Position::default() } /// Return a starting position. @@ -225,11 +225,20 @@ impl Position { } } +impl ToFenStr for Position { + type Error = ::Error; + + fn to_fen_str(&self) -> Result { + self.board.to_fen_str() + } +} + impl Default for Position { fn default() -> Self { Self { board: Board::default(), moves: OnceCell::new(), + captures: Default::default(), } } }