digging into nondeterminism due to fp issues

This commit is contained in:
Dustin Carlino 2018-09-04 12:56:13 -07:00
parent 686f247b52
commit 11f0f20a3e
3 changed files with 11 additions and 2 deletions

View File

@ -105,7 +105,8 @@ impl Sim {
{
panic!("Three buses didn't fit");
}
// TODO this is introducing nondeterminism?!
// TODO this is introducing nondeterminism, because of slight floating point errors.
// fragile that this causes it, but true. :\
/*self.make_ped_using_bus(
map,
LaneID(550),

View File

@ -79,6 +79,13 @@ impl Sim {
}
}
pub fn load(path: String, new_scenario_name: String) -> Result<Sim, std::io::Error> {
abstutil::read_json(&path).map(|mut s: Sim| {
s.scenario_name = new_scenario_name;
s
})
}
pub fn edit_lane_type(&mut self, id: LaneID, old_type: LaneType, map: &Map) {
match old_type {
LaneType::Driving => self.driving_state.edit_remove_lane(id),

View File

@ -86,7 +86,8 @@ fn with_savestating() {
);
}
let sim3: sim::Sim = abstutil::read_json(&sim1_save).unwrap();
let sim3: sim::Sim =
sim::Sim::load(sim1_save.clone(), "with_savestating_3".to_string()).unwrap();
if sim3 != sim2 {
panic!(
"sim state differs between {} and {}",