info on parked cars and peds in OSD

This commit is contained in:
Dustin Carlino 2018-07-14 13:41:20 -05:00
parent f54d581016
commit 22b1e70707
4 changed files with 24 additions and 5 deletions

View File

@ -28,6 +28,7 @@
## pedestrians
- pathfinding and stepping
- UI: draw cars and peds in intersections, even at lower zoom levels, just like on roads
- make them obey intersections (deterministically!)
- make them start and end at buildings
- trim the sidewalk path to the edge of a building

View File

@ -10,6 +10,7 @@ use CarID;
pub(crate) struct ParkingSimState {
// TODO hacky, but other types of lanes just mark 0 spots. :\
roads: Vec<ParkingLane>,
total_count: usize,
}
impl ParkingSimState {
@ -19,9 +20,14 @@ impl ParkingSimState {
.iter()
.map(|r| ParkingLane::new(r))
.collect(),
total_count: 0,
}
}
pub(crate) fn total_count(&self) -> usize {
self.total_count
}
// Kind of vague whether this should handle existing spots or not
pub(crate) fn seed_random_cars<R: Rng + ?Sized>(
&mut self,
@ -46,6 +52,7 @@ impl ParkingSimState {
}
}
}
self.total_count += new_cars;
println!(
"Seeded {} of {} parking spots with cars",
new_cars, total_capacity
@ -57,7 +64,8 @@ impl ParkingSimState {
}
pub(crate) fn remove_last_parked_car(&mut self, id: RoadID, car: CarID) {
self.roads[id.0].remove_last_parked_car(car)
self.roads[id.0].remove_last_parked_car(car);
self.total_count -= 1;
}
pub(crate) fn get_draw_cars(&self, id: RoadID, map: &Map) -> Vec<DrawCar> {

View File

@ -189,10 +189,12 @@ impl Sim {
.filter(|c| c.waiting_for.is_some())
.count();
format!(
"Time: {0:.2}, {1} / {2} cars waiting",
"Time: {0:.2}, {1} / {2} active cars waiting, {3} cars parked, {4} pedestrians",
self.time,
waiting,
self.driving_state.cars.len()
self.driving_state.cars.len(),
self.parking_state.total_count(),
self.walking_state.total_count(),
)
}

View File

@ -10,8 +10,9 @@ use {pick_goal_and_find_path, On, PedestrianID};
// TODO tune these!
// TODO make it vary, after we can easily serialize these
// TODO temporarily very high to debug peds faster
const SPEED: si::MeterPerSecond<f64> = si::MeterPerSecond {
value_unsafe: 0.9,
value_unsafe: 3.9,
_marker: std::marker::PhantomData,
};
@ -88,6 +89,9 @@ impl Pedestrian {
self.on = On::Road(road.id);
// Which end of the sidewalk are we entering?
// TODO are there cases where we should enter a new sidewalk and immediately enter a
// different turn, instead of always going to the other side of the sidealk? or are there
// enough turns to make that unnecessary?
if turn.parent == road.src_i {
self.contraflow = false;
self.dist_along = 0.0;
@ -116,6 +120,10 @@ impl WalkingSimState {
}
}
pub fn total_count(&self) -> usize {
self.id_counter
}
pub fn step(&mut self, delta_time: si::Second<f64>, map: &Map, control_map: &ControlMap) {
// Since pedestrians don't interact at all, any ordering and concurrency is deterministic
// here.