diff --git a/headless/src/main.rs b/headless/src/main.rs index e6d85470f9..f85bc4a8c1 100644 --- a/headless/src/main.rs +++ b/headless/src/main.rs @@ -69,7 +69,6 @@ fn main() { None, ); timer.done(); - println!("Sim done at {}", sim.time()); println!("{:?}", sim.get_score()); if flags.enable_profiler && save_at.is_none() { cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); diff --git a/sim/src/mechanics/driving.rs b/sim/src/mechanics/driving.rs index 9c59c2d8d4..4398234c3c 100644 --- a/sim/src/mechanics/driving.rs +++ b/sim/src/mechanics/driving.rs @@ -259,6 +259,7 @@ impl DrivingSimState { // Note that 'car' is currently missing from self.cars, but they can't be on // 'goto' right now -- they're on 'from'. if !self.queues[&goto].room_at_end(time, &self.cars) { + // TODO Subscribe to the target queue, wake up when somebody leaves it. scheduler.push(time + BLIND_RETRY, Command::UpdateCar(car.vehicle.id)); return false; } @@ -415,7 +416,22 @@ impl DrivingSimState { return true; } None => { - scheduler.push(time + BLIND_RETRY, Command::UpdateCar(car.vehicle.id)); + // If this car wasn't blocked at all, when would it reach its goal? + let ideal_end_time = match car.crossing_state(our_dist, time, map) { + CarState::Crossing(time_int, _) => time_int.end, + _ => unreachable!(), + }; + // TODO For now, always use BLIND_RETRY. Measured things to be slower + // otherwise. :( + if ideal_end_time == time || true { + // Haha, no such luck. We're super super close to the goal, but not + // quite there yet. + scheduler.push(time + BLIND_RETRY, Command::UpdateCar(car.vehicle.id)); + } else { + scheduler.push(ideal_end_time, Command::UpdateCar(car.vehicle.id)); + } + // TODO For cars stuck on their last step, this will spam a fair bit. But + // that should be pretty rare. return true; } } diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 830adf29e9..229567c5f2 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -390,6 +390,7 @@ impl Sim { panic!("Time limit {} hit", self.time); } if self.is_done() { + println!("{}, {}", self.summary(), self.measure_speed(&mut benchmark)); break; } }