mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
Give up on generic_prebake_all, an unused method that would very generically crawl all challenges, calculate their scenario, and prebake results for them. It forces GameplayMode -> Scenario to have a certain form, which seemingly blocks transitioning to an asyncish loading screen.
This commit is contained in:
parent
be3b2e8abb
commit
fbf651f1c2
@ -1,4 +1,4 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use abstutil::{prettyprint_usize, Timer};
|
||||
use geom::{Duration, Percent, Time};
|
||||
@ -316,57 +316,6 @@ pub fn prebake_all() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO This variant will be more useful when all scenarios tend to actually complete. ;)
|
||||
#[allow(unused)]
|
||||
pub fn generic_prebake_all() {
|
||||
let mut timer = Timer::new("prebake all challenge results");
|
||||
|
||||
let mut per_map: BTreeMap<String, Vec<Challenge>> = BTreeMap::new();
|
||||
for (_, list) in Challenge::all() {
|
||||
for c in list {
|
||||
per_map
|
||||
.entry(c.gameplay.map_name().to_string())
|
||||
.or_insert_with(Vec::new)
|
||||
.push(c);
|
||||
}
|
||||
}
|
||||
for (map_name, list) in per_map {
|
||||
timer.start(format!("prebake for {}", map_name));
|
||||
let map = map_model::Map::new(abstutil::path_map(&map_name), &mut timer);
|
||||
|
||||
let mut done_scenarios = HashSet::new();
|
||||
for challenge in list {
|
||||
// Bit of an abuse of this, but just need to fix the rng seed.
|
||||
if let Some(scenario) = challenge.gameplay.scenario(
|
||||
&map,
|
||||
None,
|
||||
SimFlags::for_test("prebaked").make_rng(),
|
||||
&mut timer,
|
||||
) {
|
||||
if done_scenarios.contains(&scenario.scenario_name) {
|
||||
continue;
|
||||
}
|
||||
done_scenarios.insert(scenario.scenario_name.clone());
|
||||
|
||||
prebake(&map, scenario, None, &mut timer);
|
||||
}
|
||||
}
|
||||
// TODO A weird hack to glue up tutorial scenarios.
|
||||
if map.get_name() == "montlake" {
|
||||
for generator in TutorialState::scenarios_to_prebake(&map) {
|
||||
let scenario = generator.generate(
|
||||
&map,
|
||||
&mut SimFlags::for_test("prebaked").make_rng(),
|
||||
&mut timer,
|
||||
);
|
||||
prebake(&map, scenario, None, &mut timer);
|
||||
}
|
||||
}
|
||||
|
||||
timer.stop(format!("prebake for {}", map_name));
|
||||
}
|
||||
}
|
||||
|
||||
fn prebake(map: &Map, scenario: Scenario, time_limit: Option<Duration>, timer: &mut Timer) {
|
||||
timer.start(format!(
|
||||
"prebake for {} / {}",
|
||||
|
@ -87,7 +87,7 @@ impl GameplayMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scenario(
|
||||
fn scenario(
|
||||
&self,
|
||||
map: &Map,
|
||||
num_agents: Option<usize>,
|
||||
|
Loading…
Reference in New Issue
Block a user