work around parking leak for multi-day scenarios

This commit is contained in:
Dustin Carlino 2020-04-15 16:36:56 -07:00
parent 97d31fe682
commit ec409742e7
3 changed files with 18 additions and 4 deletions

View File

@ -140,7 +140,7 @@ impl GameplayMode {
} else if name == "5 weekdays repeated" {
let s: Scenario =
abstutil::read_binary(abstutil::path_scenario(map.get_name(), "weekday"), timer);
s.repeat_days(5)
s.repeat_days(5, true)
} else {
let path = abstutil::path_scenario(map.get_name(), &name);
match abstutil::maybe_read_binary(path.clone(), timer) {

View File

@ -23,8 +23,9 @@ fn main() {
abstutil::path_scenario(map.get_name(), "weekday"),
&mut timer,
);
// TODO Hack: avoid leaking parking spots
base_scenario
.repeat_days(num_days)
.repeat_days(num_days, true)
.instantiate(&mut sim, &map, &mut rng, &mut timer);
timer.done();

View File

@ -160,13 +160,26 @@ impl Scenario {
)
}
pub fn repeat_days(mut self, days: usize) -> Scenario {
// TODO Utter hack. Blindly repeats all trips taken by each person every day. If
// avoid_inbound_trips is true, then don't repeat driving trips that start outside the map and
// come in, because those often lead to parking spots leaking. This isn't realistic, but none
// of this is; even the original 1-day scenario doesn't yet guarantee continuity of people. A
// person might be in the middle of one trip, and they start the next one!
pub fn repeat_days(mut self, days: usize, avoid_inbound_trips: bool) -> Scenario {
self.scenario_name = format!("{} repeated for {} days", self.scenario_name, days);
for person in &mut self.people {
let mut trips = Vec::new();
let mut offset = Duration::ZERO;
for _ in 0..days {
for day in 0..days {
for trip in &person.trips {
let inbound = match trip.trip {
SpawnTrip::CarAppearing { is_bike, .. } => !is_bike,
_ => false,
};
if day > 0 && inbound && avoid_inbound_trips {
continue;
}
trips.push(IndividTrip {
depart: trip.depart + offset,
trip: trip.trip.clone(),