diff --git a/abstutil/src/logs.rs b/abstutil/src/logs.rs index 26b584595b..d07ce79cfb 100644 --- a/abstutil/src/logs.rs +++ b/abstutil/src/logs.rs @@ -1,5 +1,6 @@ use crate::Timer; +// // - If it doesn't make sense to plumb Timer to a library call, return Warn. // - If there's no Timer, plumb the Warn. // - If a Timer is available and there's a Warn, use get() or with_context(). diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index 6c73675c55..0c87a621a0 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -27,7 +27,8 @@ pub fn convert(flags: &Flags, timer: &mut abstutil::Timer) -> RawMap { ); clip::clip_map(&mut map, timer); - // Need to do a first pass of removing cul-de-sacs here, or we wind up with loop PolyLines when doing the parking hint matching. + // Need to do a first pass of removing cul-de-sacs here, or we wind up with loop PolyLines when + // doing the parking hint matching. abstutil::retain_btreemap(&mut map.roads, |r, _| r.i1 != r.i2); if let Some(ref path) = flags.parking_shapes { diff --git a/docs/dev.md b/docs/dev.md index 5cf5f9498e..9e86285e7b 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -46,8 +46,8 @@ One-time setup: against a baseline in challenge mode), make sure to set `--rng_seed=42`. The `--dev` flag does by default. - All code is automatically formatted using - https://github.com/rust-lang/rustfmt; please run `cargo fmt` before sending a - PR. + https://github.com/rust-lang/rustfmt; please run `cargo +nightly fmt` before + sending a PR. (You have to install the nightly toolchain just for fmt) - More random notes [here](/docs/misc_dev_tricks.md) ## Building map data diff --git a/ezgui/src/event_ctx.rs b/ezgui/src/event_ctx.rs index 2e472cf022..510df1744d 100644 --- a/ezgui/src/event_ctx.rs +++ b/ezgui/src/event_ctx.rs @@ -125,7 +125,10 @@ impl<'a> EventCtx<'a> { .join(", ") ); } - panic!("Only 15 texture arrays supported by some videocards. Group more textures by using the same image dimensions."); + panic!( + "Only 15 texture arrays supported by some videocards. Group more textures by \ + using the same image dimensions." + ); } for (group_idx, (raw_dims, list)) in dims_to_textures.into_iter().enumerate() { let mut raw_data = Vec::new(); diff --git a/game/src/challenges.rs b/game/src/challenges.rs index 28a7379053..996f836add 100644 --- a/game/src/challenges.rs +++ b/game/src/challenges.rs @@ -25,43 +25,52 @@ impl abstutil::Cloneable for Challenge {} pub fn all_challenges() -> BTreeMap> { let mut tree = BTreeMap::new(); - tree.insert("Fix all of the traffic signals".to_string(), vec![ - Challenge { - title: "Tutorial 1".to_string(), - description: vec!["Add or remove a dedicated left phase".to_string()], - map_path: abstutil::path_synthetic_map("signal_single"), - alias: "trafficsig/tut1".to_string(), - gameplay: GameplayMode::FixTrafficSignalsTutorial(0), - }, - Challenge { - title: "Tutorial 2".to_string(), - description: vec!["Deal with heavy foot traffic".to_string()], - map_path: abstutil::path_synthetic_map("signal_single"), - alias: "trafficsig/tut2".to_string(), - gameplay: GameplayMode::FixTrafficSignalsTutorial(1), - }, - Challenge { - title: "The real challenge!".to_string(), - description: vec![ - "A city-wide power surge knocked out all of the traffic signals!".to_string(), - "Their timing has been reset to default settings, and drivers are stuck.".to_string(), - "It's up to you to repair the signals, choosing appropriate turn phases and timing.".to_string(), - "".to_string(), - "Objective: Reduce the 50%ile trip time of all drivers by at least 30s".to_string() - ], - map_path: abstutil::path_map("montlake"), - alias: "trafficsig/main".to_string(), - gameplay: GameplayMode::FixTrafficSignals, - }, - ]); + tree.insert( + "Fix all of the traffic signals".to_string(), + vec![ + Challenge { + title: "Tutorial 1".to_string(), + description: vec!["Add or remove a dedicated left phase".to_string()], + map_path: abstutil::path_synthetic_map("signal_single"), + alias: "trafficsig/tut1".to_string(), + gameplay: GameplayMode::FixTrafficSignalsTutorial(0), + }, + Challenge { + title: "Tutorial 2".to_string(), + description: vec!["Deal with heavy foot traffic".to_string()], + map_path: abstutil::path_synthetic_map("signal_single"), + alias: "trafficsig/tut2".to_string(), + gameplay: GameplayMode::FixTrafficSignalsTutorial(1), + }, + Challenge { + title: "The real challenge!".to_string(), + description: vec![ + "A city-wide power surge knocked out all of the traffic signals!".to_string(), + "Their timing has been reset to default settings, and drivers are stuck." + .to_string(), + "It's up to you to repair the signals, choosing appropriate turn phases and \ + timing." + .to_string(), + "".to_string(), + "Objective: Reduce the 50%ile trip time of all drivers by at least 30s" + .to_string(), + ], + map_path: abstutil::path_map("montlake"), + alias: "trafficsig/main".to_string(), + gameplay: GameplayMode::FixTrafficSignals, + }, + ], + ); tree.insert( "Speed up bus route 43".to_string(), vec![ Challenge { title: "Just Montlake area".to_string(), description: vec![ - "Decrease the average waiting time between all of route 43's stops by at least 30s" - .to_string()], + "Decrease the average waiting time between all of route 43's stops by at \ + least 30s" + .to_string(), + ], map_path: abstutil::path_map("montlake"), alias: "bus43/montlake".to_string(), gameplay: GameplayMode::OptimizeBus("43".to_string()), diff --git a/game/src/edit/traffic_signals.rs b/game/src/edit/traffic_signals.rs index c871c4e09b..3cf22b53d4 100644 --- a/game/src/edit/traffic_signals.rs +++ b/game/src/edit/traffic_signals.rs @@ -661,7 +661,15 @@ fn check_for_missing_groups( change_traffic_signal(signal, ui, ctx); *composite = make_diagram(id, last_phase, ui, ctx); - Transition::Push(msg("Error: missing turns", vec![format!("{} turns are missing from this traffic signal", num_missing), "They've all been added as a new last phase. Please update your changes to include them.".to_string()])) + Transition::Push(msg( + "Error: missing turns", + vec![ + format!("{} turns are missing from this traffic signal", num_missing), + "They've all been added as a new last phase. Please update your changes to include \ + them." + .to_string(), + ], + )) } // TODO I guess it's valid to preview without all turns possible. Some agents are just sad. diff --git a/game/src/render/lane.rs b/game/src/render/lane.rs index 9a69cf67ed..5e39a3d57a 100644 --- a/game/src/render/lane.rs +++ b/game/src/render/lane.rs @@ -185,8 +185,9 @@ fn calculate_parking_lines(lane: &Lane) -> Vec { for idx in 0..=num_spots { let (pt, lane_angle) = lane.dist_along(PARKING_SPOT_LENGTH * (1.0 + idx as f64)); let perp_angle = lane_angle.rotate_degs(270.0); - // Find the outside of the lane. Actually, shift inside a little bit, since the line will - // have thickness, but shouldn't really intersect the adjacent line when drawn. + // Find the outside of the lane. Actually, shift inside a little bit, since the line + // will have thickness, but shouldn't really intersect the adjacent line + // when drawn. let t_pt = pt.project_away(LANE_THICKNESS * 0.4, perp_angle); // The perp leg let p1 = t_pt.project_away(leg_length, perp_angle.opposite()); diff --git a/game/src/sandbox/gameplay/fix_traffic_signals.rs b/game/src/sandbox/gameplay/fix_traffic_signals.rs index 09a529eb1f..f97cc002ce 100644 --- a/game/src/sandbox/gameplay/fix_traffic_signals.rs +++ b/game/src/sandbox/gameplay/fix_traffic_signals.rs @@ -122,7 +122,11 @@ fn final_score(ui: &UI) -> Vec { let mut lines = Vec::new(); if time < Time::END_OF_DAY { - lines.push(format!("You have to run the simulation until the end of the day to get final results; {} to go", Time::END_OF_DAY - time)); + lines.push(format!( + "You have to run the simulation until the end of the day to get final results; {} to \ + go", + Time::END_OF_DAY - time + )); } if now_50p < baseline_50p - Duration::seconds(30.0) { @@ -133,14 +137,26 @@ fn final_score(ui: &UI) -> Vec { baseline_50p )); } else if now_50p < baseline_50p { - lines.push(format!("Almost there! 50%ile trip times are now {}, which is {} faster than the baseline {}. Can you reduce the times by 30s?", now_50p, baseline_50p - now_50p, baseline_50p)); + lines.push(format!( + "Almost there! 50%ile trip times are now {}, which is {} faster than the baseline {}. \ + Can you reduce the times by 30s?", + now_50p, + baseline_50p - now_50p, + baseline_50p + )); } else if now_50p.epsilon_eq(baseline_50p) { lines.push(format!( "... Did you change anything? 50% ile trip times are {}, same as the baseline", now_50p )); } else { - lines.push(format!("Err... how did you make things WORSE?! 50%ile trip times are {}, which is {} slower than the baseline {}", now_50p, now_50p - baseline_50p, baseline_50p)); + lines.push(format!( + "Err... how did you make things WORSE?! 50%ile trip times are {}, which is {} slower \ + than the baseline {}", + now_50p, + now_50p - baseline_50p, + baseline_50p + )); } lines } diff --git a/game/src/sandbox/overlays.rs b/game/src/sandbox/overlays.rs index 05614058ce..2c3b4d2e18 100644 --- a/game/src/sandbox/overlays.rs +++ b/game/src/sandbox/overlays.rs @@ -635,7 +635,8 @@ impl Overlays { let mut batch = GeomBatch::new(); batch.push(Color::CYAN, Polygon::rounded_rectangle(15.0, y_len, 4.0)); for (_, stop_idx, percent_next_stop) in ui.primary.sim.status_of_buses(route.id) { - // TODO Line it up right in the middle of the line of text. This is probably a bit wrong. + // TODO Line it up right in the middle of the line of text. This is probably a bit + // wrong. let base_percent_y = if stop_idx == route.stops.len() - 1 { 0.0 } else { diff --git a/game/src/tutorial.rs b/game/src/tutorial.rs index 6ae48bfd3b..fbf4d16cfc 100644 --- a/game/src/tutorial.rs +++ b/game/src/tutorial.rs @@ -528,37 +528,85 @@ impl TutorialState { let minimap = Minimap::new(ctx, ui); let stages = vec![ - Stage::msg(vec!["Welcome to your first day as a contract traffic engineer --", "like a paid assassin, but capable of making WAY more people cry.", "Warring factions in Seattle have brought you here."]).warp_to(ID::Intersection(IntersectionID(141))), - - Stage::msg(vec!["Let's start with the controls for your handy drone.", "Click and drag to pan around the map, and use your scroll wheel or touchpad to zoom."]), - Stage::msg(vec!["Let's try that ou--", "WHOA THE MONTLAKE MARKET IS ON FIRE!", "GO CLICK ON IT, QUICK!"]), + Stage::msg(vec![ + "Welcome to your first day as a contract traffic engineer --", + "like a paid assassin, but capable of making WAY more people cry.", + "Warring factions in Seattle have brought you here.", + ]) + .warp_to(ID::Intersection(IntersectionID(141))), + Stage::msg(vec![ + "Let's start with the controls for your handy drone.", + "Click and drag to pan around the map, and use your scroll wheel or touchpad to \ + zoom.", + ]), + Stage::msg(vec![ + "Let's try that ou--", + "WHOA THE MONTLAKE MARKET IS ON FIRE!", + "GO CLICK ON IT, QUICK!", + ]), // TODO Just zoom in sufficiently on it, maybe don't even click it yet. Stage::interact("Put out the fire at the Montlake Market"), - - Stage::msg(vec!["Er, sorry about that.", "Just a little joke we like to play on the new recruits.", "Now, let's learn how to inspect and interact with objects in the map.", "Select something, then click on it.", "", "HINT: The bottom of the screen shows keyboard shortcuts.", "", "Hmm, almost time to hit the road."]).arrow(ScreenPt::new(0.5 * ctx.canvas.window_width, 0.97 * ctx.canvas.window_height)), + Stage::msg(vec![ + "Er, sorry about that.", + "Just a little joke we like to play on the new recruits.", + "Now, let's learn how to inspect and interact with objects in the map.", + "Select something, then click on it.", + "", + "HINT: The bottom of the screen shows keyboard shortcuts.", + "", + "Hmm, almost time to hit the road.", + ]) + .arrow(ScreenPt::new( + 0.5 * ctx.canvas.window_width, + 0.97 * ctx.canvas.window_height, + )), Stage::interact("Go hit 3 different lanes on one road"), - - Stage::msg(vec!["You'll work day and night, watching traffic patterns unfold."]).arrow(time.composite.center_of_panel()), - Stage::msg(vec!["You can pause or resume time"]).arrow(speed.composite.inner.center_of("pause")), - Stage::msg(vec!["Speed things up"]).arrow(speed.composite.inner.center_of("600x speed")), - Stage::msg(vec!["Advance time by certain amounts"]).arrow(speed.composite.inner.center_of("step forwards 1 hour")), - Stage::msg(vec!["And reset to the beginning of the day"]).arrow(speed.composite.inner.center_of("reset to midnight")), + Stage::msg(vec![ + "You'll work day and night, watching traffic patterns unfold.", + ]) + .arrow(time.composite.center_of_panel()), + Stage::msg(vec!["You can pause or resume time"]) + .arrow(speed.composite.inner.center_of("pause")), + Stage::msg(vec!["Speed things up"]) + .arrow(speed.composite.inner.center_of("600x speed")), + Stage::msg(vec!["Advance time by certain amounts"]) + .arrow(speed.composite.inner.center_of("step forwards 1 hour")), + Stage::msg(vec!["And reset to the beginning of the day"]) + .arrow(speed.composite.inner.center_of("reset to midnight")), Stage::interact("Wait until 5pm"), - // Don't center on where the agents are, be a little offset - Stage::msg(vec!["Oh look, some people appeared!", "We've got pedestrians, bikes, and cars moving around now.", "You can see the number of them in the top-right corner."]).arrow(agent_meter.composite.center_of_panel()).warp_to( - ID::Building(BuildingID(611))).spawn_around(IntersectionID(247)), - Stage::msg(vec!["Why don't you follow the first northbound car to their destination,", "and make sure whoever gets out makes it inside their house safely?"]).spawn_around(IntersectionID(247)), + Stage::msg(vec![ + "Oh look, some people appeared!", + "We've got pedestrians, bikes, and cars moving around now.", + ]) + .warp_to(ID::Building(BuildingID(611))) + .spawn_around(IntersectionID(247)), + Stage::msg(vec![ + "You can see the number of them in the top-right corner.", + ]) + .arrow(agent_meter.composite.center_of_panel()) + .spawn_around(IntersectionID(247)), + Stage::msg(vec![ + "Why don't you follow the first northbound car to their destination,", + "and make sure whoever gets out makes it inside their house safely?", + ]) + .spawn_around(IntersectionID(247)), // TODO Make it clear they can reset // TODO The time controls are too jumpy; can we automatically slow down when // interesting stuff happens? - Stage::interact("Escort the first northbound car to their home").spawn_around(IntersectionID(247)), - - Stage::msg(vec!["The map is quite large, so to help you orient", "the minimap shows you an overview of all activity."]).arrow(minimap.composite.center_of("minimap")), + Stage::interact("Escort the first northbound car to their home") + .spawn_around(IntersectionID(247)), + Stage::msg(vec![ + "The map is quite large, so to help you orient", + "the minimap shows you an overview of all activity.", + ]) + .arrow(minimap.composite.center_of("minimap")), Stage::msg(vec!["Find addresses here"]).arrow(minimap.composite.center_of("search")), // TODO What's the test? - - Stage::msg(vec!["Training complete!", "Go have the appropriate amount of fun."]), + Stage::msg(vec![ + "Training complete!", + "Go have the appropriate amount of fun.", + ]), ]; TutorialState { stages, @@ -566,16 +614,18 @@ impl TutorialState { current: 0, } - // You've got a drone and, thanks to extremely creepy surveillance technology, the ability to peer - // into everyone's trips. - // People are on fixed schedules: every day, they leave at exactly the same time using the same - // mode of transport. All you can change is how their experience will be in the short-term. - // The city is in total crisis. You've only got 10 days to do something before all hell breaks - // loose and people start kayaking / ziplining / crab-walking / cartwheeling / to work. + // You've got a drone and, thanks to extremely creepy surveillance technology, the ability + // to peer into everyone's trips. + // People are on fixed schedules: every day, they leave at exactly the same time using the + // same mode of transport. All you can change is how their experience will be in the + // short-term. The city is in total crisis. You've only got 10 days to do something + // before all hell breaks loose and people start kayaking / ziplining / crab-walking + // / cartwheeling / to work. // TODO Show overlapping peds? // TODO Minimap, layers - // TODO Multi-modal trips -- including parking. (Cars per bldg, ownership). Border intersections. + // TODO Multi-modal trips -- including parking. (Cars per bldg, ownership). Border + // intersections. // TODO Edit mode. fixed schedules. agenda/goals. // - add a bike lane, watch cars not stack up anymore diff --git a/geom/src/pt.rs b/geom/src/pt.rs index 7515055264..ea18caf369 100644 --- a/geom/src/pt.rs +++ b/geom/src/pt.rs @@ -51,7 +51,8 @@ impl Pt2D { }; let x = (gps.longitude - b.min_lon) / (b.max_lon - b.min_lon) * width; - // Invert y, so that the northernmost latitude is 0. Screen drawing order, not Cartesian grid. + // Invert y, so that the northernmost latitude is 0. Screen drawing order, not Cartesian + // grid. let y = height - ((gps.latitude - b.min_lat) / (b.max_lat - b.min_lat) * height); Pt2D::new(x, y) } diff --git a/map_model/src/make/buildings.rs b/map_model/src/make/buildings.rs index 1b2fca4f82..98189eacec 100644 --- a/map_model/src/make/buildings.rs +++ b/map_model/src/make/buildings.rs @@ -92,10 +92,18 @@ pub fn make_all_buildings( } p.driving_pos = Position::new(driving_lane, dist_along); if lanes[driving_lane.0].length() - dist_along < Distance::meters(7.0) { - timer.warn(format!("Skipping driveway of {}, too close to the end of the road. Forfeiting {} stalls!", bldg.id, p.num_stalls)); + timer.warn(format!( + "Skipping driveway of {}, too close to the end of the road. \ + Forfeiting {} stalls!", + bldg.id, p.num_stalls + )); bldg.parking = None; } else if dist_along < Distance::meters(1.0) { - timer.warn(format!("Skipping driveway of {}, too close to the start of the road. Forfeiting {} stalls!", bldg.id, p.num_stalls)); + timer.warn(format!( + "Skipping driveway of {}, too close to the start of the road. \ + Forfeiting {} stalls!", + bldg.id, p.num_stalls + )); bldg.parking = None; } } else { diff --git a/map_model/src/make/initial/geometry.rs b/map_model/src/make/initial/geometry.rs index 98c4ce335f..8e42dd1219 100644 --- a/map_model/src/make/initial/geometry.rs +++ b/map_model/src/make/initial/geometry.rs @@ -155,7 +155,11 @@ fn generalized_trim_back( shortest_center = trimmed; } } else { - timer.warn(format!("{} and {} hit, but the perpendicular never hit the original center line, or the trimmed thing is empty", r1, r2)); + timer.warn(format!( + "{} and {} hit, but the perpendicular never hit the original center line, \ + or the trimmed thing is empty", + r1, r2 + )); } // We could also do the update for r2, but we'll just get to it later. @@ -234,7 +238,11 @@ fn generalized_trim_back( }*/ } } else { - timer.warn(format!("Excluding collision between original polylines of {} and something, because stuff's too short", id)); + timer.warn(format!( + "Excluding collision between original polylines of {} and something, because \ + stuff's too short", + id + )); } // Shift those final centers out again to find the main endpoints for the polygon. @@ -289,7 +297,11 @@ fn generalized_trim_back( }*/ } } else { - timer.warn(format!("Excluding collision between original polylines of {} and something, because stuff's too short", id)); + timer.warn(format!( + "Excluding collision between original polylines of {} and something, because \ + stuff's too short", + id + )); } /*if *id == OriginalRoad(384) { diff --git a/map_model/src/make/sidewalk_finder.rs b/map_model/src/make/sidewalk_finder.rs index d6741394ab..1ce0a0e51e 100644 --- a/map_model/src/make/sidewalk_finder.rs +++ b/map_model/src/make/sidewalk_finder.rs @@ -36,7 +36,11 @@ pub fn find_sidewalk_points( if let Some(dist_along) = lanes[sidewalk.0].dist_along_of_point(sidewalk_pt) { results.insert(query_pt, Position::new(sidewalk, dist_along)); } else { - panic!("{} isn't on {} according to dist_along_of_point, even though closest_point thinks it is.\n{}", sidewalk_pt, sidewalk, lanes[sidewalk.0].lane_center_pts); + panic!( + "{} isn't on {} according to dist_along_of_point, even though closest_point \ + thinks it is.\n{}", + sidewalk_pt, sidewalk, lanes[sidewalk.0].lane_center_pts + ); } } } diff --git a/map_model/src/make/turns.rs b/map_model/src/make/turns.rs index 6c74305c9a..ea7eae6891 100644 --- a/map_model/src/make/turns.rs +++ b/map_model/src/make/turns.rs @@ -547,7 +547,11 @@ fn make_shared_sidewalk_corner( deduped.dedup(); if deduped.len() >= 2 { if abstutil::contains_duplicates(&deduped.iter().map(|pt| pt.to_hashable()).collect()) { - timer.warn(format!("SharedSidewalkCorner between {} and {} has weird duplicate geometry, so just doing straight line", l1.id, l2.id)); + timer.warn(format!( + "SharedSidewalkCorner between {} and {} has weird duplicate geometry, so just \ + doing straight line", + l1.id, l2.id + )); return baseline; } @@ -581,12 +585,22 @@ fn make_shared_sidewalk_corner( final_pts.push(l2.first_pt()); } if abstutil::contains_duplicates(&final_pts.iter().map(|pt| pt.to_hashable()).collect()) { - timer.warn(format!("SharedSidewalkCorner between {} and {} has weird duplicate geometry, so just doing straight line", l1.id, l2.id)); + timer.warn(format!( + "SharedSidewalkCorner between {} and {} has weird duplicate geometry, so just doing \ + straight line", + l1.id, l2.id + )); return baseline; } let result = PolyLine::new(final_pts); if result.length() > 10.0 * baseline.length() { - timer.warn(format!("SharedSidewalkCorner between {} and {} explodes to {} long, so just doing straight line", l1.id, l2.id, result.length())); + timer.warn(format!( + "SharedSidewalkCorner between {} and {} explodes to {} long, so just doing straight \ + line", + l1.id, + l2.id, + result.length() + )); return baseline; } result diff --git a/map_model/src/map.rs b/map_model/src/map.rs index 43eae2ffcb..dd85c3bf2d 100644 --- a/map_model/src/map.rs +++ b/map_model/src/map.rs @@ -556,7 +556,8 @@ impl Map { loop { if roads_queue.is_empty() { panic!( - "Giving up looking for a biking or driving lane near {}, searched {} roads: {:?}", + "Giving up looking for a biking or driving lane near {}, searched {} roads: \ + {:?}", b, visited.len(), visited diff --git a/map_model/src/pathfind/mod.rs b/map_model/src/pathfind/mod.rs index 6bbbe44269..36afb9c501 100644 --- a/map_model/src/pathfind/mod.rs +++ b/map_model/src/pathfind/mod.rs @@ -243,8 +243,8 @@ impl Path { for i in 1..self.steps.len() { if let Some(d) = dist_remaining { if d <= Distance::ZERO { - // We know there's at least some geometry if we made it here, so unwrap to verify - // that understanding. + // We know there's at least some geometry if we made it here, so unwrap to + // verify that understanding. return Some(pts_so_far.unwrap()); } } diff --git a/map_model/src/stop_signs.rs b/map_model/src/stop_signs.rs index 1161844cfd..f861b11c76 100644 --- a/map_model/src/stop_signs.rs +++ b/map_model/src/stop_signs.rs @@ -15,9 +15,9 @@ use std::collections::{BTreeMap, HashMap}; // realistic. // - The higher priority agent might not even be at the intersection yet! This'll be a little // harder to implement. -// - "Higher priority" has two cases -- stop sign road always yields to a non-stop sign road. -// But also a non-stop sign road yields to another non-stop sign road. In other words, left -// turns yield to straight and ideally, lane-changing yields to straight too. +// - "Higher priority" has two cases -- stop sign road always yields to a non-stop sign road. But +// also a non-stop sign road yields to another non-stop sign road. In other words, left turns +// yield to straight and ideally, lane-changing yields to straight too. // - So there still is a notion of turn priorities -- priority (can never conflict with another // priority), yield (can't impede a priority turn), stop (has to pause and can't impede a // priority or yield turn). But I don't think we want to really depict this... diff --git a/map_model/src/traffic_signals.rs b/map_model/src/traffic_signals.rs index e4b5dc313d..2c8ed11bff 100644 --- a/map_model/src/traffic_signals.rs +++ b/map_model/src/traffic_signals.rs @@ -116,7 +116,8 @@ impl ControlTrafficSignal { for g2 in phase.protected_groups.iter().map(|g| &self.turn_groups[g]) { if g1.conflicts_with(g2) { return Err(format!( - "Traffic signal has conflicting protected groups in one phase:\n{:?}\n\n{:?}", + "Traffic signal has conflicting protected groups in one \ + phase:\n{:?}\n\n{:?}", g1, g2 )); } @@ -258,8 +259,8 @@ impl ControlTrafficSignal { .get_roads_sorted_by_incoming_angle(map.all_roads()); let (north, west, south, east) = (roads[0], roads[1], roads[2], roads[3]); - // Four-phase with protected lefts, right turn on red (except for the protected lefts), turning - // cars yield to peds + // Four-phase with protected lefts, right turn on red (except for the protected lefts), + // turning cars yield to peds let phases = make_phases( map, i, diff --git a/map_model/src/turn.rs b/map_model/src/turn.rs index 2c21e106f7..a02fa9cbf7 100644 --- a/map_model/src/turn.rs +++ b/map_model/src/turn.rs @@ -56,8 +56,9 @@ pub enum TurnPriority { // For stop signs: Can't currently specify this! // For traffic signals: Can't do this turn right now. Banned, - // For stop signs: cars have to stop before doing this turn, and are accepted with the lowest priority. - // For traffic signals: Cars can do this immediately if there are no previously accepted conflicting turns. + // For stop signs: cars have to stop before doing this turn, and are accepted with the lowest + // priority. For traffic signals: Cars can do this immediately if there are no previously + // accepted conflicting turns. Yield, // For stop signs: cars can do this without stopping. These can conflict! // For traffic signals: Must be non-conflicting. diff --git a/popdat/src/trips.rs b/popdat/src/trips.rs index 670126a9dd..3c98f67aef 100644 --- a/popdat/src/trips.rs +++ b/popdat/src/trips.rs @@ -106,7 +106,8 @@ impl Trip { stop2, )) } else { - //timer.warn(format!("{:?} not actually using transit, because pathfinding didn't find any useful route", trip)); + //timer.warn(format!("{:?} not actually using transit, because pathfinding + // didn't find any useful route", trip)); Some(SpawnTrip::JustWalking(self.depart_at, start, goal)) } } diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000..8f132fa7ed --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,5 @@ +comment_width = 100 +wrap_comments = true + +format_strings = true +max_width = 100 diff --git a/sim/src/analytics.rs b/sim/src/analytics.rs index b96629e964..7fc04c4af0 100644 --- a/sim/src/analytics.rs +++ b/sim/src/analytics.rs @@ -486,7 +486,18 @@ impl Analytics { } distrib.add(overhead / (driving_time + overhead)); } - vec![format!("Consider all trips with both a walking and driving portion"), format!("The portion of the trip spent walking to the parked car, looking for parking, and walking from the parking space to the final destination are all overhead."), format!("So what's the distribution of overhead percentages look like? 0% is ideal -- the entire trip is spent just driving between the original source and destination."), distrib.describe()] + vec![ + format!("Consider all trips with both a walking and driving portion"), + format!( + "The portion of the trip spent walking to the parked car, looking for parking, \ + and walking from the parking space to the final destination are all overhead." + ), + format!( + "So what's the distribution of overhead percentages look like? 0% is ideal -- the \ + entire trip is spent just driving between the original source and destination." + ), + distrib.describe(), + ] } pub fn intersection_delays(&self, i: IntersectionID, t1: Time, t2: Time) -> DurationHistogram { diff --git a/sim/src/make/scenario.rs b/sim/src/make/scenario.rs index 8576499144..4da16e96e6 100644 --- a/sim/src/make/scenario.rs +++ b/sim/src/make/scenario.rs @@ -691,7 +691,8 @@ fn seed_parked_cars( // TODO This should be more critical, but neighborhoods can currently contain a // building, but not even its road, so this is inevitable. timer.warn(format!( - "No room to seed parked cars. {} total spots, {:?} of {} buildings requested, {} new cars so far. Searched from {}", + "No room to seed parked cars. {} total spots, {:?} of {} buildings requested, \ + {} new cars so far. Searched from {}", total_spots, cars_per_building, owner_buildings.len(), diff --git a/sim/src/mechanics/car.rs b/sim/src/mechanics/car.rs index eaff6602f4..b1ad29eaa6 100644 --- a/sim/src/mechanics/car.rs +++ b/sim/src/mechanics/car.rs @@ -125,8 +125,8 @@ impl Car { } else { driveway.to_polyline().extend(raw_body).reversed() }; - // Then make the car creep along the added length of the driveway (which could - // be really short) + // Then make the car creep along the added length of the driveway (which + // could be really short) let creep_along = driveway.length() * percent_time; // TODO Ideally the car would slowly (dis)appear into the building, but // some stuff downstream needs to understand that the windows and such will diff --git a/sim/src/mechanics/driving.rs b/sim/src/mechanics/driving.rs index 8bb2873c6f..e624e45dcf 100644 --- a/sim/src/mechanics/driving.rs +++ b/sim/src/mechanics/driving.rs @@ -113,7 +113,11 @@ impl DrivingSimState { ) { None | Some(ActionAtEnd::GotoLaneEnd) => {} x => { - panic!("Car with one-step route {:?} had unexpected result from maybe_handle_end: {:?}", car.router, x); + panic!( + "Car with one-step route {:?} had unexpected result from \ + maybe_handle_end: {:?}", + car.router, x + ); } } if params.start_dist > car.router.get_end_dist() { @@ -312,8 +316,9 @@ impl DrivingSimState { } } CarState::WaitingToAdvance => unreachable!(), - // They weren't blocked. Note that there's no way the Crossing state could jump - // forwards here; the leader is still in front of them. + // They weren't blocked. Note that there's no way the Crossing state could + // jump forwards here; the leader is still in front + // of them. CarState::Crossing(_, _) | CarState::Unparking(_, _, _) | CarState::Parking(_, _, _) @@ -716,11 +721,12 @@ impl DrivingSimState { match follower.state { CarState::Queued => { - // If they're on their last step, they might be ending early and not right - // behind us. + // If they're on their last step, they might be ending early and not + // right behind us. if !follower.router.last_step() { - // The follower has been smoothly following while the laggy head gets out - // of the way. So immediately promote them to WaitingToAdvance. + // The follower has been smoothly following while the laggy head + // gets out of the way. So + // immediately promote them to WaitingToAdvance. follower.state = CarState::WaitingToAdvance; if self.recalc_lanechanging { follower @@ -731,8 +737,9 @@ impl DrivingSimState { } } CarState::WaitingToAdvance => unreachable!(), - // They weren't blocked. Note that there's no way the Crossing state could jump - // forwards here; the leader vanished from the end of the traversable. + // They weren't blocked. Note that there's no way the Crossing state could + // jump forwards here; the leader vanished from the + // end of the traversable. CarState::Crossing(_, _) | CarState::Unparking(_, _, _) | CarState::Parking(_, _, _) diff --git a/sim/src/mechanics/intersection.rs b/sim/src/mechanics/intersection.rs index 87b4461e15..1ee03bac90 100644 --- a/sim/src/mechanics/intersection.rs +++ b/sim/src/mechanics/intersection.rs @@ -388,7 +388,11 @@ impl State { if time_to_cross > remaining_phase_time { // Actually, we might have bigger problems... if time_to_cross > phase.duration { - println!("OYYY! {:?} is impossible to fit into phase duration of {}. Allowing, but fix the policy!", req, phase.duration); + println!( + "OYYY! {:?} is impossible to fit into phase duration of {}. Allowing, but fix \ + the policy!", + req, phase.duration + ); } else { return false; } diff --git a/sim/src/mechanics/queue.rs b/sim/src/mechanics/queue.rs index 5d8c0fdc24..654deecb1e 100644 --- a/sim/src/mechanics/queue.rs +++ b/sim/src/mechanics/queue.rs @@ -89,7 +89,8 @@ impl Queue { if bound < Distance::ZERO { dump_cars(&result, cars, self.id, now); panic!( - "Queue has spillover on {} at {} -- can't draw {}, bound is {}. Laggy head is {:?}", + "Queue has spillover on {} at {} -- can't draw {}, bound is {}. Laggy head is \ + {:?}", self.id, now, id, bound, self.laggy_head ); } diff --git a/sim/src/router.rs b/sim/src/router.rs index 0091104f43..ba98754f25 100644 --- a/sim/src/router.rs +++ b/sim/src/router.rs @@ -222,7 +222,11 @@ impl Router { format!("parking somewhere else"), )); } else { - println!("WARNING: {} can't find parking on {} or anywhere reachable from it. Possibly we're just totally out of parking space!", vehicle.id, current_lane); + println!( + "WARNING: {} can't find parking on {} or anywhere reachable from \ + it. Possibly we're just totally out of parking space!", + vehicle.id, current_lane + ); *stuck_end_dist = Some(map.get_l(current_lane).length()); } return Some(ActionAtEnd::GotoLaneEnd); diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 7d43225432..367e8334f8 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -651,7 +651,10 @@ impl Sim { })) { Ok(()) => {} Err(err) => { - println!("********************************************************************************"); + println!( + "*************************************************************************\ + *******" + ); println!("Sim broke:"); self.dump_before_abort(); panic::resume_unwind(err);