future_moves + generate_children things
This commit is contained in:
parent
86d4455321
commit
ff1ded0a74
@ -110,7 +110,7 @@ impl FutureMoves {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
||||||
.try_for_each(|node_idx| {
|
.try_for_each(|node_idx| {
|
||||||
self.generate_children(node_idx).last();
|
self.generate_children(node_idx);
|
||||||
self.arena[node_idx].tried_children = true;
|
self.arena[node_idx].tried_children = true;
|
||||||
|
|
||||||
if self.arena_len() >= self.config.max_arena_size {
|
if self.arena_len() >= self.config.max_arena_size {
|
||||||
@ -144,10 +144,10 @@ impl FutureMoves {
|
|||||||
false
|
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
|
/// Completely unchecked, the caller should be the one who tests to make sure child generation
|
||||||
/// hasn't already been tried on a parent
|
/// hasn't already been tried on a parent
|
||||||
fn generate_children(&mut self, parent_idx: usize) -> impl Iterator<Item = usize> {
|
fn generate_children(&mut self, parent_idx: usize) {
|
||||||
let parent = &self.arena[parent_idx];
|
let parent = &self.arena[parent_idx];
|
||||||
|
|
||||||
let new_color = !parent.color;
|
let new_color = !parent.color;
|
||||||
@ -175,11 +175,9 @@ impl FutureMoves {
|
|||||||
|
|
||||||
let new_indices = start_idx..self.arena.len();
|
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);
|
self.set_parent_child(parent_idx, child_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_indices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given an index from `self.arena`, what depth is it at? 0-indexed
|
/// 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]
|
let children_value = self.arena[idx]
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&child| self.arena[child].value.expect("child has no value??"))
|
.flat_map(|&child| self.arena[child].value)
|
||||||
// average value of children
|
// sum values of children
|
||||||
.sum::<i128>()
|
.sum::<i128>()
|
||||||
// divide in order to calculate average value of all children
|
// divide in order to calculate average value of all children
|
||||||
.checked_div(self.arena[idx].children.len() as i128)
|
.checked_div(self.arena[idx].children.len() as i128)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user