diff options
Diffstat (limited to 'src/grossmeister/search.rs')
-rw-r--r-- | src/grossmeister/search.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs index 5c03887..43423e4 100644 --- a/src/grossmeister/search.rs +++ b/src/grossmeister/search.rs @@ -45,6 +45,11 @@ 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); } @@ -447,7 +452,7 @@ mod tests { let fen = String::from("2kr1b1r/pp1npppp/2p1bn2/7q/5B2/2NB1Q1P/PPP1N1P1/2KR3R w - - 0 1"); let board = Board::from_FEN(fen); let mut gm = Grossmeister::new(board); - let (score, pv) = gm.iterative_deepening(8, Duration::from_secs(15), true); + let (score, pv) = gm.iterative_deepening(8); assert_eq!(score, VALUE_WIN); assert_eq!(pv, vec![ @@ -464,7 +469,7 @@ mod tests { board.ply += 1; // TODO: remove me when FEN parsing includes side to move let mut gm = Grossmeister::new(board); - let (_, pv) = gm.iterative_deepening(6, Duration::from_secs(60), true); + let (_, pv) = gm.iterative_deepening(6); assert_eq!( pv[0], Move { source: Square::F5, target: Square::H4, kind: MoveKind::Quiet }, @@ -478,7 +483,7 @@ mod tests { let board = Board::from_FEN(fen); let mut gm = Grossmeister::new(board); - let (_, pv) = gm.iterative_deepening(5, Duration::from_secs(60), true); + let (_, pv) = gm.iterative_deepening(5); assert_eq!( pv[0], Move { source: Square::C2, target: Square::C3, kind: MoveKind::Quiet }, |