diff --git a/editor/src/plugins/a_b_tests.rs b/editor/src/plugins/a_b_tests.rs index 101396d87a..e57545c4a7 100644 --- a/editor/src/plugins/a_b_tests.rs +++ b/editor/src/plugins/a_b_tests.rs @@ -98,7 +98,10 @@ fn pick_ab_test(map: &Map, mut wizard: WrappedWizard) -> Option { fn launch_test(test: &ABTest, kml: &Option) -> (PerMapUI, PerMapUI) { info!("Launching A/B test {}...", test.test_name); - let load = format!("../data/scenarios/{}/{}", test.map_name, test.scenario_name); + let load = format!( + "../data/scenarios/{}/{}.json", + test.map_name, test.scenario_name + ); // TODO plumb from original flags let rng_seed = Some(42); diff --git a/editor/src/plugins/mod.rs b/editor/src/plugins/mod.rs index cf03cec592..a1f8f42db5 100644 --- a/editor/src/plugins/mod.rs +++ b/editor/src/plugins/mod.rs @@ -78,6 +78,7 @@ pub fn choose_scenario(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Op ).map(|(n, _)| n) } +// TODO Implicitly need a blank edits entry pub fn choose_edits(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Option { let map_name = map.get_name().to_string(); wizard diff --git a/map_model/src/make/bus_stops.rs b/map_model/src/make/bus_stops.rs index f5eb758eb9..c52dd27042 100644 --- a/map_model/src/make/bus_stops.rs +++ b/map_model/src/make/bus_stops.rs @@ -93,7 +93,8 @@ pub fn verify_bus_routes(map: &Map, routes: Vec) -> Vec { { let bs1 = map.get_bs(*stop1); let bs2 = map.get_bs(*stop2); - if Pathfinder::shortest_distance(map, bs1.driving_lane, bs2.driving_lane).is_none() + if Pathfinder::shortest_distance(map, bs1.driving_lane, bs2.driving_lane, false) + .is_none() { warn!( "Removing route {} since {:?} and {:?} aren't connected", diff --git a/map_model/src/pathfind.rs b/map_model/src/pathfind.rs index 99715c8bec..3a7ef3e116 100644 --- a/map_model/src/pathfind.rs +++ b/map_model/src/pathfind.rs @@ -1,10 +1,10 @@ use geom::{Line, Pt2D}; use ordered_float::NotNaN; use std::collections::{BinaryHeap, HashMap, VecDeque}; -use {LaneID, Map}; +use {LaneID, LaneType, Map}; pub enum Pathfinder { - ShortestDistance { goal_pt: Pt2D }, + ShortestDistance { goal_pt: Pt2D, is_bike: bool }, // TODO result isn't really lanes, we also want to know bus stops... post-process? remember // more stuff? hmm. UsingTransit, @@ -12,22 +12,31 @@ pub enum Pathfinder { impl Pathfinder { // Returns an inclusive path, aka, [start, ..., end] - pub fn shortest_distance(map: &Map, start: LaneID, end: LaneID) -> Option> { + pub fn shortest_distance( + map: &Map, + start: LaneID, + end: LaneID, + is_bike: bool, + ) -> Option> { let goal_pt = map.get_l(end).first_pt(); - Pathfinder::ShortestDistance { goal_pt }.pathfind(map, start, end) + Pathfinder::ShortestDistance { goal_pt, is_bike }.pathfind(map, start, end) } fn expand(&self, map: &Map, current: LaneID) -> Vec<(LaneID, NotNaN)> { match self { - Pathfinder::ShortestDistance { goal_pt } => { + Pathfinder::ShortestDistance { goal_pt, is_bike } => { let current_length = NotNaN::new(map.get_l(current).length().value_unsafe).unwrap(); map.get_next_lanes(current) .iter() - .map(|next| { - let heuristic_dist = - NotNaN::new(Line::new(next.first_pt(), *goal_pt).length().value_unsafe) - .unwrap(); - (next.id, current_length + heuristic_dist) + .filter_map(|next| { + if !is_bike && next.lane_type == LaneType::Biking { + None + } else { + let heuristic_dist = NotNaN::new( + Line::new(next.first_pt(), *goal_pt).length().value_unsafe, + ).unwrap(); + Some((next.id, current_length + heuristic_dist)) + } }).collect() } Pathfinder::UsingTransit => { diff --git a/sim/src/spawn.rs b/sim/src/spawn.rs index b11bb54c39..aa995d9cf0 100644 --- a/sim/src/spawn.rs +++ b/sim/src/spawn.rs @@ -435,7 +435,8 @@ fn calculate_paths( let timer = Instant::now(); let paths: Vec>> = requested_paths .par_iter() - .map(|(start, goal)| Pathfinder::shortest_distance(map, *start, *goal)) + // TODO No bikes yet, so never use the bike lanes + .map(|(start, goal)| Pathfinder::shortest_distance(map, *start, *goal, false)) .collect(); debug!( diff --git a/sim/src/transit.rs b/sim/src/transit.rs index b6825dcd73..2368a56dea 100644 --- a/sim/src/transit.rs +++ b/sim/src/transit.rs @@ -95,12 +95,15 @@ impl TransitSimState { .map(|(idx, stop1)| { let next_stop = route.next_stop(idx); let stop2 = &route.stops[next_stop]; - let path = - Pathfinder::shortest_distance(map, stop1.driving_lane, stop2.driving_lane) - .expect(&format!( - "No route between bus stops {:?} and {:?}", - stop1, stop2 - )); + let path = Pathfinder::shortest_distance( + map, + stop1.driving_lane, + stop2.driving_lane, + false, + ).expect(&format!( + "No route between bus stops {:?} and {:?}", + stop1, stop2 + )); (next_stop, stop1.dist_along, path) }).collect() } @@ -164,6 +167,7 @@ impl TransitSimState { map, stop.driving_lane, route.stops[next_stop].driving_lane, + false, ).expect(&format!( "No route between bus stops {:?} and {:?}", stop, route.stops[next_stop]