future_move: fix limiting arena size w/ multithreading

This commit is contained in:
Simon Gardling 2025-04-08 15:48:44 -04:00
parent 7e6c057127
commit ec3fc382d4
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 16 additions and 12 deletions

View File

@ -160,27 +160,31 @@ impl FutureMoves {
)
};
self.leaf_moves()
let allowed_size = self.config.max_arena_size - self.arena.len();
let got = self
.leaf_moves()
.into_iter()
.filter(|&i| self.depth_of(i) == self.current_depth)
.collect::<Vec<usize>>()
.into_par_iter()
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
.map(|parent_idx| (parent_idx, self.generate_children_raw(parent_idx)))
.collect::<Vec<(usize, Vec<Move>)>>()
.into_iter()
.for_each(|(parent_idx, moves)| {
let start_idx = self.arena.len();
self.arena.extend(moves);
.take_any(allowed_size)
.collect::<Vec<(usize, Vec<Move>)>>();
let got_len = got.len();
let new_indices = start_idx..self.arena.len();
self.arena[parent_idx].children.extend(new_indices);
});
got.into_iter().for_each(|(parent_idx, moves)| {
let start_idx = self.arena.len();
self.arena.extend(moves);
let new_indices = start_idx..self.arena.len();
self.arena[parent_idx].children.extend(new_indices);
});
self.prune_bad_children();
self.current_depth += 1;
if self.arena.len() >= self.config.max_arena_size {
if got_len == allowed_size {
// got.len() has hit the upper limit of size permitted
break;
}
}

View File

@ -32,7 +32,7 @@ fn main() {
min_arena_depth: 14,
top_k_children: 2,
up_to_minus: 10,
max_arena_size: 400_000_000,
max_arena_size: 200_000_000,
do_prune: true,
print: true,
children_eval_method: Default::default(),