[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

@ -6,8 +6,10 @@ pub mod testing;
mod builder;
mod defs;
mod moves;
mod record;
pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult};
pub use defs::{Kind, PromotionShape};
pub use generators::GeneratedMove;
pub use moves::Move;
pub use record::MoveRecord;

View file

@ -1,14 +1,14 @@
// Eryn Wells <eryn@erynwells.me>
use crate::Move;
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 {
pub struct MoveRecord {
/// The color of the player who made the move
pub color: Color,
@ -29,6 +29,7 @@ pub(crate) struct MoveRecord {
}
impl MoveRecord {
#[must_use]
pub fn new(board: &Board, ply: Move, capture: Option<Piece>) -> Self {
Self {
color: board.active_color,

View file

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

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>;