From ad39d647b7c56ffaf0d1e16743aa87f742485922 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 21 Feb 2025 21:52:11 -0500 Subject: [PATCH] properly fix max_depth --- src/logic/future_moves.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index 09fa5f9..4903a62 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -55,7 +55,7 @@ impl FutureMoves { .filter(|&idx| self.is_connected_to_root(idx)) // put here so this will not extend needlessly before prunes .collect(); - for i in self.current_depth..=self.max_depth { + for i in (self.current_depth + 1)..=self.max_depth { next_nodes = next_nodes .into_iter() .progress_with_style( @@ -425,4 +425,26 @@ mod tests { assert_ne!(futm.arena[2].i, 1234, "dummy value still exists"); } + + #[test] + fn expand_layer_test() { + let mut futm = FutureMoves::new(Piece::Black, 1, 1); + futm.arena.push(Move { + i: 0, + j: 0, + board: Board::new().starting_pos(), + winner: Winner::None, + parent: None, + children: Vec::new(), + value: 0, + self_value: 0, + color: Piece::Black, + lazy_children: false, + }); + + futm.current_root = Some(0); + + futm.extend_layers(); + assert_eq!(futm.arena_len(), 5); + } }