From f10f4d83e022b96d5ac927e4e0c3da6c6dd0bf67 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 25 Mar 2025 13:29:19 -0400 Subject: [PATCH] future_move: improve pruning logic --- src/logic/future_moves.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index 452ff13..16215ca 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -480,9 +480,16 @@ 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 + // any nodes that have no parent node and aren't + // the root node, is orphaned + if self.arena[idx].parent.is_none() && self.current_root != Some(idx) { + // propegate orphan-ness to the children + let children: Vec = self.arena[idx].children.drain(..).collect(); + for idx in children { + self.arena[idx].parent = None; + } + continue; + } let mut m = self.arena[idx].clone(); // don't attempt and trim moves that have already been trimmed