Skip to content

Commit 2285af4

Browse files
Fix go depth off by one sometimes
Bench: 3554133
1 parent 5f4f8c6 commit 2285af4

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/search.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
movepick::{MovePicker, Stage},
66
stack::Stack,
77
thread::{RootMove, Status, ThreadData},
8+
time::Limits,
89
transposition::{Bound, TtDepth},
910
types::{
1011
ArrayVec, Color, MAX_PLY, Move, Piece, PieceType, Score, Square, draw, is_decisive, is_loss, is_valid, is_win,
@@ -77,8 +78,13 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
7778
let mut best_move_changes = 0;
7879
let mut soft_stop_voted = false;
7980

81+
let max_depth = match td.time_manager.limits() {
82+
Limits::Depth(maximum) => maximum,
83+
_ => MAX_PLY as i32,
84+
};
85+
8086
// Iterative Deepening
81-
for depth in 1..MAX_PLY as i32 {
87+
for depth in 1..=max_depth {
8288
best_move_changes /= 2;
8389

8490
td.sel_depth = 0;

src/time.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ impl TimeManager {
6969

7070
pub fn soft_limit(&self, td: &ThreadData, multiplier: impl Fn() -> f32) -> bool {
7171
match self.limits {
72-
Limits::Infinite => false,
73-
Limits::Depth(maximum) => td.completed_depth >= maximum,
72+
Limits::Infinite | Limits::Depth(_) => false,
7473
Limits::Nodes(maximum) => td.shared.nodes.aggregate() >= maximum,
7574
Limits::Time(maximum) => self.start_time.elapsed() >= Duration::from_millis(maximum),
7675
_ => self.start_time.elapsed() >= Duration::from_secs_f32(self.soft_bound.as_secs_f32() * multiplier()),

0 commit comments

Comments
 (0)