diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 01:18:51 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 01:18:51 +0300 |
commit | 0d8860bd88c49641093434d2f96299b27a0ff641 (patch) | |
tree | dfeb7881d2ab8d954609093c2befb85fd1e5fbbc /src | |
parent | 68986d0b26ee2b02e34230b64bfb6f08dcf5ed7b (diff) | |
download | chessnost-0d8860bd88c49641093434d2f96299b27a0ff641.tar.gz |
test: add checkmate test case
Diffstat (limited to 'src')
-rw-r--r-- | src/board/engine.rs | 18 |
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}; |