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