mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 08:53:26 +03:00
fix area under curve on jump-to-time when active agents isnt 0 at end of day. also... fail loudly when we make it to the end of the day and too many active agents are left. at some point lakeslice broke and I didnt notice. :( ... but actually it's just a crowd of people waiting on a bus that isnt managing to spawn.
This commit is contained in:
parent
24740e9852
commit
f056080106
@ -3,7 +3,7 @@ use crate::game::{State, Transition};
|
|||||||
use crate::managed::{Callback, ManagedGUIState, WrappedComposite};
|
use crate::managed::{Callback, ManagedGUIState, WrappedComposite};
|
||||||
use crate::sandbox::gameplay::Tutorial;
|
use crate::sandbox::gameplay::Tutorial;
|
||||||
use crate::sandbox::{GameplayMode, SandboxMode, TutorialState};
|
use crate::sandbox::{GameplayMode, SandboxMode, TutorialState};
|
||||||
use abstutil::Timer;
|
use abstutil::{prettyprint_usize, Timer};
|
||||||
use ezgui::{hotkey, Btn, Color, Composite, EventCtx, Key, Line, Text, TextExt, Widget};
|
use ezgui::{hotkey, Btn, Color, Composite, EventCtx, Key, Line, Text, TextExt, Widget};
|
||||||
use geom::{Duration, Time};
|
use geom::{Duration, Time};
|
||||||
use map_model::Map;
|
use map_model::Map;
|
||||||
@ -381,8 +381,19 @@ fn prebake(map: &Map, scenario: Scenario, time_limit: Option<Duration>, timer: &
|
|||||||
abstutil::path_prebaked_results(&scenario.map_name, &scenario.scenario_name),
|
abstutil::path_prebaked_results(&scenario.map_name, &scenario.scenario_name),
|
||||||
sim.get_analytics(),
|
sim.get_analytics(),
|
||||||
);
|
);
|
||||||
|
let agents_left = sim.num_agents().sum();
|
||||||
|
timer.note(format!("{} agents left by end of day", agents_left));
|
||||||
timer.stop(format!(
|
timer.stop(format!(
|
||||||
"prebake for {} / {}",
|
"prebake for {} / {}",
|
||||||
scenario.map_name, scenario.scenario_name
|
scenario.map_name, scenario.scenario_name
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// TODO Ah, it's people waiting on a bus that never spawned. Woops.
|
||||||
|
if agents_left > 500 && false {
|
||||||
|
panic!(
|
||||||
|
"{} agents left by end of day on {}; seems bad",
|
||||||
|
prettyprint_usize(agents_left),
|
||||||
|
scenario.map_name
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,24 +306,24 @@ impl AgentMeter {
|
|||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::draw_svg(ctx, "system/assets/meters/pedestrian.svg").margin_right(5),
|
Widget::draw_svg(ctx, "system/assets/meters/pedestrian.svg").margin_right(5),
|
||||||
prettyprint_usize(by_type[&AgentType::Pedestrian]).draw_text(ctx),
|
prettyprint_usize(by_type.get(AgentType::Pedestrian)).draw_text(ctx),
|
||||||
]),
|
]),
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::draw_svg(ctx, "system/assets/meters/bike.svg").margin_right(5),
|
Widget::draw_svg(ctx, "system/assets/meters/bike.svg").margin_right(5),
|
||||||
prettyprint_usize(by_type[&AgentType::Bike]).draw_text(ctx),
|
prettyprint_usize(by_type.get(AgentType::Bike)).draw_text(ctx),
|
||||||
]),
|
]),
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::draw_svg(ctx, "system/assets/meters/car.svg").margin_right(5),
|
Widget::draw_svg(ctx, "system/assets/meters/car.svg").margin_right(5),
|
||||||
prettyprint_usize(by_type[&AgentType::Car]).draw_text(ctx),
|
prettyprint_usize(by_type.get(AgentType::Car)).draw_text(ctx),
|
||||||
]),
|
]),
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::draw_svg(ctx, "system/assets/meters/bus.svg").margin_right(5),
|
Widget::draw_svg(ctx, "system/assets/meters/bus.svg").margin_right(5),
|
||||||
prettyprint_usize(by_type[&AgentType::Bus] + by_type[&AgentType::Train])
|
prettyprint_usize(by_type.get(AgentType::Bus) + by_type.get(AgentType::Train))
|
||||||
.draw_text(ctx),
|
.draw_text(ctx),
|
||||||
]),
|
]),
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Widget::draw_svg(ctx, "system/assets/meters/passenger.svg").margin_right(5),
|
Widget::draw_svg(ctx, "system/assets/meters/passenger.svg").margin_right(5),
|
||||||
prettyprint_usize(by_type[&AgentType::TransitRider]).draw_text(ctx),
|
prettyprint_usize(by_type.get(AgentType::TransitRider)).draw_text(ctx),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
.centered(),
|
.centered(),
|
||||||
|
@ -744,6 +744,7 @@ fn area_under_curve(raw: Vec<(Time, usize)>, width: f64, height: f64) -> Polygon
|
|||||||
for pt in lttb::lttb(pts, 100) {
|
for pt in lttb::lttb(pts, 100) {
|
||||||
downsampled.push(Pt2D::new(pt.x, pt.y));
|
downsampled.push(Pt2D::new(pt.x, pt.y));
|
||||||
}
|
}
|
||||||
|
downsampled.push(Pt2D::new(width, height));
|
||||||
downsampled.push(downsampled[0]);
|
downsampled.push(downsampled[0]);
|
||||||
Polygon::new(&downsampled)
|
Polygon::new(&downsampled)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
UnzoomedAgent, Vehicle, VehicleSpec, VehicleType, WalkingSimState, BUS_LENGTH,
|
UnzoomedAgent, Vehicle, VehicleSpec, VehicleType, WalkingSimState, BUS_LENGTH,
|
||||||
LIGHT_RAIL_LENGTH, MIN_CAR_LENGTH,
|
LIGHT_RAIL_LENGTH, MIN_CAR_LENGTH,
|
||||||
};
|
};
|
||||||
use abstutil::{Parallelism, Timer};
|
use abstutil::{Counter, Parallelism, Timer};
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use geom::{Distance, Duration, PolyLine, Pt2D, Speed, Time};
|
use geom::{Distance, Duration, PolyLine, Pt2D, Speed, Time};
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
@ -871,7 +871,7 @@ impl Sim {
|
|||||||
pub fn num_trips(&self) -> (usize, usize) {
|
pub fn num_trips(&self) -> (usize, usize) {
|
||||||
self.trips.num_trips()
|
self.trips.num_trips()
|
||||||
}
|
}
|
||||||
pub fn num_agents(&self) -> BTreeMap<AgentType, usize> {
|
pub fn num_agents(&self) -> Counter<AgentType> {
|
||||||
self.trips.num_agents(&self.transit)
|
self.trips.num_agents(&self.transit)
|
||||||
}
|
}
|
||||||
// (total number of people, just in buildings, just off map)
|
// (total number of people, just in buildings, just off map)
|
||||||
|
@ -829,7 +829,7 @@ impl TripManager {
|
|||||||
self.unfinished_trips,
|
self.unfinished_trips,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn num_agents(&self, transit: &TransitSimState) -> BTreeMap<AgentType, usize> {
|
pub fn num_agents(&self, transit: &TransitSimState) -> Counter<AgentType> {
|
||||||
let mut cnt = Counter::new();
|
let mut cnt = Counter::new();
|
||||||
for a in self.active_trip_mode.keys() {
|
for a in self.active_trip_mode.keys() {
|
||||||
cnt.inc(a.to_type());
|
cnt.inc(a.to_type());
|
||||||
@ -837,10 +837,7 @@ impl TripManager {
|
|||||||
let (buses, trains) = transit.active_vehicles();
|
let (buses, trains) = transit.active_vehicles();
|
||||||
cnt.add(AgentType::Bus, buses);
|
cnt.add(AgentType::Bus, buses);
|
||||||
cnt.add(AgentType::Train, trains);
|
cnt.add(AgentType::Train, trains);
|
||||||
AgentType::all()
|
cnt
|
||||||
.into_iter()
|
|
||||||
.map(|k| (k, cnt.get(k)))
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
pub fn num_ppl(&self) -> (usize, usize, usize) {
|
pub fn num_ppl(&self) -> (usize, usize, usize) {
|
||||||
let mut ppl_in_bldg = 0;
|
let mut ppl_in_bldg = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user