This commit is contained in:
2025-03-03 23:50:11 -05:00
parent d48670dbdb
commit e8521ac96d
2 changed files with 54 additions and 23 deletions

View File

@@ -123,13 +123,39 @@ impl FutureMoves {
});
self.prune_bad_children();
self.current_depth += 1;
if cf.is_break() {
// pruning unfinished level
let by_depth = self.by_depth(0..self.arena.len());
let mut bdh = HashMap::new();
for (a, b) in by_depth {
bdh.insert(a, b);
}
for &i in bdh.get(&(self.current_depth + 1)).unwrap_or(&Vec::new()) {
self.remove(i);
}
for &i in bdh.get(&self.current_depth).unwrap_or(&Vec::new()) {
self.arena[i].tried_children = false;
}
self.refocus_tree();
return;
}
self.current_depth += 1;
}
}
fn remove(&mut self, index: usize) {
if let Some(parent) = self.arena[index].parent {
self.arena[parent].children.retain(|&j| j != index);
}
self.arena[index].parent = None;
}
/// Determines if a [`Move`] at index `idx` is connected to `self.current_root`
/// Returns `false` if `self.current_root` is None
fn is_connected_to_root(&self, idx: usize) -> bool {