properly fix max_depth

This commit is contained in:
Simon Gardling 2025-02-21 21:52:11 -05:00
parent 409038f983
commit ad39d647b7
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -55,7 +55,7 @@ impl FutureMoves {
.filter(|&idx| self.is_connected_to_root(idx)) // put here so this will not extend needlessly before prunes .filter(|&idx| self.is_connected_to_root(idx)) // put here so this will not extend needlessly before prunes
.collect(); .collect();
for i in self.current_depth..=self.max_depth { for i in (self.current_depth + 1)..=self.max_depth {
next_nodes = next_nodes next_nodes = next_nodes
.into_iter() .into_iter()
.progress_with_style( .progress_with_style(
@ -425,4 +425,26 @@ mod tests {
assert_ne!(futm.arena[2].i, 1234, "dummy value still exists"); 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);
}
} }