From ff1ded0a7436d139c87dc575e967c32aaca4c5c6 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 28 Feb 2025 21:42:03 -0500 Subject: [PATCH] future_moves + generate_children things --- src/logic/future_moves.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index be1241c..bbed4f9 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -110,7 +110,7 @@ impl FutureMoves { .into_iter() .progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap()) .try_for_each(|node_idx| { - self.generate_children(node_idx).last(); + self.generate_children(node_idx); self.arena[node_idx].tried_children = true; if self.arena_len() >= self.config.max_arena_size { @@ -144,10 +144,10 @@ impl FutureMoves { false } - /// Creates children for a parent (`parent`), returns an iterator it's children's indexes + /// Creates children for a parent (`parent_idx`) /// Completely unchecked, the caller should be the one who tests to make sure child generation /// hasn't already been tried on a parent - fn generate_children(&mut self, parent_idx: usize) -> impl Iterator { + fn generate_children(&mut self, parent_idx: usize) { let parent = &self.arena[parent_idx]; let new_color = !parent.color; @@ -175,11 +175,9 @@ impl FutureMoves { let new_indices = start_idx..self.arena.len(); - for child_idx in new_indices.clone() { + for child_idx in new_indices { self.set_parent_child(parent_idx, child_idx); } - - new_indices } /// Given an index from `self.arena`, what depth is it at? 0-indexed @@ -228,8 +226,8 @@ impl FutureMoves { let children_value = self.arena[idx] .children .iter() - .map(|&child| self.arena[child].value.expect("child has no value??")) - // average value of children + .flat_map(|&child| self.arena[child].value) + // sum values of children .sum::() // divide in order to calculate average value of all children .checked_div(self.arena[idx].children.len() as i128)