aboutsummaryrefslogtreecommitdiff
path: root/src/grossmeister/search.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grossmeister/search.rs')
-rw-r--r--src/grossmeister/search.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index 2d20e3a..cad2b99 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -71,16 +71,16 @@ impl Grossmeister {
}
}
- if depth_left == 0 {
- return (self.quiscence(alpha, beta, root_distance), principal_variation);
- }
-
// Mate distance pruning
let mating_score = Grossmeister::MDP(&mut alpha, &mut beta, root_distance);
if mating_score != 0.0 {
return (mating_score, principal_variation)
}
+ if depth_left == 0 {
+ return (self.quiscence(alpha, beta, root_distance), principal_variation);
+ }
+
let mut should_pv_search = true;
let mut legal_move_found = false;
@@ -509,4 +509,16 @@ mod tests {
dbg!(score, pv);
assert_eq!(SCORE_MATE - score, 3.0); // Mate in 3 plies
}
+
+ #[test]
+ fn unwinnable() {
+ let fen = String::from("8/8/2P1k3/1K1n4/8/8/8/8 b - - 0 55");
+ let board = Board::from_FEN(fen);
+
+ let mut gm = Grossmeister::new(board);
+ gm.debug = true;
+ let (score, pv) = gm.iterative_deepening(5);
+ dbg!(score, pv);
+ assert!(score <= 0.0);
+ }
}