fixing all tests

This commit is contained in:
Dustin Carlino 2018-07-09 13:48:48 -07:00
parent 8b58665dbd
commit db54420ede
4 changed files with 23 additions and 13 deletions

View File

@ -3,7 +3,6 @@
## cars
- model cars parking
- need to update the tests to seed, then start
- render parked cars (different color)
- make vanished cars just park again
- how to handle when parking is full or no parking at goal road?

View File

@ -29,7 +29,8 @@ fn main() {
let control_map = control::ControlMap::new(&map);
let mut sim = sim::Sim::new(&map, flags.rng_seed);
// TODO need a notion of scenarios
sim.spawn_many_on_empty_roads(&map, 100000);
sim.seed_parked_cars(0.7);
sim.start_many_parked_cars(&map, 100000);
let mut counter = 0;
let mut benchmark = sim.start_benchmark();

View File

@ -414,15 +414,21 @@ impl DrivingSimState {
return false;
}
let goal = rng.choose(map.all_roads()).unwrap();
if goal.lane_type != LaneType::Driving || goal.id == start {
println!("Chose bad goal {}", goal.id);
return false;
}
let mut path = if let Some(steps) = map_model::pathfind(map, start, goal.id) {
let candidate_goals: Vec<RoadID> = map.all_roads()
.iter()
.filter_map(|r| {
if r.lane_type != LaneType::Driving || r.id == start {
None
} else {
Some(r.id)
}
})
.collect();
let goal = rng.choose(&candidate_goals).unwrap();
let mut path = if let Some(steps) = map_model::pathfind(map, start, *goal) {
VecDeque::from(steps)
} else {
println!("No path from {} to {}", start, goal.id);
println!("No path from {} to {}", start, goal);
return false;
};
// path includes the start, but that's not the invariant Car enforces

View File

@ -18,8 +18,10 @@ fn from_scratch() {
let mut sim1 = sim::Sim::new(&map, Some(rng_seed));
let mut sim2 = sim::Sim::new(&map, Some(rng_seed));
sim1.spawn_many_on_empty_roads(&map, spawn_count);
sim2.spawn_many_on_empty_roads(&map, spawn_count);
sim1.seed_parked_cars(0.7);
sim1.start_many_parked_cars(&map, spawn_count);
sim2.seed_parked_cars(0.7);
sim2.start_many_parked_cars(&map, spawn_count);
for _ in 1..1200 {
if sim1 != sim2 {
@ -47,8 +49,10 @@ fn with_savestating() {
let mut sim1 = sim::Sim::new(&map, Some(rng_seed));
let mut sim2 = sim::Sim::new(&map, Some(rng_seed));
sim1.spawn_many_on_empty_roads(&map, spawn_count);
sim2.spawn_many_on_empty_roads(&map, spawn_count);
sim1.seed_parked_cars(0.7);
sim1.start_many_parked_cars(&map, spawn_count);
sim2.seed_parked_cars(0.7);
sim2.start_many_parked_cars(&map, spawn_count);
for _ in 1..600 {
sim1.step(&map, &control_map);