From 2a67d2266b513d9707bacd67fe93c89b49597b07 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 29 Jan 2023 08:20:09 +0300 Subject: test: add weird knight sacrifice test-case --- src/board/engine.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/board') diff --git a/src/board/engine.rs b/src/board/engine.rs index a710efb..5f64c39 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -476,8 +476,7 @@ mod tests { #[test] fn material() { let board = Board::new(); - assert_eq!(board.material(Color::Black), 40.0); - assert_eq!(board.material(Color::White), 40.0); + assert_eq!(board.material(Color::Black), board.material(Color::White)); } @@ -495,6 +494,20 @@ mod tests { ]); } + #[test] + fn stupid_knight_sac() { + let fen = String::from("r3k1r1/pp3ppp/1q6/2ppPn2/6P1/1PPP1P2/P1N3KP/R2QR3 b - - 0 18"); + let mut board = Board::from_FEN(fen); + board.ply += 1; // TODO: remove me when FEN parsing includes side to move + + let (_, pv) = board.iterative_deepening(6, Duration::from_secs(60)); + assert_eq!( + pv[0], + Move { source: Square::F5, target: Square::H4, kind: MoveKind::Quiet }, + "You should save this poor knight from danger!" + ); + } + mod evaluation { use crate::{moves::{Move, MoveKind}, square::Square}; @@ -537,7 +550,7 @@ mod tests { board.print(); println!("Score {}", score); - assert!(score < -4.0); + assert!(score < -3.0); } #[test] -- cgit v1.2.3