[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>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
use crate::{
|
use crate::{movement::Movement, sight::Sight};
|
||||||
check::CheckingPieces,
|
use chessfriend_bitboard::{BitBoard, IterationDirection};
|
||||||
move_generator::{MoveSet, Moves},
|
use chessfriend_board::{
|
||||||
sight::SightExt,
|
display::DiagramFormatter, en_passant::EnPassant, fen::ToFenStr, Board, PlacePieceError,
|
||||||
|
PlacePieceStrategy,
|
||||||
};
|
};
|
||||||
use chessfriend_bitboard::BitBoard;
|
use chessfriend_core::{Color, Piece, Square};
|
||||||
use chessfriend_board::{castle::Castle, display::DiagramFormatter, en_passant::EnPassant, Board};
|
use std::{cell::OnceCell, fmt, ops::BitOr};
|
||||||
use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square};
|
|
||||||
use chessfriend_moves::Move;
|
|
||||||
use std::{cell::OnceCell, fmt};
|
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[derive(Clone, Debug, Eq)]
|
#[derive(Clone, Debug, Eq)]
|
||||||
pub struct Position {
|
pub struct Position {
|
||||||
pub board: Board,
|
pub board: Board,
|
||||||
moves: OnceCell<Moves>,
|
moves: OnceCell<Moves>,
|
||||||
|
pub(super) captures: [Vec<Piece>; Color::NUM],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Position {
|
impl Position {
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
Default::default()
|
Position::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a starting position.
|
/// 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 {
|
impl Default for Position {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
board: Board::default(),
|
board: Board::default(),
|
||||||
moves: OnceCell::new(),
|
moves: OnceCell::new(),
|
||||||
|
captures: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue