probabilistic progress
This commit is contained in:
40
src/elo.rs
40
src/elo.rs
@@ -29,7 +29,7 @@ pub fn run() {
|
||||
children_eval_method: Default::default(),
|
||||
};
|
||||
|
||||
let configs = [4, 5, 6]
|
||||
let configs = [6]
|
||||
.into_iter()
|
||||
.map(move |d| FutureMoveConfig {
|
||||
max_depth: d,
|
||||
@@ -119,14 +119,17 @@ pub fn run() {
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
vec.push((
|
||||
"RandomAgent".to_string(),
|
||||
Box::new(move |piece| Box::new(RandomAgent::new(piece))),
|
||||
));
|
||||
|
||||
if false {
|
||||
vec.push((
|
||||
"RandomAgent".to_string(),
|
||||
Box::new(move |piece| Box::new(RandomAgent::new(piece))),
|
||||
));
|
||||
}
|
||||
|
||||
let mut arena = PlayerArena::new(vec);
|
||||
|
||||
arena.prop_arena(1000);
|
||||
arena.prop_arena(100);
|
||||
|
||||
println!("{}", arena);
|
||||
}
|
||||
@@ -172,7 +175,10 @@ impl PlayerArena {
|
||||
.map(|&(i, j)| {
|
||||
(
|
||||
(i, j),
|
||||
Self::create_agents(&self.players[i].1, &self.players[j].1),
|
||||
(
|
||||
(&self.players[i].1)(Piece::Black),
|
||||
(&self.players[j].1)(Piece::White),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -221,14 +227,16 @@ impl PlayerArena {
|
||||
|
||||
while let Ok((i, j, o)) = receiver.recv() {
|
||||
self.process_outcome(i, j, &o);
|
||||
received_num += 1;
|
||||
p.inc(1);
|
||||
|
||||
term.clear_last_lines(self.players.len())
|
||||
.expect("unable to clear prev lines");
|
||||
if received_num > 0 {
|
||||
term.clear_last_lines(self.players.len())
|
||||
.expect("unable to clear prev lines");
|
||||
}
|
||||
term.write_str(format!("{}", self).as_str())
|
||||
.expect("unable to write leaderboard");
|
||||
|
||||
received_num += 1;
|
||||
p.inc(1);
|
||||
// break if all pairs were recieved
|
||||
if received_num == num {
|
||||
break;
|
||||
@@ -265,19 +273,13 @@ impl PlayerArena {
|
||||
self.players[player2].2 = np2;
|
||||
}
|
||||
|
||||
fn create_agents(
|
||||
player_1_fn: &AgentMaker,
|
||||
player_2_fn: &AgentMaker,
|
||||
) -> (Box<dyn Agent>, Box<dyn Agent>) {
|
||||
(player_1_fn(Piece::Black), player_2_fn(Piece::White))
|
||||
}
|
||||
|
||||
fn play_two_inner(player_1: Box<dyn Agent>, player_2: Box<dyn Agent>) -> Outcomes {
|
||||
let result = GameInner::new(
|
||||
player_1,
|
||||
player_2,
|
||||
false,
|
||||
Board::random(rand::random_range(1..=15)),
|
||||
// Board::random(rand::random_range(20..=30)),
|
||||
Board::STARTING_POSITION,
|
||||
)
|
||||
.expect("unable to create game")
|
||||
.loop_until_result();
|
||||
|
||||
Reference in New Issue
Block a user