diff --git a/src/complexagent.rs b/src/complexagent.rs index 1132f8d..2568ec2 100644 --- a/src/complexagent.rs +++ b/src/complexagent.rs @@ -46,19 +46,22 @@ struct FutureMoves { arena: Vec, current_root: Option, current_depth: usize, + max_depth: usize, + max_arena: usize, /// Color w.r.t agent_color: Piece, } impl FutureMoves { - pub const fn new(agent_color: Piece, max_depth: usize) -> Self { + pub const fn new(agent_color: Piece, max_depth: usize, max_arena: usize) -> Self { Self { arena: Vec::new(), current_root: None, current_depth: 0, max_depth, + max_arena, agent_color, } } @@ -84,6 +87,9 @@ impl FutureMoves { let mut next_color = !color; for _ in 0..remaining_depth { + if self.arena.len() >= self.max_arena { + break; + } next_nodes = next_nodes .into_iter() .flat_map(|node_idx| { @@ -243,10 +249,11 @@ pub struct ComplexAgent { impl ComplexAgent { pub const fn new(color: Piece) -> Self { - const MAX_DEPTH: usize = 8; + const MAX_DEPTH: usize = 10; + const MAX_ARENA: usize = 20_000_000; Self { color, - future_moves: FutureMoves::new(color, MAX_DEPTH), + future_moves: FutureMoves::new(color, MAX_DEPTH, MAX_ARENA), } } }