add early_break for extend_layers
This commit is contained in:
parent
9fd3b45c0e
commit
cd0ac5f538
@ -11,6 +11,7 @@ fn extend_layers_test(depth: usize) {
|
||||
start_pruning_at_minus: 4,
|
||||
top_k_children: 2,
|
||||
up_to_mod: 4,
|
||||
max_arena_size: 10_000_000,
|
||||
};
|
||||
let mut fut = FutureMoves::new(Piece::Black, config);
|
||||
fut.set_root_from_board(Board::new().starting_pos());
|
||||
|
||||
@ -13,10 +13,11 @@ pub struct ComplexAgent {
|
||||
impl ComplexAgent {
|
||||
pub const fn new(color: Piece) -> Self {
|
||||
const CONFIG: FutureMoveConfig = FutureMoveConfig {
|
||||
max_depth: 7,
|
||||
max_depth: 9,
|
||||
start_pruning_at_minus: 4,
|
||||
top_k_children: 2,
|
||||
up_to_mod: 4,
|
||||
max_arena_size: 100_000_000,
|
||||
};
|
||||
Self {
|
||||
color,
|
||||
|
||||
@ -36,6 +36,10 @@ pub struct FutureMoveConfig {
|
||||
// the lower the value, the more conservative the pruning is, what level to stop pruning at?
|
||||
// a lower value allows more possible paths
|
||||
pub up_to_mod: usize,
|
||||
|
||||
/// Max size of the arena, will not generate more if
|
||||
/// the arena is of that size or bigger
|
||||
pub max_arena_size: usize,
|
||||
}
|
||||
|
||||
impl FutureMoves {
|
||||
@ -58,6 +62,11 @@ impl FutureMoves {
|
||||
/// only `pub` for the sake of benchmarking
|
||||
pub fn extend_layers(&mut self) {
|
||||
for i 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;
|
||||
}
|
||||
|
||||
(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| {
|
||||
@ -81,11 +90,6 @@ impl FutureMoves {
|
||||
self.prune_bad_children();
|
||||
self.current_depth += 1;
|
||||
}
|
||||
assert_eq!(
|
||||
self.current_depth, self.config.max_depth,
|
||||
"iteration and extention did not extend current_depth ({}) to the max_depth ({})",
|
||||
self.current_depth, self.config.max_depth
|
||||
);
|
||||
}
|
||||
|
||||
/// Determines if a [`Move`] at index `idx` is connected to `self.current_root`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user