fix logic and minmax
This commit is contained in:
parent
eedc80e46a
commit
6b9516a510
17
src/elo.rs
17
src/elo.rs
@ -2,7 +2,7 @@ use crate::{
|
|||||||
agent::{Agent, RandomAgent},
|
agent::{Agent, RandomAgent},
|
||||||
complexagent::ComplexAgent,
|
complexagent::ComplexAgent,
|
||||||
game_inner::GameInner,
|
game_inner::GameInner,
|
||||||
logic::{ChildrenEvalMethod, FutureMoveConfig},
|
logic::{ChildrenEvalMethod, FutureMoveConfig, FutureMoves},
|
||||||
repr::{Board, Piece, Winner},
|
repr::{Board, Piece, Winner},
|
||||||
};
|
};
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
@ -18,18 +18,25 @@ type AgentMaker = Box<dyn Fn(Piece) -> Box<dyn Agent>>;
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn run() {
|
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 {
|
let fmv_base = FutureMoveConfig {
|
||||||
max_depth: 20,
|
max_depth: 10,
|
||||||
min_arena_depth: 14,
|
min_arena_depth: 14,
|
||||||
top_k_children: 2,
|
top_k_children: 2,
|
||||||
up_to_minus: 10,
|
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,
|
do_prune: false,
|
||||||
print: false,
|
print: false,
|
||||||
children_eval_method: Default::default(),
|
children_eval_method: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let configs = [4, 5, 6]
|
let configs = [20]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(move |d| FutureMoveConfig {
|
.map(move |d| FutureMoveConfig {
|
||||||
max_depth: d,
|
max_depth: d,
|
||||||
@ -129,7 +136,7 @@ pub fn run() {
|
|||||||
|
|
||||||
let mut arena = PlayerArena::new(vec);
|
let mut arena = PlayerArena::new(vec);
|
||||||
|
|
||||||
arena.prop_arena(100);
|
arena.prop_arena(500);
|
||||||
|
|
||||||
println!("{}", arena);
|
println!("{}", arena);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,9 @@ impl FutureMoves {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const ARENA_ENTRY_SIZE: usize =
|
||||||
|
size_of::<Move>() + size_of::<usize>() * (Board::AREA.0 as usize / 4);
|
||||||
|
|
||||||
/// Return the length of the Arena
|
/// Return the length of the Arena
|
||||||
pub fn arena_len(&self) -> usize {
|
pub fn arena_len(&self) -> usize {
|
||||||
self.arena.len()
|
self.arena.len()
|
||||||
@ -382,12 +385,15 @@ impl FutureMoves {
|
|||||||
/// Return the best move which is a child of `self.current_root`
|
/// Return the best move which is a child of `self.current_root`
|
||||||
pub fn best_move(&self) -> Option<MoveCoord> {
|
pub fn best_move(&self) -> Option<MoveCoord> {
|
||||||
self.current_root
|
self.current_root
|
||||||
.and_then(|x| {
|
.and_then(|x| match self.config.children_eval_method {
|
||||||
self.arena[x]
|
ChildrenEvalMethod::MinMax => self.arena[x]
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
// this would be considered `minimax`
|
.max_by_key(|&&idx| self.arena[idx].value.value),
|
||||||
.max_by_key(|&&idx| self.arena[idx].value)
|
ChildrenEvalMethod::MinMaxProb => self.arena[x]
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.max_by_key(|&&idx| self.arena[idx].value),
|
||||||
})
|
})
|
||||||
.inspect(|&&x| {
|
.inspect(|&&x| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user