elo: progress bar

This commit is contained in:
Simon Gardling 2025-03-04 16:00:57 -05:00
parent ea7df6a739
commit c0224f1a05
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
4 changed files with 28 additions and 17 deletions

1
Cargo.lock generated
View File

@ -252,6 +252,7 @@ dependencies = [
"console", "console",
"number_prefix", "number_prefix",
"portable-atomic", "portable-atomic",
"rayon",
"unicode-width", "unicode-width",
"web-time", "web-time",
] ]

View File

@ -25,7 +25,7 @@ debug = true
arrayvec = "0.7" arrayvec = "0.7"
const_fn = "0.4" const_fn = "0.4"
either = "1.13" either = "1.13"
indicatif = "0.17" indicatif = { version = "0.17", features = [ "rayon" ] }
nohash-hasher = "0.2" nohash-hasher = "0.2"
num = "0.4" num = "0.4"
rand = "0.9" rand = "0.9"

View File

@ -5,6 +5,7 @@ use crate::{
logic::{ChildrenEvalMethod, FutureMoveConfig}, logic::{ChildrenEvalMethod, FutureMoveConfig},
repr::{Board, Piece, Winner}, repr::{Board, Piece, Winner},
}; };
use indicatif::{ParallelProgressIterator, ProgressStyle};
use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon::iter::{IntoParallelIterator, ParallelIterator};
use skillratings::{ use skillratings::{
elo::{elo, EloConfig, EloRating}, elo::{elo, EloConfig, EloRating},
@ -23,21 +24,25 @@ pub fn run() {
children_eval_method: ChildrenEvalMethod::Average, children_eval_method: ChildrenEvalMethod::Average,
}; };
let vec: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)> = (3..=6) let vec: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)> = (5..=6)
.map(move |d| -> (String, Box<dyn Fn(Piece) -> Box<dyn Agent>>) { .flat_map(move |d| {
// -> (String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)
[true, false].map(move |p| -> (String, Box<dyn Fn(Piece) -> Box<dyn Agent>>) {
( (
format!("ComplexAgentD{}", d), format!("ComplexAgentD{}P{}", d, p),
Box::new(move |piece| { Box::new(move |piece| {
Box::new(ComplexAgent::new( Box::new(ComplexAgent::new(
piece, piece,
FutureMoveConfig { FutureMoveConfig {
max_depth: d, max_depth: d,
do_not_prune: p,
..FMV_BASE ..FMV_BASE
}, },
)) ))
}), }),
) )
}) })
})
.collect(); .collect();
let mut arena = PlayerArena::new(vec); let mut arena = PlayerArena::new(vec);
@ -93,6 +98,11 @@ impl PlayerArena {
.collect::<Vec<_>>() .collect::<Vec<_>>()
// after the agents are created, we can multithread the games being played // after the agents are created, we can multithread the games being played
.into_par_iter() .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))) .map(|((i, j), (p1, p2))| (i, j, Self::play_two_inner(p1, p2)))
.collect::<Vec<_>>() .collect::<Vec<_>>()
// collect and process the outcomes of all the games // collect and process the outcomes of all the games

View File

@ -12,8 +12,8 @@ pub mod repr;
// TODO! make this agent configuration a config option via `clap-rs` // TODO! make this agent configuration a config option via `clap-rs`
fn main() { fn main() {
// elo::run(); elo::run();
// return; return;
let player1 = complexagent::ComplexAgent::new( let player1 = complexagent::ComplexAgent::new(
Piece::Black, Piece::Black,
FutureMoveConfig { FutureMoveConfig {