From c0224f1a051eb3905dbe29703d39122fea6c2099 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 4 Mar 2025 16:00:57 -0500 Subject: [PATCH] elo: progress bar --- Cargo.lock | 1 + Cargo.toml | 2 +- src/elo.rs | 38 ++++++++++++++++++++++++-------------- src/main.rs | 4 ++-- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cf026b..f97a5d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,6 +252,7 @@ dependencies = [ "console", "number_prefix", "portable-atomic", + "rayon", "unicode-width", "web-time", ] diff --git a/Cargo.toml b/Cargo.toml index 5e93ef8..7ab808c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ debug = true arrayvec = "0.7" const_fn = "0.4" either = "1.13" -indicatif = "0.17" +indicatif = { version = "0.17", features = [ "rayon" ] } nohash-hasher = "0.2" num = "0.4" rand = "0.9" diff --git a/src/elo.rs b/src/elo.rs index 9d10632..f4e4531 100644 --- a/src/elo.rs +++ b/src/elo.rs @@ -5,6 +5,7 @@ use crate::{ logic::{ChildrenEvalMethod, FutureMoveConfig}, repr::{Board, Piece, Winner}, }; +use indicatif::{ParallelProgressIterator, ProgressStyle}; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use skillratings::{ elo::{elo, EloConfig, EloRating}, @@ -23,20 +24,24 @@ pub fn run() { children_eval_method: ChildrenEvalMethod::Average, }; - let vec: Vec<(String, Box Box>)> = (3..=6) - .map(move |d| -> (String, Box Box>) { - ( - format!("ComplexAgentD{}", d), - Box::new(move |piece| { - Box::new(ComplexAgent::new( - piece, - FutureMoveConfig { - max_depth: d, - ..FMV_BASE - }, - )) - }), - ) + let vec: Vec<(String, Box Box>)> = (5..=6) + .flat_map(move |d| { + // -> (String, Box Box>) + [true, false].map(move |p| -> (String, Box Box>) { + ( + format!("ComplexAgentD{}P{}", d, p), + Box::new(move |piece| { + Box::new(ComplexAgent::new( + piece, + FutureMoveConfig { + max_depth: d, + do_not_prune: p, + ..FMV_BASE + }, + )) + }), + ) + }) }) .collect(); @@ -93,6 +98,11 @@ impl PlayerArena { .collect::>() // after the agents are created, we can multithread the games being played .into_par_iter() + .progress_with_style( + ProgressStyle::with_template("[{elapsed_precise}] {pos:>7}/{len:7} ETA: {eta}") + .expect("invalid ProgressStyle") + .progress_chars("##-"), + ) .map(|((i, j), (p1, p2))| (i, j, Self::play_two_inner(p1, p2))) .collect::>() // collect and process the outcomes of all the games diff --git a/src/main.rs b/src/main.rs index c870b35..28bcfe7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,8 @@ pub mod repr; // TODO! make this agent configuration a config option via `clap-rs` fn main() { - // elo::run(); - // return; + elo::run(); + return; let player1 = complexagent::ComplexAgent::new( Piece::Black, FutureMoveConfig {