add limit to size of arena
This commit is contained in:
parent
a086d75f42
commit
3815ff1a95
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user