From 975726485477ac519d68bbadac85c0d67438eb7b Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 25 Mar 2025 13:01:31 -0400 Subject: [PATCH] future_move: add comments to pruning logic --- src/logic/future_moves.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index b5b6bec..452ff13 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -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; } }