aboutsummaryrefslogtreecommitdiff
path: root/src/grossmeister/search.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-09-03 19:29:54 +0300
committereug-vs <eugene@eug-vs.xyz>2023-09-03 19:29:54 +0300
commite2934b95cbad65bc89cbc285c3ece2124bf44a55 (patch)
tree99252dd59ee15cace85730f68db0cd85ea628330 /src/grossmeister/search.rs
parent9927af55dd12bc5eca7ff17e9dbc2665c42fcfb7 (diff)
downloadchessnost-e2934b95cbad65bc89cbc285c3ece2124bf44a55.tar.gz
feat: improved scoring for (semi)dead positions
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);
+ }
}