future_move: add comments to pruning logic

This commit is contained in:
Simon Gardling 2025-03-25 13:01:31 -04:00
parent e1207153ab
commit 9757264854
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -468,9 +468,7 @@ impl FutureMoves {
// values are needed in order to prune and see what's best
self.compute_values(0..self.arena_len());
let by_depth = self.by_depth(0..self.arena.len());
for (depth, indexes) in by_depth {
for (depth, indexes) in self.by_depth(0..self.arena.len()) {
// TODO! maybe update by_depth every iteration or something?
if depth > self.current_depth.saturating_sub(self.config.up_to_minus) {
return;
@ -482,15 +480,25 @@ impl FutureMoves {
}
for idx in indexes {
// TODO! add check here to make sure that this index is
// still connected to the root from the previous trimming
// steps
let mut m = self.arena[idx].clone();
// don't attempt and trim moves that have already been trimmed
if m.is_trimmed {
continue;
}
m.is_trimmed = true;
m.sort_children(&self.arena);
// prune the selected non top_k children
if m.children.len() > self.config.top_k_children {
// remove parent-child relation
let drained = m.children.drain(self.config.top_k_children..);
for idx in drained {
// remove child-parent relation
self.arena[idx].parent = None;
}
}