Skip to content

Commit

Permalink
Remove From impls for Move
Browse files Browse the repository at this point in the history
These won't work if we change Move to contain more information.
  • Loading branch information
jgilchrist committed Oct 31, 2024
1 parent 327f2fe commit 5c63669
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 0 additions & 12 deletions src/chess/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ impl Move {
}
}

impl From<(Square, Square)> for Move {
fn from((src, dst): (Square, Square)) -> Self {
Self::new(src, dst)
}
}

impl From<(Square, Square, PromotionPieceKind)> for Move {
fn from((src, dst, promotion): (Square, Square, PromotionPieceKind)) -> Self {
Self::new_with_promotion(src, dst, promotion)
}
}

impl std::fmt::Debug for Move {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
Expand Down
2 changes: 1 addition & 1 deletion src/engine/search/move_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {
let game = Game::new();

let mut moves: Vec<Move> = Vec::new();
let mut move_picker = MovePicker::new(Some((G1, F3).into()));
let mut move_picker = MovePicker::new(Some(Move::new(G1, F3)));

let search_state = SearchState::new();
let persistent_state = PersistentState::new(16);
Expand Down
12 changes: 8 additions & 4 deletions src/engine/see.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,26 @@ pub fn see(game: &Game, mv: Move, threshold: Eval) -> bool {
mod tests {
use super::*;
use crate::chess::game::Game;
use crate::chess::moves::MoveListExt;
use crate::chess::square::squares::all::*;
use crate::chess::square::Square;

fn should_be_good_capture(fen: &str, mv: impl Into<Move>) {
fn should_be_good_capture(fen: &str, mv: (Square, Square)) {
crate::init();

let game = Game::from_fen(fen).unwrap();
let mv = game.moves().expect_matching(mv.0, mv.1, None);

assert!(see(&game, mv.into(), Eval(0)));
assert!(see(&game, mv, Eval(0)));
}

fn should_be_bad_capture(fen: &str, mv: impl Into<Move>) {
fn should_be_bad_capture(fen: &str, mv: (Square, Square)) {
crate::init();

let game = Game::from_fen(fen).unwrap();
let mv = game.moves().expect_matching(mv.0, mv.1, None);

assert!(!see(&game, mv.into(), Eval(0)));
assert!(!see(&game, mv, Eval(0)));
}

#[test]
Expand Down

0 comments on commit 5c63669

Please sign in to comment.