future_move: fix limiting arena size w/ multithreading
This commit is contained in:
parent
7e6c057127
commit
ec3fc382d4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user