From 0d8860bd88c49641093434d2f96299b27a0ff641 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 29 Jan 2023 01:18:51 +0300 Subject: test: add checkmate test case --- src/board/engine.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/board') 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}; -- cgit v1.2.3