[moves, position] Move MoveRecord to the moves crate

This commit is contained in:
Eryn Wells 2025-05-31 14:32:39 -07:00
parent b8f45aaece
commit 34e8c08c36
5 changed files with 8 additions and 7 deletions

View file

@ -1,6 +1,5 @@
// Eryn Wells <eryn@erynwells.me>
mod move_record;
mod position;
#[macro_use]

View file

@ -1,42 +0,0 @@
// Eryn Wells <eryn@erynwells.me>
use chessfriend_board::{board::HalfMoveClock, Board, CastleRights};
use chessfriend_core::{Color, Piece, Square};
use chessfriend_moves::Move;
/// A record of a move made on a board. This struct contains all the information
/// necessary to restore the board position to its state immediately before the
/// move was made.
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct MoveRecord {
/// The color of the player who made the move
pub color: Color,
/// The move played
pub ply: Move,
/// The en passant square when the move was made
pub en_passant_target: Option<Square>,
/// Castling rights for all players when the move was made
pub castling_rights: CastleRights,
/// The half move clock when the move was made
pub half_move_clock: HalfMoveClock,
/// The piece captured by the move, if any
pub captured_piece: Option<Piece>,
}
impl MoveRecord {
pub fn new(board: &Board, ply: Move, capture: Option<Piece>) -> Self {
Self {
color: board.active_color,
ply,
en_passant_target: board.en_passant_target,
castling_rights: board.castling_rights,
half_move_clock: board.half_move_clock,
captured_piece: capture,
}
}
}

View file

@ -9,11 +9,10 @@ use chessfriend_moves::{
AllPiecesMoveGenerator, BishopMoveGenerator, KingMoveGenerator, KnightMoveGenerator,
PawnMoveGenerator, QueenMoveGenerator, RookMoveGenerator,
},
GeneratedMove,
GeneratedMove, Move, MoveRecord,
};
pub use make_move::{MakeMoveError, ValidateMove};
use crate::move_record::MoveRecord;
use captures::CapturesList;
use chessfriend_bitboard::BitBoard;
use chessfriend_board::{

View file

@ -1,11 +1,11 @@
// Eryn Wells <eryn@erynwells.me>
use crate::{move_record::MoveRecord, Position};
use crate::Position;
use chessfriend_board::{
castle::CastleEvaluationError, movement::Movement, Board, PlacePieceError, PlacePieceStrategy,
};
use chessfriend_core::{Color, Piece, Rank, Square, Wing};
use chessfriend_moves::Move;
use chessfriend_moves::{Move, MoveRecord};
use thiserror::Error;
type MakeMoveResult = Result<MoveRecord, MakeMoveError>;