aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-08-19 21:23:15 +0300
committereug-vs <eugene@eug-vs.xyz>2023-08-19 21:23:15 +0300
commit90190dc10c9d4ed00d4bb976d42c73f2f30098a5 (patch)
tree998aaddcd49fcff7e4fe95c3e34cbb9c2c9c5afd
parent9bf3c532018bb96792d60840b1c37cd9df94b927 (diff)
downloadchessnost-90190dc10c9d4ed00d4bb976d42c73f2f30098a5.tar.gz
feat: also check 3-fold repetition in quiesence
-rw-r--r--src/grossmeister/search.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index 43423e4..532e9ed 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -22,6 +22,11 @@ impl Grossmeister {
let mut killer_moves = Vec::new();
let color = self.board.color();
+ if self.board.positions.iter().filter(|p| **p == self.board.hash).count() >= 3 {
+ // Draw by repetition
+ return (0.0, principal_variation);
+ }
+
if let Some(transposition) = self.transposition() {
if transposition.depth == depth_left {
match transposition.node_type {
@@ -45,11 +50,6 @@ impl Grossmeister {
}
}
- if self.board.positions.iter().filter(|p| **p == self.board.hash).count() >= 3 {
- // Draw by repetition
- return (0.0, principal_variation);
- }
-
if depth_left == 0 {
return (self.quiscence(alpha, beta), principal_variation);
}
@@ -154,6 +154,11 @@ impl Grossmeister {
let mut moves = self.board.generate_pseudolegal_moves();
moves = self.order_moves(moves, Vec::new());
+ if self.board.positions.iter().filter(|p| **p == self.board.hash).count() >= 3 {
+ // Draw by repetition
+ return 0.0;
+ }
+
if !self.board.is_king_in_check(color) {
// If we are not in check, we can evaluate stand pat
let stand_pat = self.evaluate();