zero-index FutureMoves::depth_of
This commit is contained in:
parent
17ea2e8e98
commit
9f9472939e
@ -68,7 +68,7 @@ impl FutureMoves {
|
||||
self.generate_children(
|
||||
node_idx,
|
||||
if self.arena[node_idx].lazy_children {
|
||||
self.depth_of(node_idx) - 1
|
||||
self.depth_of(node_idx)
|
||||
} else {
|
||||
i
|
||||
} > self.lazy_expire,
|
||||
@ -168,10 +168,10 @@ impl FutureMoves {
|
||||
Some(new_indices)
|
||||
}
|
||||
|
||||
/// Given an index from `self.arena`, what depth is it at? 1-indexed (ROOT IS AT INDEX 1)
|
||||
/// Given an index from `self.arena`, what depth is it at? 0-indexed
|
||||
fn depth_of(&self, node_idx: usize) -> usize {
|
||||
let mut depth = 0;
|
||||
let mut current = Some(node_idx);
|
||||
let mut current = self.arena[node_idx].parent;
|
||||
while let Some(parent_idx) = current {
|
||||
depth += 1;
|
||||
current = self.arena[parent_idx].parent;
|
||||
@ -298,7 +298,7 @@ impl FutureMoves {
|
||||
/// Update current root without modifying or pruning the Arena
|
||||
fn update_root_idx_raw(&mut self, idx: usize) {
|
||||
self.current_root = Some(idx);
|
||||
self.current_depth -= self.depth_of(idx) - 1;
|
||||
self.current_depth -= self.depth_of(idx);
|
||||
}
|
||||
|
||||
/// Update current root index while pruning and extending the tree (also recalculate values)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user