mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
prebake results per map, and store in binary
This commit is contained in:
parent
c54842faff
commit
3b1a659f15
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,7 +10,7 @@ data/input/*
|
||||
data/maps/*
|
||||
data/neighborhoods/*
|
||||
data/raw_maps/*
|
||||
data/prebaked_results.json
|
||||
data/prebaked_results/*
|
||||
data/save/*
|
||||
data/scenarios/*
|
||||
data/screenshots/*/*.png
|
||||
|
@ -96,6 +96,10 @@ pub fn path_pending_screenshots(map_name: &str) -> String {
|
||||
format!("../data/screenshots/pending_{}", map_name)
|
||||
}
|
||||
|
||||
pub fn path_prebaked_results(map_name: &str) -> String {
|
||||
format!("../data/prebaked_results/{}.bin", map_name)
|
||||
}
|
||||
|
||||
pub fn path_shortcut(name: &str) -> String {
|
||||
format!("../data/shortcuts/{}.json", name)
|
||||
}
|
||||
|
@ -132,20 +132,26 @@ impl State for ChallengeSplash {
|
||||
pub fn prebake() {
|
||||
let mut timer = Timer::new("prebake all challenge results");
|
||||
|
||||
timer.start("run normal sim");
|
||||
let (map, mut sim, _) = SimFlags {
|
||||
load: abstutil::path1_bin(
|
||||
"montlake",
|
||||
abstutil::SCENARIOS,
|
||||
"weekday_typical_traffic_from_psrc",
|
||||
),
|
||||
use_map_fixes: true,
|
||||
rng_seed: Some(42),
|
||||
opts: SimOptions::new("prebaked"),
|
||||
}
|
||||
.load(&mut timer);
|
||||
sim.timed_step(&map, Duration::END_OF_DAY, &mut timer);
|
||||
timer.stop("run normal sim");
|
||||
for map_name in vec!["montlake", "23rd"] {
|
||||
timer.start(&format!("run normal sim for {}", map_name));
|
||||
let (map, mut sim, _) = SimFlags {
|
||||
load: abstutil::path1_bin(
|
||||
map_name,
|
||||
abstutil::SCENARIOS,
|
||||
"weekday_typical_traffic_from_psrc",
|
||||
),
|
||||
use_map_fixes: true,
|
||||
rng_seed: Some(42),
|
||||
opts: SimOptions::new("prebaked"),
|
||||
}
|
||||
.load(&mut timer);
|
||||
sim.timed_step(&map, Duration::END_OF_DAY, &mut timer);
|
||||
timer.stop(&format!("run normal sim for {}", map_name));
|
||||
|
||||
abstutil::write_json("../data/prebaked_results.json", sim.get_analytics()).unwrap();
|
||||
abstutil::write_binary(
|
||||
&abstutil::path_prebaked_results(map_name),
|
||||
sim.get_analytics(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,14 @@ enum State {
|
||||
|
||||
impl GameplayState {
|
||||
pub fn initialize(mode: GameplayMode, ui: &mut UI, ctx: &mut EventCtx) -> GameplayState {
|
||||
let prebaked: Analytics =
|
||||
abstutil::read_json("../data/prebaked_results.json", &mut Timer::throwaway()).unwrap();
|
||||
let prebaked: Analytics = abstutil::read_binary(
|
||||
&abstutil::path_prebaked_results(ui.primary.map.get_name()),
|
||||
&mut Timer::throwaway(),
|
||||
)
|
||||
.unwrap_or_else(|_| {
|
||||
println!("WARNING! No prebaked sim analytics. Only freeform mode will work.");
|
||||
Analytics::new()
|
||||
});
|
||||
|
||||
let (state, maybe_scenario) = match mode.clone() {
|
||||
GameplayMode::Freeform => (
|
||||
|
@ -6,7 +6,7 @@ function common_release {
|
||||
|
||||
cp docs/INSTRUCTIONS.md $OUT
|
||||
mkdir $OUT/data
|
||||
cp data/color_scheme.json data/prebaked_results.json $OUT/data
|
||||
cp -Rv data/color_scheme.json data/prebaked_results $OUT/data
|
||||
|
||||
mkdir $OUT/data/maps
|
||||
for map in 23rd ballard caphill downtown montlake; do
|
||||
|
Loading…
Reference in New Issue
Block a user