elo: improve UX on live updating leaderboard
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::{
|
||||
logic::{ChildrenEvalMethod, FutureMoveConfig},
|
||||
repr::{Board, Piece, Winner},
|
||||
};
|
||||
use indicatif::{ParallelProgressIterator, ProgressStyle};
|
||||
use indicatif::{ParallelProgressIterator, ProgressStyle, TermLike};
|
||||
use rand::seq::SliceRandom;
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
use skillratings::{
|
||||
@@ -164,6 +164,7 @@ impl PlayerArena {
|
||||
// Immediately drop our copy of the sender so the channel closes properly
|
||||
drop(sender);
|
||||
|
||||
let term = console::Term::stdout();
|
||||
// Process results on main thread as they arrive
|
||||
let mut received_num = 0;
|
||||
while let Ok((i, j, o)) = receiver.recv() {
|
||||
@@ -172,7 +173,11 @@ impl PlayerArena {
|
||||
|
||||
// print the leaderboard every 5 steps
|
||||
if received_num % 5 == 0 {
|
||||
println!("{}", self);
|
||||
term.clear_last_lines(num)
|
||||
.expect("unable to clear prev lines");
|
||||
let formatted_self = format!("{}", self);
|
||||
term.write_str(&formatted_self)
|
||||
.expect("unable to write leaderboard");
|
||||
}
|
||||
|
||||
// break if all pairs were recieved
|
||||
|
||||
Reference in New Issue
Block a user