Skip to content

Commit

Permalink
Restore old logic partly. Now SMP gridlocks horribly.
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Apr 28, 2022
1 parent 4a6561e commit 488ab70
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sim/src/mechanics/intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ impl IntersectionSimState {
return false;
}

let turn = map.get_t(req.turn);

// Once upon a time, we'd make sure that this request doesn't conflict with another in
// self.waiting:
// 1) Higher-ranking turns get to go first.
Expand All @@ -876,11 +878,21 @@ impl IntersectionSimState {
// that events are processed in time order mean that case #2 is magically handled anyway.
// If a case #1 could've started by now, then they would have. Since they didn't, they must
// be blocked.
for other_req in self.state[&req.turn.parent].waiting.keys() {
if map.get_t(other_req.turn).conflicts_with(turn)
&& our_priority < sign.get_priority(other_req.turn, map)
{
info!(
"{} yielding to {} who's waiting",
req.agent, other_req.agent
);
return false;
}
}

// Can we optimistically finish this turn before an approaching higher-priority vehicle
// wants to begin?

let turn = map.get_t(req.turn);
let expected_finish = now + turn.geom.length() / speed;
for (_, (other_req, eta)) in &self.state[&req.turn.parent].leader_eta {
if expected_finish < *eta {
Expand Down

0 comments on commit 488ab70

Please sign in to comment.