Question from a completely clueless perspective.
The points you mention I always have and I have been wondering where to simulate it and get numerical answers to all those behaviors that can be infuriating.
In your seattle full map you say you heuristically got the time for the lights, but where is that coming from exactly, like would it be possible to infer that for another city from some kind of public data.
Is it in the domain of science fiction, there are so many parameters to take in account so it probably is impossible, that you could model the usual behavior of commuters in a city and then simulate whether the current traffic lights are set for the right length of time. I suppose some are updated live to react to traffic jams but in these circumstances there could also be way to simulate how shifting times would be the best to refluidify the traffic, instead of just going with brute force and empirical intuition which I assume is how it works most of the time.
Some traffic signals are adaptive (they'll switch phases sooner/later based on real-time vehicle detection, bus priority, etc) or even centrally controllable. I'm not modeling that yet.
This is pretty cool! One thing that bothers me about every traffic simulation I've ever seen, though: all of the vehicles and pedestrians here seem to be obeying the law.
That's just not realistic -- especially on Mercer, which is blocked (both directions) every few minutes in rush hour by some jerk trying to make an illegal turn onto a packed street. I'd say the main causes of traffic blockages that I encounter during rush hour are drivers blocking the box, and pedestrians entering the crosswalk against a red hand. I also see a lot of lane sweeping, too, which I assume is from the influx of drivers from California (where it's legal).
I hope traffic engineers aren't making real-world decisions based on simulations that follow all state laws perfectly, but I fear they are.
I've had a lot of fun tweaking this setting in Cities:Skylines. There's a user-written mod called Traffic Manager Presidential Edition which lets you enable some (but not all) bad behaviors.
The principle one is entering an intersection that they don't have room to leave, so they're still there when the signal changes and block the cross direction. (Is this AKA blocking the box? That sounds like a regional term.) This is needed to induce most forms of gridlock.
I'd love if it had more support for jaywalking and vehicles stopping in travel lanes with their flashers on. (And then I'd love if I had a lightning-bolt tool where I could just smite them from on high. There probably is a mod for that, actually.)
The feature, for anyone curious what the other rules it'll break are. [0] TMPE is such a great mod for improving the game's traffic simulation. I've spent a lot of time playing with timed traffic light systems. Cities Skylines will also automatically despawn vehicles to prevent massive gridlock that will break your city, and TMPE can disable this assistance for a truly difficult game.
In the US, you can generally only cross at crosswalks (for sections of roads that have crosswalks,) and only when the signal is in your favor if there is a signal. Beyond that it decays into a bunch of state and local laws.
You can get a ticket in many places for crossing at the wrong spot, or agains the signals, even if you didn't inconvenience anyone.
I take it that (most of) the US doesn't have pedestrian right of way, then? That's concerning; it suggests a whole host of other things around road culture, most of which are worrying. For instance, I predict that drivers are likely to pay less attention to the road, and that collisions with pedestrians are more lethal when they do occur.
I'm starting to see why the stereotypical USian drives everywhere, even in small areas.
Pedestrians have the right of way in the situations I mentioned, but not when "jaywalking."
You're not wrong about the system heavily favoring driver's convenience; and when drivers break the law (even if they injure someone) the punishments are light.
> Originally, the legal rule was that "all persons have an equal right in the highway, and that in exercising the right each shall take due care not to injure other users of the way".[8] In time, however, streets became the province of motorised traffic, both practically and legally. Automobile interests in the US took up the cause of labeling and scorning jaywalkers in the 1910s and early 1920s, by then the earlier term of "jay driver" was declining in use.[9][10] The earliest citation in the Oxford English Dictionary follows in 1917.
[8]: Miller McClintock for the Chicago Association of Commerce, "Report and Recommendations of the Metropolitan Street Traffic Survey", p. 133, quoted by Norton, Fighting Traffic, on p. 289.
[9]: Norton, Fighting Traffic, pp. 79-79.
[10]: Peter D. Norton, "Street Rivals: Jaywalking and the Invention of the Motor Age Street", Technology and Culture 48 (April 2007), 331-359 (342). doi:10.1353/tech.2007.0085
Just a warning for those visiting the US - crosswalks will only give you a false sense of security in many parts of the the country (bigger cities possibly excepted), many drivers pay 0 attention to them. Had a car narrowly miss me last week in a crosswalk, and honked at me as it whizzed by. I've never witnessed any enforcement of these kinds of violations against the drivers, either.
This is one of the many things I miss from cycling when driving a car: being able to just match speeds with someone else and hold a conversation over something that happened.
I agree with you. However, this may be obvious, but some of that could be due to people trying to follow Google Maps, Waze, or other similar navigation system directions where the routes are generated based on what other users have done.
I drove in downtown Seattle rush "hour" traffic for the first time in almost a year earlier this week, and Maps was giving me all kinds of dangerous, traffic-jam-causing directions. Things like "make a left turn at an uncontrolled intersection, from a side street onto an arterial that's gridlocked for about a kilometer in either direction". Apparently it had been happening for awhile, because the city had installed a barrier across the median, and I couldn't have followed the directions even if I'd wanted to.
IOW, it's not just drivers ignoring the law, it's tech companies explicitly instructing drivers to break the law and cause traffic problems that the simulations need to account for now.
It is. If a driver comes across the situation you described, any action other than a right-hand turn means they should probably take a driver's ed course again. Regardless of what a robotic voice on their phone is telling them.
Google maps once instructed my wife to do a U-turn on Lakeshore Drive. Nope.
That's certainly the ideal approach, but I don't think it's realistic to plan for normal people behaving that way.
By the time I realized that Google had given me a route that would not work, breaking out of it cost me 10 minutes of sitting in traffic going the wrong way. I think most people would take the "drive like a jerk" alternative at that point, because the sunk-cost illusion is hard to let go of.
A self-driving car is basically just going to do what the mapping software tells it to as well, so the "bad instructions from tech companies" factor is a problem that needs to be addressed specifically anyway.
Yes, and driver's ed should harp on the concept of ignoring the sat-nav if it's telling you obnoxious things. See my other comment.
I don't think this concept is mentioned anywhere in the current curriculum, and I think a lot of people are ignorant enough of technology to obey it more blindly than they should.
"Maps apps" consistently give me crazy directions in Seattle, in particular things like trying to turn left onto a busy road from a side street when one block over there's an arterial with a light. I really think the prevalence of crazy directions and Uber/Lyft drivers blindly following them must be hurting traffic flow in aggregate.
Not so much actions that break the law, but rather actions that are just pointless and stupid.
And the process for reporting a map error or unsafe maneuver instruction is way too complicated to do while moving, but can't be done after you've left the area, and there's no function to just submit a voice note.
Related:
Some time back, I gave my old TomTom to a not-very-technically adept friend. I figured a little introduction was in order, and at first, I asked her to interact with the unit while I did the driving.
The first thing I did was ignore every instruction. A few minutes of https://xkcd.com/1837/ ensued.
Because I wanted to drive home the point, you won't break it by ignoring it. If you don't feel like making that turn, don't make it. The voice in the box will just recalculate, it won't get annoyed, it has infinite patience and can recalculate for as many maneuvers as you feel like missing.
This is a crucial bit of understanding that I think many drivers lack, as they blindly try to follow impossible or unsafe maneuvers like the computer's word must be obeyed absolutely.
If I had a button which could project thoughts into other people's minds, but _only one thought_ and once programmed the button can never be changed, I think I might set it to "It's okay, just go past it, turn around, and come back." I think a huge fraction of traffic snarls could be eased by spamming the hell out of such a button.
I'd like to explore more realistic behavior at some point. Right now, vehicles will avoid starting a turn if there's not enough time left in the signal, but this is an optimistic estimate assuming nobody else is creeping along on the same turn: https://github.com/dabreegster/abstreet/blob/770507610caf4e4...
Right now, it's hard to get a full day of simulation to complete at all, because vehicles gridlock on really short roads inferred from OSM. Once a realistic amount of traffic can get through at all, then I'd love to simulate some percentage of illegal behavior.
I can't even be mad at people blocking the intersections anymore. I know it's not a valid argument, but if they don't do it, other people will and they'll be stuck there not moving at all.
Seattle is a good example of how bad design can create incredibly bad traffic despite the fact that number of cars are actually not that high. Assign a cop to certain intersections would relief most of the traffic I presume.
Another thing I'd be interested in seeing modeled are the people who squeeze into an exit lane at the very last minute. I've only ever commuted in the LA area but it's one of the biggest contributors to traffic by the freeway interchanges.
Yep. Happens all the time going northbound on 280 at the 101/280 interchange in SF. You'll always see at least one person clogging up one of the two 280 north lanes by trying to squeeze into the (almost always near-stationary) 101 north lanes. Then, further up 280, the same thing happens with the 6th Street exit, without fail.
Yes, I figured I probably wasn't clear enough. I agree with the points in the article but I'm referring to a different situation. For example, the one that kills me every morning is where the 101 S turns into the 134, there are 2 dedicated lanes for the 134 on-ramp (so no zipper merge) but people wait until the last possible minute to force their way into the dedicated lanes and clog both those and the surrounding ones. Similar situation where the 170 S hits the 134.
I swear I was discussing exactly this sort of simulation with my brother as both of us wondered how many city planners model the changes they are making to the road networks before pumping millions into projects that dump traffic from one point to another. Additionally, it'd be interesting to simulate the cascading effect of traffic violations like bad parkings, straddling lanes.
in nyc it's quite common (maybe even required) to run simulations of changes of infrastructure before making them to see how they will effect traffic.
source: my partner helps run these simulations as part of their job/their company gets contract work from the city all the time to check changes of bus routes/etc.
I've had some trouble getting in touch with the engineers who did this around Seattle. Any details they can share about the software they use, what metrics they base decisions on, where they pull demand data? Any thoughts on making the input and results of these simulations public so anybody can reproduce the analysis, experiment on their own, etc?
I've been thinking for a while now about building a system like this. There is one particular set of traffic lights on my commute which causes 45-60 minute delays at peak times. I've wondered how some small changes to timings of the light might reduce some of that, and was thinking about building something to simulate it and test my theory.
The other thing that is interesting about traffic patterns is how truly connected the entire network of roads are. You can have a collision on a major road which has a big impact on roads several miles away. I've always thought it would be fun to visualize that somehow, to determine not just the immediate effects of a change to a road system, but how it effects other commuter routes.
Definitely going to play around with this. Kudos to the author.
The professional simulators are prohibitively expensive for individuals to play around with, sadly. I had the chance to try VISSIM recently, and the UI was overwhelming -- the general public would never casually learn to use something that intricate. I'm trying to strike a balance between the heavy-duty simulation packages and existing city sim games -- something with a good approximation of a real city by default, and something that's very easy for anybody to pick up.
Agreed - I used VISSIM for some work in a university transportation research lab, and it was very interesting after learning how to use it - but both expensive and very intricate to learn. It even supports other types of transportation, like rail networks. It would be great to have a simplified version or some kind of middle ground to help people understand these complex systems.
Nice work. I'm wondering since this project seems to use its own nicely modularized GUI library, what motivated you in particular to write your own instead of using an existing Rust GUI library/game engine ? And would you make the same decision if you started now (vs 2 years ago) ?
I wouldn't call the GUI library "nicely modularized" at all. :) I regret rolling my own; the best choice when I started probably would have been https://github.com/Gekkio/imgui-rs. Recently iced has appeared and looks like the most promising.
Looks promising. But I don't see any sort of XML-like component layout/config so I assume it's all done by calling methods? That sounds kind of kludgy. Or am I missing an example?
While I'm not overly optimistic about his goal of getting solutions from the game to be enacted in real life Seattle, it's a really admirable idea and an impressive execution to boot.
I'm wondering if, with a big enough budget and a team of skilled devs like Dustin here, the local government could create more refined simulations to tackle these planning issues. Or would that inevitably run into the problem mentioned in his Project Mission: 'People are local experts on the small slice of the city they interact with daily -- the one left turn lane that always backs up or a certain set of poorly timed walk signals'?
Perhaps, with a large enough data pool, even these small quirks could be worked out via simulation?
> Project Mission: 'People are local experts on the small slice of the city they interact with daily -- the one left turn lane that always backs up or a certain set of poorly timed walk signals'
100% of the intersections I see that get backed up are backed up because someone blocks the box. Can we get more enforcement for that? They don't even need a patrol car. Just have an officer stand at the corner of Mercer and Westlake from 4pm to 7pm, and each time the light changes, walk out into the intersection and ticket the guy who's blocking it. You could write $1000 in tickets an hour, every night of the week.
Many intersections have threatening signs to this effect, but they don't do any good. I've never seen or heard of anyone getting ticketed for that.
I would also like to see some pedestrian bridges or tunnels that would allow walking commuters like me to cross our major streets (Mercer, Denny, Westlake, and Dexters) at any time. This, I strongly believe, could reduce traffic, make residential neighborhoods effectively closer to commercial areas (due to reduced walking time), and improve both vehicle and pedestrian safety. Bridges should be far less expensive than roads, and could be built very quickly.
Cars that block a lane tend to get honked at, and that seems like it should be enough to not to do it again. I made that mistake once and ever since have been vigilant about there being at least a car space available on the other side.
I would be supportive of this as long as it is done with some degree of discretion. On every traffic light cycle each side must release at least one car for the system to work out (traffic light timing must accommodate this). Sometimes that first car has to get into the intersection. I don’t really fault that driver for doing so.
The next step would be writing a program to modify intersections, monitor how long cars take to get a journey done and optimize the streets for total transit time, or emissions, or whatever. That's probably faster than letting people discover optima along their usual routes.
I'm pretty sure that is a NP-complete problem (or worse). Which means on the scale of a city all the computers in the world couldn't solve it in a human lifetime. A small town is easy, but in a large city is out of control.
Ignoring that, cities change. You can come up with an optimal system, but people get new jobs, move to new houses, have kids, die, just to name a few obvious things that affect traffic - it might seem minor but they all add up to your optimal system today being wrong for tomorrow.
Even ignoring that, budgets are finite. The ideal solution probably is to tear down all buildings, move the mountain a few dozen miles east, re-reoute the river, change the shoreline, and then rebuild. Any one of them is possible on a small scale, but not on the whole thing all at once (you wouldn't move a whole mountain, but we have created passes).
Really the best we can do is come up with ideas that are affordable and then test them. One thing this can do well (if the simulation is good!) is let us see if fixing one are makes a different area worse - which helps as talk about the trade offs in the projects we can afford to do.
I've brainstormed with some people about trying reinforcement learning. It's not a direction I'm prioritizing anytime soon, but if you're interested in this, I'm happy to adjust the sim and analysis layer to make this as easy as possible.
This is really fucking cool. And I love your ultimate objective: to allow informed public participation in transport planning. Nice developer info, too. Looking forward to playing with this.
Yes it's awesome! Calling it just a 'traffic simulation game' is probably a disservice to the potential applications of something like this. Very inspiring!
That reminds me of Sumo[1] a open source traffic simulator I used at university to import a OSM map of town, populate it with activity based traffic and simulated the traffic under different conditions.
While that isn't quite as 'gameified' as this, it was fun!
(It's scary thinking a half-mile traffic jam starts at 4am... and I can't help but wonder what it looks like at more sane hours such as 8:30am or 5:15pm. Is everything just red for miles around?)
The jam is probably not realistic. Because that area is a divided set of one-way roads, there are a few intersections each tagged with a traffic signal in OpenStreetMap. I'm simulating each signal independently right now. In reality, it's one signal with more reasonable timing.
(Also sorry for the slow replies, HN is rate-limiting comments because this is a new account.)
I have a theory that restricting an on-ramp/off-ramp for one street during peak rush hour will significantly improve traffic flow on my freeway commute. I’ve taken the time to propose the change to my department of transportation, suggesting they simulate the change. Expect that suggestion went straight into the trash can.
Realistically, modeling this section of the freeway would be difficult, and proving there would be a net benefit - even harder, because there are accidents due to this on-ramp merge which cause the delays. The simulation has to model accidents to be valid.
If anyone knows of a way to simulate traffic, including changing accident probability based upon traffic flow (quick stops caused by merging traffic likely increase the accident probability), I’d like to model my commute and provide that to the department of transportation.
Not a mirror, it was forked initially from that repo 2 years or so ago when the codebase had just roughly 20 commits, and it the contributor graph shows it is indeed basically just Dustin working on this.
I started the project while I was working at Google, went through the open source process, and then left a short while after to work on it full-time. There's no affiliation with Google.
It's a bit more of a story to tell offline. In short, the stable money stream quickly leads to a comfortable savings, giving me time to try an experiment like this. Right now I'm motivated by technically interesting projects that might lead towards good things in the real world, and once I was in a position to realize that, there was no way I wouldn't be working on A/B St.
Amazing! This is basically a live action more detailed version of Cities:Skylines. That game taught me how much of a blocker traffic turning across other traffic is, and the benefits of one-way systems in avoiding that.
Looking at the Cargo.toml for ezgui this uses glium which is an attempt at making OpenGL safe using the typesystem. I don't think it's worth the hassle.
For 2D I'd recommend ggez, it's easily the simplest and most polished rust game toolkit.
There's a good wrapper for SDL2, but I forget which one it is.
wgpu-rs is a really cool next-gen-but-easier-to-use cross platform graphics API. It's early days though so you have to be willing to do some legwork.
Amethyst is taking a shot at a Godot or Unity style modern integrated game engine. It'll be a while before they get to that level but it's still useful and reasonably well documented.
In theory, https://github.com/dabreegster/abstreet/blob/master/docs/new.... There are a bunch of unsolved problems -- for example, most places in OSM don't map on-street parking, so there won't be any. For Seattle, I'm inferring from an extra shapefile. Have to figure out how to generalize that.