aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/board/engine.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs
index c4aa615..2ebbd7d 100644
--- a/src/board/engine.rs
+++ b/src/board/engine.rs
@@ -434,7 +434,9 @@ impl Board {
#[cfg(test)]
mod tests {
- use crate::board::{Board, engine::PerftResult, Color};
+ use std::time::Duration;
+ use crate::{board::{Board, engine::PerftResult, Color}, square::Square, moves::{Move, MoveKind}};
+ use super::VALUE_WIN;
#[test]
fn perft() {
@@ -477,6 +479,20 @@ mod tests {
}
+ #[test]
+ fn checkmate() {
+ let fen = String::from("2kr1b1r/pp1npppp/2p1bn2/7q/5B2/2NB1Q1P/PPP1N1P1/2KR3R w - - 0 1");
+ let mut board = Board::from_FEN(fen);
+ let (score, pv) = board.iterative_deepening(8, Duration::from_secs(15));
+
+ assert_eq!(score, VALUE_WIN);
+ assert_eq!(pv, vec![
+ Move { source: Square::F3, target: Square::C6, kind: MoveKind::Capture },
+ Move { source: Square::B7, target: Square::C6, kind: MoveKind::Capture },
+ Move { source: Square::D3, target: Square::A6, kind: MoveKind::Quiet },
+ ]);
+ }
+
mod evaluation {
use crate::{moves::{Move, MoveKind}, square::Square};