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",
"number_prefix",
"portable-atomic",
"rayon",
"unicode-width",
"web-time",
]

View File

@ -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"

View File

@ -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<dyn Fn(Piece) -> Box<dyn Agent>>)> = (3..=6)
.map(move |d| -> (String, Box<dyn Fn(Piece) -> Box<dyn Agent>>) {
(
format!("ComplexAgentD{}", d),
Box::new(move |piece| {
Box::new(ComplexAgent::new(
piece,
FutureMoveConfig {
max_depth: d,
..FMV_BASE
},
))
}),
)
let vec: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)> = (5..=6)
.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{}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::<Vec<_>>()
// 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::<Vec<_>>()
// 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`
fn main() {
// elo::run();
// return;
elo::run();
return;
let player1 = complexagent::ComplexAgent::new(
Piece::Black,
FutureMoveConfig {