count the peds moving/waiting too

This commit is contained in:
Dustin Carlino 2018-08-08 12:47:57 -07:00
parent ccbf5939d8
commit c77415164e
2 changed files with 11 additions and 6 deletions

View File

@ -389,13 +389,14 @@ impl Sim {
pub fn summary(&self) -> String {
let (waiting_cars, active_cars) = self.driving_state.get_active_and_waiting_count();
let (waiting_peds, active_peds) = self.walking_state.get_active_and_waiting_count();
format!(
"Time: {0:.2}, {1} / {2} active cars waiting, {3} cars parked, {4} pedestrians",
"Time: {0:.2}, {1} / {2} active cars waiting, {3} cars parked, {4} / {5} pedestrians waiting",
self.time,
waiting_cars,
active_cars,
self.parking_state.total_count(),
self.walking_state.total_count(),
waiting_peds, active_peds,
)
}

View File

@ -177,10 +177,6 @@ impl WalkingSimState {
// No-op
}
pub fn total_count(&self) -> usize {
self.id_counter
}
pub fn step(
&mut self,
delta_time: Time,
@ -311,6 +307,14 @@ impl WalkingSimState {
info.leaders.insert(id);
}
}
pub fn get_active_and_waiting_count(&self) -> (usize, usize) {
let waiting = self.peds
.values()
.filter(|p| p.waiting_for.is_some())
.count();
(waiting, self.peds.len())
}
}
fn is_contraflow(map: &Map, from: LaneID, to: LaneID) -> bool {