arena size fixes
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::{
|
||||
repr::{Board, Coord, Piece, Winner},
|
||||
};
|
||||
use indicatif::{ProgressIterator, ProgressStyle};
|
||||
use std::{collections::HashMap, hash::BuildHasherDefault};
|
||||
use std::{collections::HashMap, hash::BuildHasherDefault, ops::ControlFlow};
|
||||
|
||||
pub struct FutureMoves {
|
||||
/// Arena containing all [`Move`]
|
||||
@@ -63,11 +63,6 @@ impl FutureMoves {
|
||||
/// only `pub` for the sake of benchmarking
|
||||
pub fn extend_layers(&mut self) {
|
||||
for _ in (self.current_depth + 1)..=self.config.max_depth {
|
||||
if self.arena_len() >= self.config.max_arena_size {
|
||||
dbg!("extend_layers: early break ({})", self.arena_len());
|
||||
break;
|
||||
}
|
||||
|
||||
let pstyle_inner = if cfg!(test) {
|
||||
""
|
||||
} else {
|
||||
@@ -78,7 +73,7 @@ impl FutureMoves {
|
||||
)
|
||||
};
|
||||
|
||||
(0..self.arena.len())
|
||||
let cf = (0..self.arena.len())
|
||||
// we want to select all nodes that don't have children, or are lazy (need to maybe be regenerated)
|
||||
.filter(|&idx| {
|
||||
let got = &self.arena[idx];
|
||||
@@ -88,13 +83,23 @@ impl FutureMoves {
|
||||
.collect::<Vec<usize>>()
|
||||
.into_iter()
|
||||
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
||||
.for_each(|node_idx| {
|
||||
.try_for_each(|node_idx| {
|
||||
self.generate_children(node_idx).last();
|
||||
self.arena[node_idx].tried_children = true;
|
||||
|
||||
if self.arena_len() >= self.config.max_arena_size {
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
});
|
||||
|
||||
self.prune_bad_children();
|
||||
self.current_depth += 1;
|
||||
if cf.is_break() {
|
||||
dbg!("extend_layers: early break ({})", self.arena_len());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user