arena size fixes
This commit is contained in:
parent
12a6881070
commit
956386fb66
@ -13,11 +13,11 @@ pub struct ComplexAgent {
|
||||
impl ComplexAgent {
|
||||
pub const fn new(color: Piece) -> Self {
|
||||
const CONFIG: FutureMoveConfig = FutureMoveConfig {
|
||||
max_depth: 13,
|
||||
max_depth: 20,
|
||||
min_arena_depth_sub: 3,
|
||||
top_k_children: 2,
|
||||
up_to_minus: 3,
|
||||
max_arena_size: 10_000_000,
|
||||
max_arena_size: 50_000_000,
|
||||
};
|
||||
Self {
|
||||
color,
|
||||
|
||||
@ -3,7 +3,7 @@ use crate::{
|
||||
repr::{Board, Coord, Piece, Winner},
|
||||
};
|
||||
use indicatif::{ProgressIterator, ProgressStyle};
|
||||
use std::{collections::HashMap, hash::BuildHasherDefault};
|
||||
use std::{collections::HashMap, hash::BuildHasherDefault, ops::ControlFlow};
|
||||
|
||||
pub struct FutureMoves {
|
||||
/// Arena containing all [`Move`]
|
||||
@ -63,11 +63,6 @@ impl FutureMoves {
|
||||
/// only `pub` for the sake of benchmarking
|
||||
pub fn extend_layers(&mut self) {
|
||||
for _ 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;
|
||||
}
|
||||
|
||||
let pstyle_inner = if cfg!(test) {
|
||||
""
|
||||
} else {
|
||||
@ -78,7 +73,7 @@ impl FutureMoves {
|
||||
)
|
||||
};
|
||||
|
||||
(0..self.arena.len())
|
||||
let cf = (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| {
|
||||
let got = &self.arena[idx];
|
||||
@ -88,13 +83,23 @@ impl FutureMoves {
|
||||
.collect::<Vec<usize>>()
|
||||
.into_iter()
|
||||
.progress_with_style(ProgressStyle::with_template(pstyle_inner).unwrap())
|
||||
.for_each(|node_idx| {
|
||||
.try_for_each(|node_idx| {
|
||||
self.generate_children(node_idx).last();
|
||||
self.arena[node_idx].tried_children = true;
|
||||
|
||||
if self.arena_len() >= self.config.max_arena_size {
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
});
|
||||
|
||||
self.prune_bad_children();
|
||||
self.current_depth += 1;
|
||||
if cf.is_break() {
|
||||
dbg!("extend_layers: early break ({})", self.arena_len());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@ pub mod repr;
|
||||
fn main() {
|
||||
let player1 = complexagent::ComplexAgent::new(Piece::Black);
|
||||
// let player2 = complexagent::ComplexAgent::new(Piece::White);
|
||||
// let player2 = agent::ManualAgent::new(Piece::White);
|
||||
let player2 = agent::RandomAgent::new(Piece::White);
|
||||
let player2 = agent::ManualAgent::new(Piece::White);
|
||||
// let player2 = agent::RandomAgent::new(Piece::White);
|
||||
let mut game = Game::new(Box::new(player1), Box::new(player2));
|
||||
game.game_loop();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user