[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.
This commit is contained in:
parent
97552302cb
commit
6591619e32
1 changed files with 19 additions and 10 deletions
|
@ -1,25 +1,25 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
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<Moves>,
|
||||
pub(super) captures: [Vec<Piece>; 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 = <Board as ToFenStr>::Error;
|
||||
|
||||
fn to_fen_str(&self) -> Result<String, Self::Error> {
|
||||
self.board.to_fen_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Position {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
board: Board::default(),
|
||||
moves: OnceCell::new(),
|
||||
captures: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue