diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-28 17:12:07 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-28 17:12:07 +0200 |
commit | 2aab23c40f663a28fb361d6a7976493cb7bb5ea8 (patch) | |
tree | b6f79eba52e5874f0c261c219ad38daef6453dfa /planetwars-server/src | |
parent | 09ce75d5bf2d4966bb8cde492ebfb1da687a0bb2 (diff) | |
download | planetwars.dev-2aab23c40f663a28fb361d6a7976493cb7bb5ea8.tar.xz planetwars.dev-2aab23c40f663a28fb361d6a7976493cb7bb5ea8.zip |
run ranker on all maps
Diffstat (limited to 'planetwars-server/src')
-rw-r--r-- | planetwars-server/src/modules/ranking.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/planetwars-server/src/modules/ranking.rs b/planetwars-server/src/modules/ranking.rs index 7661b71..90c4a56 100644 --- a/planetwars-server/src/modules/ranking.rs +++ b/planetwars-server/src/modules/ranking.rs @@ -16,8 +16,6 @@ use tokio; const RANKER_INTERVAL: u64 = 60; const RANKER_NUM_MATCHES: i64 = 10_000; -const RANKER_MAP_NAME: &str = "hex"; - pub async fn run_ranker(config: Arc<GlobalConfig>, db_pool: DbPool) { // TODO: make this configurable // play at most one match every n seconds @@ -33,13 +31,18 @@ pub async fn run_ranker(config: Arc<GlobalConfig>, db_pool: DbPool) { // not enough bots to play a match continue; } - let selected_bots: Vec<(Bot, BotVersion)> = { - let mut rng = &mut rand::thread_rng(); - bots.choose_multiple(&mut rng, 2).cloned().collect() + + let selected_bots: Vec<(Bot, BotVersion)> = bots + .choose_multiple(&mut rand::thread_rng(), 2) + .cloned() + .collect(); + + let maps = db::maps::list_maps(&db_conn).expect("could not load map"); + let map = match maps.choose(&mut rand::thread_rng()).cloned() { + None => continue, // no maps available + Some(map) => map, }; - let map = - db::maps::find_map_by_name(RANKER_MAP_NAME, &db_conn).expect("could not load map"); play_ranking_match(config.clone(), map, selected_bots, db_pool.clone()).await; recalculate_ratings(&db_conn).expect("could not recalculate ratings"); } |