mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 06:55:40 +03:00
tweaking rustfmt options; the long literal string vecs in tutorial look awful
This commit is contained in:
parent
318faacbdb
commit
95a84fd26a
@ -1,5 +1,6 @@
|
||||
use crate::Timer;
|
||||
|
||||
//
|
||||
// - If it doesn't make sense to plumb Timer to a library call, return Warn<T>.
|
||||
// - If there's no Timer, plumb the Warn<T>.
|
||||
// - If a Timer is available and there's a Warn<T>, use get() or with_context().
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -25,43 +25,52 @@ impl abstutil::Cloneable for Challenge {}
|
||||
|
||||
pub fn all_challenges() -> BTreeMap<String, Vec<Challenge>> {
|
||||
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()),
|
||||
|
@ -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.
|
||||
|
@ -185,8 +185,9 @@ fn calculate_parking_lines(lane: &Lane) -> Vec<Polygon> {
|
||||
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());
|
||||
|
@ -122,7 +122,11 @@ fn final_score(ui: &UI) -> Vec<String> {
|
||||
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<String> {
|
||||
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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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...
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
5
rustfmt.toml
Normal file
5
rustfmt.toml
Normal file
@ -0,0 +1,5 @@
|
||||
comment_width = 100
|
||||
wrap_comments = true
|
||||
|
||||
format_strings = true
|
||||
max_width = 100
|
@ -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 {
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
|
@ -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(_, _, _)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -651,7 +651,10 @@ impl Sim {
|
||||
})) {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
println!("********************************************************************************");
|
||||
println!(
|
||||
"*************************************************************************\
|
||||
*******"
|
||||
);
|
||||
println!("Sim broke:");
|
||||
self.dump_before_abort();
|
||||
panic::resume_unwind(err);
|
||||
|
Loading…
Reference in New Issue
Block a user