elo: progress bar
This commit is contained in:
parent
ea7df6a739
commit
c0224f1a05
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -252,6 +252,7 @@ dependencies = [
|
||||
"console",
|
||||
"number_prefix",
|
||||
"portable-atomic",
|
||||
"rayon",
|
||||
"unicode-width",
|
||||
"web-time",
|
||||
]
|
||||
|
||||
@ -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"
|
||||
|
||||
38
src/elo.rs
38
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<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
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user