diff --git a/benches/future_children.rs b/benches/future_children.rs index 2d51883..02e3bf1 100644 --- a/benches/future_children.rs +++ b/benches/future_children.rs @@ -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()); diff --git a/src/complexagent.rs b/src/complexagent.rs index 8b123ab..d8bfed8 100644 --- a/src/complexagent.rs +++ b/src/complexagent.rs @@ -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, diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index 7718f7c..a41f5a6 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -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`