smarter estimate about cars queued on last step... but disabled it :(

This commit is contained in:
Dustin Carlino 2019-03-05 18:01:37 -08:00
parent ce340f5668
commit 4ae478a7a5
3 changed files with 18 additions and 2 deletions

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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;
}
}