Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
fix: fixed bug causing the engine to ignore draws
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhammer committed Aug 20, 2024
1 parent bb395d7 commit 6a40b1a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions brogle/src/search/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl<'a> Searcher<'a> {
// Reached the end of the depth; start a qsearch for captures only
if depth == 0 {
return self.quiescence(game, ply + 1, alpha, beta);
// return Ok(Evaluator::new(game).eval());
}

let mut moves = game.legal_moves();
Expand All @@ -109,13 +108,14 @@ impl<'a> Searcher<'a> {

// Make the score move on the position, getting a new position in return
let new_pos = game.clone().with_move_made(mv);
if new_pos.is_repetition() || new_pos.can_draw_by_fifty() {
// eprintln!("Repetition in Negamax after {mv} on {}", new_pos.fen());
continue;
}

// Recursively search our opponent's responses
let score = -self.negamax(&new_pos, depth - 1, ply + 1, -beta, -alpha)?;
// If it's a draw, don't recurse, but set the score to 0 and continue as normal
let score = if new_pos.is_repetition() || new_pos.can_draw_by_fifty() {
0
} else {
// Otherwise, recursively search our opponent's responses
-self.negamax(&new_pos, depth - 1, ply + 1, -beta, -alpha)?
};
self.data.nodes_searched += 1;

// Check if we've run out of time or if we've been told to stop searching
Expand Down

0 comments on commit 6a40b1a

Please sign in to comment.