diff --git a/src/elo.rs b/src/elo.rs index 3a2a6de..d34c6ea 100644 --- a/src/elo.rs +++ b/src/elo.rs @@ -2,7 +2,7 @@ use crate::{ agent::{Agent, RandomAgent}, complexagent::ComplexAgent, game_inner::GameInner, - logic::{ChildrenEvalMethod, FutureMoveConfig}, + logic::{ChildrenEvalMethod, FutureMoveConfig, FutureMoves}, repr::{Board, Piece, Winner}, }; use indicatif::{ProgressBar, ProgressStyle}; @@ -18,18 +18,25 @@ type AgentMaker = Box Box>; #[allow(dead_code)] pub fn run() { + let total_memory = 30_000_000_000; + let num_threads = std::thread::available_parallelism() + .map(NonZero::get) + .expect("unable to get number of threads"); + let mem_per_thread = total_memory / num_threads; + let fmv_base = FutureMoveConfig { - max_depth: 20, + max_depth: 10, min_arena_depth: 14, top_k_children: 2, up_to_minus: 10, - max_arena_size: usize::MAX, + // max_arena_size: usize::MAX, + max_arena_size: mem_per_thread / FutureMoves::ARENA_ENTRY_SIZE, do_prune: false, print: false, children_eval_method: Default::default(), }; - let configs = [4, 5, 6] + let configs = [20] .into_iter() .map(move |d| FutureMoveConfig { max_depth: d, @@ -129,7 +136,7 @@ pub fn run() { let mut arena = PlayerArena::new(vec); - arena.prop_arena(100); + arena.prop_arena(500); println!("{}", arena); } diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index bf66c7f..fcabde2 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -109,6 +109,9 @@ impl FutureMoves { } } + pub const ARENA_ENTRY_SIZE: usize = + size_of::() + size_of::() * (Board::AREA.0 as usize / 4); + /// Return the length of the Arena pub fn arena_len(&self) -> usize { self.arena.len() @@ -382,12 +385,15 @@ impl FutureMoves { /// Return the best move which is a child of `self.current_root` pub fn best_move(&self) -> Option { self.current_root - .and_then(|x| { - self.arena[x] + .and_then(|x| match self.config.children_eval_method { + ChildrenEvalMethod::MinMax => self.arena[x] .children .iter() - // this would be considered `minimax` - .max_by_key(|&&idx| self.arena[idx].value) + .max_by_key(|&&idx| self.arena[idx].value.value), + ChildrenEvalMethod::MinMaxProb => self.arena[x] + .children + .iter() + .max_by_key(|&&idx| self.arena[idx].value), }) .inspect(|&&x| { assert_eq!(