diff --git a/docs/TODO_quality.md b/docs/TODO_quality.md index 68528f25cf..93977f6222 100644 --- a/docs/TODO_quality.md +++ b/docs/TODO_quality.md @@ -115,8 +115,6 @@ - validation (just do it in spawn and return an error?) - getting the path - converting goal into router and such - - is overtime necessary? - - all the scoring/query stuff is so terrible - perf - speed up Scheduler diff --git a/editor/src/common/turn_cycler.rs b/editor/src/common/turn_cycler.rs index f84581895f..996919327f 100644 --- a/editor/src/common/turn_cycler.rs +++ b/editor/src/common/turn_cycler.rs @@ -2,7 +2,6 @@ use crate::helpers::ID; use crate::render::{draw_signal_diagram, DrawCtx, DrawTurn}; use crate::ui::UI; use ezgui::{Color, EventCtx, GfxCtx, Key}; -use geom::Duration; use map_model::{IntersectionID, LaneID, Map, TurnType}; pub struct TurnCyclerState { @@ -89,12 +88,8 @@ impl TurnCyclerState { State::ShowIntersection(i) => { if self.shift_key_held { if let Some(signal) = ui.primary.map.maybe_get_traffic_signal(i) { - let (cycle, mut time_left) = + let (cycle, time_left) = signal.current_cycle_and_remaining_time(ui.primary.sim.time()); - if ui.primary.sim.is_in_overtime(i, &ui.primary.map) { - // TODO Hacky way of indicating overtime. Should make a 3-case enum. - time_left = Duration::seconds(-1.0); - } let ctx = DrawCtx { cs: &ui.cs, map: &ui.primary.map, diff --git a/editor/src/render/intersection.rs b/editor/src/render/intersection.rs index 32545ade85..eb4b66c690 100644 --- a/editor/src/render/intersection.rs +++ b/editor/src/render/intersection.rs @@ -140,20 +140,18 @@ impl Renderable for DrawIntersection { && opts.suppress_traffic_signal_details != Some(self.id) { let signal = ctx.map.get_traffic_signal(self.id); - if !ctx.sim.is_in_overtime(self.id, ctx.map) { - let mut maybe_redraw = self.draw_traffic_signal.borrow_mut(); - let recalc = maybe_redraw - .as_ref() - .map(|(_, t)| *t != ctx.sim.time()) - .unwrap_or(true); - if recalc { - let (cycle, t) = signal.current_cycle_and_remaining_time(ctx.sim.time()); - let mut batch = GeomBatch::new(); - draw_signal_cycle(cycle, Some(t), &mut batch, ctx); - *maybe_redraw = Some((g.prerender.upload(batch), ctx.sim.time())); - } - g.redraw(&maybe_redraw.as_ref().unwrap().0); + let mut maybe_redraw = self.draw_traffic_signal.borrow_mut(); + let recalc = maybe_redraw + .as_ref() + .map(|(_, t)| *t != ctx.sim.time()) + .unwrap_or(true); + if recalc { + let (cycle, t) = signal.current_cycle_and_remaining_time(ctx.sim.time()); + let mut batch = GeomBatch::new(); + draw_signal_cycle(cycle, Some(t), &mut batch, ctx); + *maybe_redraw = Some((g.prerender.upload(batch), ctx.sim.time())); } + g.redraw(&maybe_redraw.as_ref().unwrap().0); } } } @@ -397,22 +395,12 @@ pub fn draw_signal_diagram( let mut labels = Vec::new(); for (idx, cycle) in cycles.iter().enumerate() { if idx == current_cycle && time_left.is_some() { - // TODO Hacky way of indicating overtime - if time_left.unwrap() < Duration::ZERO { - let mut txt = Text::from_line(format!("Cycle {}: ", idx + 1)); - txt.append( - "OVERTIME".to_string(), - Some(ctx.cs.get_def("signal overtime", Color::RED)), - ); - labels.push(txt); - } else { - labels.push(Text::from_line(format!( - "Cycle {}: {:.01}s / {}", - idx + 1, - (cycle.duration - time_left.unwrap()).inner_seconds(), - cycle.duration - ))); - } + labels.push(Text::from_line(format!( + "Cycle {}: {:.01}s / {}", + idx + 1, + (cycle.duration - time_left.unwrap()).inner_seconds(), + cycle.duration + ))); } else { labels.push(Text::from_line(format!( "Cycle {}: {}", diff --git a/release/linux_or_mac.sh b/release/linux_or_mac.sh index 0b66de0cc4..3e9969269a 100755 --- a/release/linux_or_mac.sh +++ b/release/linux_or_mac.sh @@ -11,7 +11,7 @@ fi rm -rfv $OUT mkdir $OUT -cp color_scheme docs/INSTRUCTIONS.md release/play_abstreet.sh $OUT +cp color_scheme.json docs/INSTRUCTIONS.md release/play_abstreet.sh $OUT mkdir -p $OUT/data/maps for map in 23rd ballard caphill downtown montlake; do @@ -19,7 +19,7 @@ for map in 23rd ballard caphill downtown montlake; do done mkdir -p $OUT/data/shapes -cp -v data/shapes/popdat $OUT/data/shapes +cp -v data/shapes/popdat.bin $OUT/data/shapes mkdir $OUT/editor cargo build --release --bin editor diff --git a/release/windows.sh b/release/windows.sh index d7d4b88297..45cdbb4326 100755 --- a/release/windows.sh +++ b/release/windows.sh @@ -7,7 +7,7 @@ OUT=abstreet_windows rm -rfv $OUT mkdir $OUT -cp color_scheme docs/INSTRUCTIONS.md release/play_abstreet.bat $OUT +cp color_scheme.json docs/INSTRUCTIONS.md release/play_abstreet.bat $OUT mkdir -p $OUT/data/maps for map in 23rd ballard caphill downtown montlake; do @@ -15,7 +15,7 @@ for map in 23rd ballard caphill downtown montlake; do done mkdir -p $OUT/data/shapes -cp -v data/shapes/popdat $OUT/data/shapes +cp -v data/shapes/popdat.bin $OUT/data/shapes mkdir $OUT/editor cross build --release --target x86_64-pc-windows-gnu --bin editor diff --git a/sim/src/mechanics/driving.rs b/sim/src/mechanics/driving.rs index 7b2dc00a9f..5926553d6b 100644 --- a/sim/src/mechanics/driving.rs +++ b/sim/src/mechanics/driving.rs @@ -738,8 +738,8 @@ impl DrivingSimState { car.vehicle.owner } - // This ignores capacity, pedestrians, and traffic signal overtime. So it should yield false - // positives (thinks there's gridlock, when there isn't) but never false negatives. + // This ignores capacity and pedestrians. So it should yield false positives (thinks there's + // gridlock, when there isn't) but never false negatives. pub fn detect_gridlock(&self, map: &Map) -> bool { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] enum Node { diff --git a/sim/src/mechanics/intersection.rs b/sim/src/mechanics/intersection.rs index a03284196f..d7c18b1059 100644 --- a/sim/src/mechanics/intersection.rs +++ b/sim/src/mechanics/intersection.rs @@ -67,8 +67,8 @@ impl IntersectionSimState { assert!(state.accepted.remove(&Request { agent, turn })); // TODO Could be smarter here. For both policies, only wake up agents that would then be - // accepted. For now, wake up everyone -- for traffic signals, maybe we were in overtime, - // or maybe a Yield and Priority finished and could let another one in. + // accepted. For now, wake up everyone -- for traffic signals, maybe a Yield and Priority + // finished and could let another one in. for req in state.waiting.keys() { // TODO Use update because multiple agents could finish a turn at the same time, before @@ -155,18 +155,6 @@ impl IntersectionSimState { .map(|req| req.agent) .collect() } - - pub fn is_in_overtime(&self, time: Duration, id: IntersectionID, map: &Map) -> bool { - if let Some(ref signal) = map.maybe_get_traffic_signal(id) { - let (cycle, _) = signal.current_cycle_and_remaining_time(time); - self.state[&id] - .accepted - .iter() - .any(|req| cycle.get_priority(req.turn) == TurnPriority::Banned) - } else { - false - } - } } impl State { @@ -237,17 +225,6 @@ impl State { ) -> bool { let (cycle, _remaining_cycle_time) = signal.current_cycle_and_remaining_time(time); - // For now, just maintain safety when agents over-run. - for req in &self.accepted { - if cycle.get_priority(req.turn) == TurnPriority::Banned { - /*println!( - "{:?} is still doing {} after the cycle is over", - req.agent, req.turn - );*/ - return false; - } - } - // Can't go at all this cycle. if cycle.get_priority(new_req.turn) == TurnPriority::Banned { return false; @@ -272,8 +249,7 @@ impl State { // higher-priority vehicle wants to begin. // TODO Don't accept the agent if they won't finish the turn in time. If the turn and - // target lane were clear, we could calculate the time, but it gets hard. For now, allow - // overtime. This is trivial for peds. + // target lane were clear, we could calculate the time. true } diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 613c79faef..2d6ecf5a7c 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -56,7 +56,10 @@ pub struct Sim { impl Sim { pub fn new(map: &Map, run_name: String, savestate_every: Option) -> Sim { let mut scheduler = Scheduler::new(); - scheduler.push(CHECK_FOR_GRIDLOCK_FREQUENCY, Command::CheckForGridlock); + // TODO Gridlock detection doesn't add value right now. + if false { + scheduler.push(CHECK_FOR_GRIDLOCK_FREQUENCY, Command::CheckForGridlock); + } if let Some(d) = savestate_every { scheduler.push(d, Command::Savestate(d)); } @@ -780,8 +783,4 @@ impl Sim { pub fn get_accepted_agents(&self, id: IntersectionID) -> HashSet { self.intersections.get_accepted_agents(id) } - - pub fn is_in_overtime(&self, id: IntersectionID, map: &Map) -> bool { - self.intersections.is_in_overtime(self.time, id, map) - } }