diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 08:20:09 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 08:23:46 +0300 |
commit | 2a67d2266b513d9707bacd67fe93c89b49597b07 (patch) | |
tree | 65aadd2ac384f8da109a97a2252ee7c8c6e988c9 | |
parent | 688461af14f75e488b3a96ae991d85199c8cdc93 (diff) | |
download | chessnost-2a67d2266b513d9707bacd67fe93c89b49597b07.tar.gz |
test: add weird knight sacrifice test-case
-rw-r--r-- | src/board/engine.rs | 19 |
1 files changed, 16 insertions, 3 deletions
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] |