add limit to size of arena

This commit is contained in:
Simon Gardling 2025-02-12 22:33:09 -05:00
parent a086d75f42
commit 3815ff1a95
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -46,19 +46,22 @@ struct FutureMoves {
arena: Vec<Move>,
current_root: Option<usize>,
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),
}
}
}