diff --git a/src/complexagent.rs b/src/complexagent.rs index ccc6c57..a2d6f16 100644 --- a/src/complexagent.rs +++ b/src/complexagent.rs @@ -262,9 +262,14 @@ impl FutureMoves { self.arena .iter() .enumerate() - .find_map(|(idx, node)| { - (node.parent == self.current_root && node.i == i && node.j == j).then_some(idx) + .filter(|(_, node)| { + node.parent == self.current_root + && self.current_root.is_some() + && node.i == i + && node.j == j }) + .next() + .map(|x| x.0) .inspect(|&root| self.update_root_idx(root)) .is_some() }