elo: fix types
This commit is contained in:
parent
cb00b28166
commit
7863e0324f
26
src/elo.rs
26
src/elo.rs
@ -14,6 +14,8 @@ use skillratings::{
|
||||
};
|
||||
use std::num::NonZero;
|
||||
|
||||
type AgentMaker = Box<dyn Fn(Piece) -> Box<dyn Agent>>;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run() {
|
||||
const FMV_BASE: FutureMoveConfig = FutureMoveConfig {
|
||||
@ -93,16 +95,14 @@ pub fn run() {
|
||||
.collect()
|
||||
});
|
||||
|
||||
let vec: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)> = configs
|
||||
let vec: Vec<(String, AgentMaker)> = configs
|
||||
.into_iter()
|
||||
.map(
|
||||
move |config| -> (String, Box<dyn Fn(Piece) -> Box<dyn Agent>>) {
|
||||
(
|
||||
format!("{}", config),
|
||||
Box::new(move |piece| Box::new(ComplexAgent::new(piece, config))),
|
||||
)
|
||||
},
|
||||
)
|
||||
.map(move |config| -> (String, AgentMaker) {
|
||||
(
|
||||
format!("{}", config),
|
||||
Box::new(move |piece| Box::new(ComplexAgent::new(piece, config))),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut arena = PlayerArena::new(vec);
|
||||
@ -114,7 +114,7 @@ pub fn run() {
|
||||
|
||||
pub struct PlayerArena {
|
||||
/// Name, Creator Function, Elo
|
||||
players: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>, EloRating)>,
|
||||
players: Vec<(String, AgentMaker, EloRating)>,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PlayerArena {
|
||||
@ -136,7 +136,7 @@ impl std::fmt::Display for PlayerArena {
|
||||
}
|
||||
|
||||
impl PlayerArena {
|
||||
pub fn new(players: Vec<(String, Box<dyn Fn(Piece) -> Box<dyn Agent>>)>) -> Self {
|
||||
pub fn new(players: Vec<(String, AgentMaker)>) -> Self {
|
||||
Self {
|
||||
players: players
|
||||
.into_iter()
|
||||
@ -259,8 +259,8 @@ impl PlayerArena {
|
||||
}
|
||||
|
||||
fn create_agents(
|
||||
player_1_fn: &dyn Fn(Piece) -> Box<dyn Agent>,
|
||||
player_2_fn: &dyn Fn(Piece) -> Box<dyn Agent>,
|
||||
player_1_fn: &AgentMaker,
|
||||
player_2_fn: &AgentMaker,
|
||||
) -> (Box<dyn Agent>, Box<dyn Agent>) {
|
||||
(player_1_fn(Piece::Black), player_2_fn(Piece::White))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user