[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 builder;
mod defs; mod defs;
mod moves; mod moves;
mod record;
pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult}; pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult};
pub use defs::{Kind, PromotionShape}; pub use defs::{Kind, PromotionShape};
pub use generators::GeneratedMove; pub use generators::GeneratedMove;
pub use moves::Move; pub use moves::Move;
pub use record::MoveRecord;

View file

@ -1,14 +1,14 @@
// Eryn Wells <eryn@erynwells.me> // Eryn Wells <eryn@erynwells.me>
use crate::Move;
use chessfriend_board::{board::HalfMoveClock, Board, CastleRights}; use chessfriend_board::{board::HalfMoveClock, Board, CastleRights};
use chessfriend_core::{Color, Piece, Square}; 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 /// 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 /// necessary to restore the board position to its state immediately before the
/// move was made. /// move was made.
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct MoveRecord { pub struct MoveRecord {
/// The color of the player who made the move /// The color of the player who made the move
pub color: Color, pub color: Color,
@ -29,6 +29,7 @@ pub(crate) struct MoveRecord {
} }
impl MoveRecord { impl MoveRecord {
#[must_use]
pub fn new(board: &Board, ply: Move, capture: Option<Piece>) -> Self { pub fn new(board: &Board, ply: Move, capture: Option<Piece>) -> Self {
Self { Self {
color: board.active_color, color: board.active_color,

View file

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

View file

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

View file

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