aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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();