future_move: fix limiting arena size w/ multithreading
This commit is contained in:
parent
7e6c057127
commit
ec3fc382d4
@ -160,16 +160,20 @@ impl FutureMoves {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.leaf_moves()
|
let allowed_size = self.config.max_arena_size - self.arena.len();
|
||||||
|
let got = self
|
||||||
|
.leaf_moves()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|&i| self.depth_of(i) == self.current_depth)
|
.filter(|&i| self.depth_of(i) == self.current_depth)
|
||||||
.collect::<Vec<usize>>()
|
.collect::<Vec<usize>>()
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
||||||
.map(|parent_idx| (parent_idx, self.generate_children_raw(parent_idx)))
|
.map(|parent_idx| (parent_idx, self.generate_children_raw(parent_idx)))
|
||||||
.collect::<Vec<(usize, Vec<Move>)>>()
|
.take_any(allowed_size)
|
||||||
.into_iter()
|
.collect::<Vec<(usize, Vec<Move>)>>();
|
||||||
.for_each(|(parent_idx, moves)| {
|
let got_len = got.len();
|
||||||
|
|
||||||
|
got.into_iter().for_each(|(parent_idx, moves)| {
|
||||||
let start_idx = self.arena.len();
|
let start_idx = self.arena.len();
|
||||||
self.arena.extend(moves);
|
self.arena.extend(moves);
|
||||||
|
|
||||||
@ -179,8 +183,8 @@ impl FutureMoves {
|
|||||||
|
|
||||||
self.prune_bad_children();
|
self.prune_bad_children();
|
||||||
self.current_depth += 1;
|
self.current_depth += 1;
|
||||||
|
if got_len == allowed_size {
|
||||||
if self.arena.len() >= self.config.max_arena_size {
|
// got.len() has hit the upper limit of size permitted
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ fn main() {
|
|||||||
min_arena_depth: 14,
|
min_arena_depth: 14,
|
||||||
top_k_children: 2,
|
top_k_children: 2,
|
||||||
up_to_minus: 10,
|
up_to_minus: 10,
|
||||||
max_arena_size: 400_000_000,
|
max_arena_size: 200_000_000,
|
||||||
do_prune: true,
|
do_prune: true,
|
||||||
print: true,
|
print: true,
|
||||||
children_eval_method: Default::default(),
|
children_eval_method: Default::default(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user