A/B Street: A simulation game to fix Seattle's traffic
abstreet.orgHi, author here. Previously posted to HN (https://news.ycombinator.com/item?id=21763636). I just released alpha -- check out this cheesy trailer (https://www.youtube.com/watch?v=LxPD4n_1-LU).
Happy to answer questions! And if you're serious about running this in your city, the importing process has improved greatly since December, so get in touch.
Reminds me of the Citybound game in (slow :( ) development by basically one guy and also written in Rust:
He demoed his actor system with 100 000 cars in the middle of this talk: https://www.youtube.com/watch?v=qr9GTTST_Dk
Maybe you guys should team up :) (if not already...)
Citybound looks awesome, but development seems a bit stalled. I've been in touch on r/citybound before, am following the project closely. There's also https://github.com/Uriopass/Scale, which has a really awesome demo running of Paris
There is also: https://store.steampowered.com/app/1067860/NewCity/ which i've seen with a couple hundred thousand actors.
It's like SimCity for a real city!
I tried the Windows version and some of the UI controls don't respond to mouse clicks, e.g. home and gear button in bottom left, speed controls and dropdown. I noticed the target areas for them are about 90px below where the buttons are painted. So when I click the checkbox to show/hide Bus, it actually turns on and off the one for Car. I'm on v0.2.0b and the client area of my game window (excluding titlebar, edges) is about 2560x1520.
Some elements, like the dropdowns at the top (Sandbox map and traffic setting) work ok.
EDIT: Looks like schemescape beat me to reporting this. I'd love to know if this was just a dumb "programmer-oops" or if there's an opportunity for the language/libraries/framework to better funnel code toward correctness.
I've seen a few interfaces with this issue now, another one being ultimaker cura (might be fixed in a current version) and the occasional game. Every time has been with scaling on, and always seems to move the clickbox down and to the right. Would love to know what causes it.
Minor issue I noticed: whenever I launch the app on Windows, the mouse hit-targeting is off vertically by ~40 pixels. Resizing the window makes the problem go away for the rest of the session. I'm on Windows 10, 1920x1080, and I haven't modified scaling/DPI settings.
Could you give https://github.com/dabreegster/abstreet/suites/828409393/art... a shot? If that URL disappears or you don't want to re-download the whole .zip, just the fixed binary is https://www.dropbox.com/s/j2hh8xrugtsxslc/game.exe?dl=0
That new build did NOT fix the issue for me.
Now that I'm looking more closely, this looks like some sort of initial aspect ratio issue, possibly related to a resize.
The game launches and the window either starts maximized or it maximizes itself. If I restore (un-maximize) and re-maximize, the aspect ratio is clearly different because the logo in the center of the screen gets slightly taller (while staying the same width).
In other words, the initial aspect ratio of the graphics seems incorrect (squished vertically slightly for me, running at 1920x1080).
https://github.com/dabreegster/abstreet/issues/65
Thanks for reporting! I'll try fixing this blind (no Windows machine handy) and send a new build; it'd be great if someone could confirm it.
Have you tried Virtualbox in whatever OS you're using to run a Windows VM?
I believe MS provides premade free virtualbox images for IE testing purposes too.
This sounds suspiciously familiar
Do you have your windows taskbar in non-default position? Mine is on top of screen and some games in some display modes give offset mouse position
It would be awesome to see you model some real changes that the city has made over the last few years, and see how closely the "predictions" made by your model match up with the observed data! The big one is the viaduct closure, but even little changes that you saw in your own experience, like "Bus lane now extends for two more streets," could be really informative.
1) How is assignment actually done? i.e given a trip from O to D, how does the model decide which mode to take and which roads/routes to take?
2) How well does it validate? I couldn't find any reference to observed traffic count data anywhere
1) Mode choice is fixed, coming from https://www.psrc.org/activity-based-travel-model-soundcast. Next work focus will be on adjusting mode choice when edits make it favorable to bike/walk. Route assignment is mentioned in https://dabreegster.github.io/abstreet/how_it_works.html (documenting all assumptions in an organized way has been really hard). There are score functions in https://github.com/dabreegster/abstreet/tree/master/map_mode... -- they're pretty simple right now.
2) I wrote a bit here: https://old.reddit.com/r/urbanplanning/comments/hdylmo/ab_st... In short, validation is hard, and I'd say I'm a bit understaffed.
Kudos for this.
Does this only simulate what would be considered a typical traffic load, or can it simulate outlier events (sport games, concerts, COVID quarantine, etc)?
Only fixed trips coming from https://www.psrc.org/activity-based-travel-model-soundcast. Demand modelling is next -- changes you make to the map will influence existing trips to change mode. The biggest difficulty in simulating outlier events is making a clear UI for specifying that new load.
I wonder what the how far the optimal is from existing for variations of global vs greedy (local) optimization.
Awesome job congratulations this looks it detailled, I can see there is a lot of work behind.
Does this take into account the CHAZ/CHOP?
There's been a small edit war in OpenStreetMap to keep up with the access restriction changes. Right now no, but when I grab fresh new OSM data, some roads will probably just disappear. Need to support no-through-access.
If you like this game consider checking out Cities Skylines. Traffic is a major part of the game. With the vanilla edition you can already do a lot, but if you want to route lanes you need the traffic manager mod https://steamcommunity.com/sharedfiles/filedetails/?id=16376...
Do any of the mods give the simulated people real commutes? I gave up after I made a city with a full subway system and zoned areas and watched as the simulated citizens left home, went to work, and then went to another random home at night.
It completely ruined my fancy subway system's timetable. :(
A relevant movie from the USSR comes to mind (which was also discussed recently): https://en.wikipedia.org/wiki/The_Irony_of_Fate
Another somewhat relevant film: :)
Oh. I've seen that.
Cities Skylines with the traffic manager mod is a great way to spend a whole lot of time if you are bored. It’s surprisingly fun to try to optimize traffic.
And surprisingly frustrating. Why is my city gridlocked? Because only the left most lane of my 6 lane avenue is being used by these 1000 hot dog trucks leaving my port.
As far as I've read, you can solve that problem by just not connecting the parts of your city, in which case the population just pretends everything works.
And if you ever make a bridge across a river... be prepared to add like 4 more next to it. My cities always end up looking ridiculous like that.
Sounds about right, actually. ;)
If you're interested in this kind of planning problems, check out the NeurIPS Flatland challenge, in which we try to optimize traffic on railway networks, in association with the Swiss and German railway companies!
https://www.aicrowd.com/challenges/neurips-2020-flatland-cha...
(disclaimer: I'm an organizer)
This simulation confirms that the easiest fix is to not have the West Seattle bridge be broken :)
I've been really hoping for the Maps team at Google/Waze to release a similar "traffic congestion" view to highlight consistent hot spots. A simulation is also pretty good, but the real data from Maps/Waze users will be even better!
Ideally, a government dashboard to see traffic congestion changes per year, month, day of week, but also hour. If we can create metrics for cities like p99 door-door trip time (i.e. latency) policy makers can better measure changes, bottlenecks, etc and plan better.
Your hope has come true! Kindof. I don't think this comes with a dashboard, but the data is there
https://www.digitaltrends.com/cars/waze-for-cities-data-puts...
The problem is there's only so much room for automobiles in a city. The more you decrease traffic, the more you'll induce demand to fill those improved traffic flow patterns.
The more infrastructure that is built downtown, the more people want to be downtown.
This. Traffic congestion is the result of many choices society has made. Subsidize driving or mass transit? Use land for more parking/roads/interchanges or housing/business/retail? Live close to work and pay high rent or commute 30 min. or more to save money? Allow flexible hours or require everyone to come in at 8 a.m.? Toll roads?
Now you've got a cool simulator to prove it!
That's not a reason to not improve infrastructure anymore than "the more chocolate we produce the more people want to buy chocolate" is a reason not to make chocolate. It just shows you're ludicrously underserving demand.
Efficiency matters. If allocating 100 million currency units to widening a highway from 5 lanes to 6 lanes improves people/hour capacity and quality of life less than other solutions, the other solutions should be chosen. In addition to diminishing returns on the way we’ve always done it, there’s a hard limit of about 2000 cars/hour/lane.
Chocolate is not free at the point of use but roads usually are. Without price signals or other limits people over-consume resulting in a shortage and people paying in time.
Hence an easy solution to traffic is increase the cost of driving. Which Seattle already has dynamic tolls which change in price:
The fact that it induces demand makes it more efficient, not less.
This is awesome, although part of the traffic problem is the horrible condition of the roads around Seattle, and a failure to enforce basic traffic laws - specifically - the left lane is for passing, and probably more importantly, do not stop in an intersection. Just because the light is yellow, doesn't mean we need to stack more cars into the middle of the road.
I walked to work (when I lived in Seattle recently) but the amount of traffic jams I saw caused by both regular people in their cars, and the mass transit bus drivers, driving right into an intersection as the light turned red is crazy. I don't know how you can plan traffic flow around it, because as green as the light might be, no one is moving with a bus sitting in the middle of the intersection.
Plenty of selfish/oblivious drivers, but don't overlook the selfish pedestrians causing intersection traffic backup too. There are plenty that are crossing right up until the light is red (even if they don't have a "walk" signal), making it impossible for more than one car to make the left turn. Everyone needs to work together.
Rad! It's a bummer that Amazon employees will have a hard time contributing to this (as Amazon prevents collaborating with anyone on any side projects that are 'games'.) Their offices surround some of the worst traffic in the city, and it'd be interesting to have some of their engineers contributing.
What, really? It's also an "urban planning tool," does that help?
What? That's a real thing? Bypassing the feeling of "how can that even be legal?", how can people join a company that puts these kind of restrictions on it's employees? Kind of feels like that Amazon employees put themselves in this situation, so hard to feel bad for them.
If any company tries to limit what I do in my free time, it's a quick and hard "no" on working for them.
They don't tell you until you've started.
That has to be illegal, even in the US?
This is completely awesome. I've considered doing something similar (mostly while sitting around in Austin looking at traffic lights backing up 100+ cars to allow 2-3 to enter from a side street) or looking at a pair of lights (accidentally?) acting like a metering device. Particularly city wide as I'm 100% convinced that the actual traffic engineers here are doing something wrong. They reworked a bike lane a few years back on a street I was driving on daily and then I could see them out there for months trying to work around the fact that they backed up a couple major intersections a couple blocks away as a result.
So the question is, given a bit of ML/etc driving it, and some actual commute time data, what are the changes something like this actually can be used to improve traffic?
There are lots of data quality and simulation assumption issues that prevent results from being meaningful. I'm mostly positioning this as a way to get people interested in coming up with specific ideas, but of course I'd love to reach trustworthiness parity with industry standard traffic sims.
I actually got started in traffic sim while I was in Austin! If you know anybody there who'd be interested in putting in some work to get the area running smoothly, I'd love to include it as a second city in the game.
The trailer looks amazing. I was actually just imagining a video game like this a few days ago, so it is something of a wish fulfillment plus baader meinhoff syndrome to see this.
I can't wait till tonight when I'll have enough time to get it installed and try it out!
This idea was supposed to be my master's thesis project. However I found something different and never did the original idea but's it's always been in my mind.
Big kudos to the author for this nice project ! I hope it gives further ideas to people playing it
This project is wicked cool, and I almost missed that they built it using Rust. I like the language a lot, and I think something like this is a sign of it moving towards real maturity, where the utility of the programs starts outshining the method of its construction. I'll be really curious to see if any project proposals end up citing this over the next couple years as an impetus for starting to experiment with different approaches to their traffic infrastructure, or at least inspiring people to become more engaged with it.
I gave a [talk](https://www.youtube.com/watch?v=chYd5I-5oyc) to a Rust meetup with lots of gory details, if it's interesting
Didn’t notice either, I’m aware of rust but I’ve not seen bigger codebase in it, will have pull it and have a nosy.
Thanks for pointing out that it’s in rust.
How much would be involved to adapt this to other cities?
https://github.com/dabreegster/abstreet/blob/master/docs/new...
Biggest barrier is lack of trip demand data. If you come up with how many people leave from building1 to building2 at time T using some mode of transport, then this can work.
I see you worked at Google at the same time I was there. I'm surprised we never got in touch, I helped work on a project that did traffic light optimization research, also investigating some of the approaches you mentioned, such as microbidding. We didn't build our own microsimulator but instead worked off of SUMO + OSM, which I'm sure you're familiar with. :)
I no longer work there either, but feel free to reach out if you're interested in chatting.
Hey this is something I've been working on as a side project for the last 2 years. Using traffic cameras to detect the flows through intersections with the goal of providing better stats to governments and city planners.
Hopefully I can have the poc going in the next month. A city wide integration with something like AB street would be really cool and was phase 2 for this project. Phase 3 being an optimised citywide traffic control.
Whoa, this would be awesome! Strongly consider publishing open datasets. :) Could you talk at all about how it works, or what privacy issues you've dealt with?
Sure, the system takes a raw camera feed and spits out an entry into a sql db which will then, depending on customer requirements, be provided in a format they want.
In between these steps, (all based in python) opencv takes the video, splits it, sticks some of the frames on a kafka cluster.
Another node picks up approx 2 fps, hands it to a object detection algo based on tensorflow which then puts the results on another kafka topic.
A heavily customised tracking algo pulls all of the frames available and the tensorflow results for initialisation and reverification. Once a vehicle is tracked through the field of view the vehicle is counted.
For the privacy issues, as this is only tracking for a short amount of time, not tracking between intersections and not tracking persistent uuids or numberplates, there shouldn't be too much trouble. But it will depend on the local law requirements. As this is a statistical problem, tracking the actual path of a car between point a and b isn't completely necessary if you can get a sufficient amount of coverage over a city. (You probably already understand this.)
As for opening the datasets up, I plan to do this with the poc. I've been using the Biloxi Mississippi camera live stream from youtube for all of my testing so far. My poc will be a website with this live stream having an overlayed view and the ability to download the stats for the day/month/year etc. As for other cities, I'm sure a FOIA will be able to get you the data. But I will be pushing to publish it openly as they will have to pay for it either way.
As you can probably tell, I'm trying to turn this into a business and the costs of actually collecting and processing the data isn't something that is reasonable for single person to bear. After talking to the traffic dept for my country, the largest city of 1.5m has about 3000 cameras. But I am aiming for a system that's cheap enough to enable 24/7 monitoring as that's when this all gets pretty exciting.
Woah, the data comes from OpenStreetMap!
Is it possible to create a map with one click for a new city?
I read through https://github.com/dabreegster/abstreet/blob/master/docs/art... but I can't tell if this must be manually followed.
https://github.com/dabreegster/abstreet/blob/master/docs/new...
Not quite one-click, but you can try the one-shot importer. You'll probably hit some issues; I have strict assertions to prevent regressions in Seattle. Please file a bug if you can't get a new place to work.
I would love to see a simulation system like this that also involved other "graph" components of city infrastructure -- like power, water, food, rail, air traffic, internet, mobile service etc. The ripple effects could be very hard to guess at, but could make for really interesting scenarios. Imagine trying to increase power when the only "lever" you can change is food prices!
In the real world, how is traffic routed? I often wonder what controls obviously inefficient intersections and how easy or hard it is to fix that.
I assume that there are software systems that take in schedules and various inputs (cameras, magnets, crosswalk buttons) but I'm curious if anyone works in the field and would talk about their experience.
Check out the Kimley-Horn Integrated Transportation System (KITS):
https://www.kimley-horn.com/service/kits-advanced-traffic-ma...
A user manual might give you some sense of the complications (bus priority, special events scheduling, etc.):
https://dpw.lacounty.gov/TNL/ITS/KITS/site_files/LACO%20KITS...
So cool! I'm sure there's a reason this hasn't been done, but I'm curious if there would be value in doing using this for some type of folding at home distributed optimization problem solving. Converging on actual suggest improvements that might not seem obvious
Adding a options for rethinking current systems would be nice.
For example, autonomous vehicles would be interesting. You potentially don't need intersection control with all autonomous traffic. Or what is the benefit of certain streets or lanes being designated autonomous only?
And what is the impact of education? Is there a way to change behavior that's cheaper than changing a street for example? You can change the street, but you can also change how people use the street.
> You potentially don't need intersection control with all autonomous traffic
I thought this myth had been widely debunked. In a world where every commuter drives a 100% autonomous car, you still have hobbyists driving old vintage cars, cyclists riding non-autonomous bikes, pedestrians, birds, runaway shopping carts, etc. disrupting the flow of traffic. Without traffic control you make the intersection in-crossible for a significant subset of the traffic.
When are we getting the CHAZ DLC?
Fixing the traffic lights would go a long way towards improving traffic flow in Seattle. How much time do you spend sitting at a red light when there's no cross traffic? How often are you and the 5 cars behind you abruptly stopped to let one cross traffic car through?
Lots of traffic lights already have cameras on them. Hook 'em up to an AI and a goal of maximizing throughput.
The paper for this is: On Traffic Light Control of Regular Towns by Elina Mancinelli, Guy Cohen, Stéphane Gaubert, Jean-Pierre Quadrat, Edmundo Rofman
https://www.researchgate.net/publication/281356849_On_Traffi... where you have nice (or almost) nice regular blocks with a constant speed. When you start deviating from this, the math all breaks down.
The ideal case would be to pulse the traffic such that given a certain amount of traffic flow and everyone following the proper speed limit that the time it takes for the traffic pulse to get to the next traffic light is green (and the pulse can continue).
This can be seen when you switch from one traffic light synchronization district to another - and hitting a traffic light.
There's a stretch on my commute where when I follow the speed limit (its 25 in this segment), I can go from one end of the traffic district to the next without ever hitting a red light (about 15 blocks).
The thing is that if the traffic isn't pulsed, then the spot where it changes from one traffic district to the next backs up significantly and causes other backups further down traffic.
This sounds simple but it really isn't.
First, the vast majority of signals aren't networked, they're on simple timers. And you can't just put them on the internet for hopefully obvious reasons.
Second, there's a bit of a butterfly effect. Change one thing and the whole system reacts in sometimes unpredictable ways.
Third, you need to account for pedestrians too. There's ADA requirements around how long signals are green for based on the width of the road.
Fourth, you need to account for pedestrian load. There's no cameras trained on the areas where pedestrians gather. If you're going to say they just need to press the button, no:
https://cal.streetsblog.org/2020/04/01/stop-touching-pedestr...
Basically, it's really not that simple.
I'm sure those are not insurmountable obstacles. For example,
> First, the vast majority of signals aren't networked, they're on simple timers.
Doesn't matter. Even doing the ones that are networked would be a big improvement.
> And you can't just put them on the internet for hopefully obvious reasons.
But you can put every neighboring building on the internet with their security cameras? It's not like you need hires or high frame rates to detect large moving blobs, count them, and estimate their speed & distance.
The problem is, the city has no incentive to do this, as the cost falls on other people.
The internet issue is a security one. Imagine what would happen if someone could make lights green in 2 directions.
To the first point, the networked lights are already in this mode (it's the reason why they added it in the first place). I can't find the report right now but upgrading all of the signals on 2nd from Denny to Yesler cost something like 30 million bucks.
The upgrade in the Mercer project area isn't exactly a glowing success:
https://www.theurbanist.org/2018/09/06/eleven-ways-adaptive-...
> Imagine what would happen if someone could make lights green in 2 directions.
I didn't consider it because the solution is obvious. An interlock that makes it electrically impossible to have 2 greens, like an airlock has a piece of hardware that prevents both doors opening at the same time. I suppose I should also mention the obvious that if the internet connection goes down, or the camera lens gets iced up, etc., it should automatically revert to egg-timer mode.
See https://en.wikipedia.org/wiki/Therac-25
> I can't find the report right now but upgrading all of the signals on 2nd from Denny to Yesler cost something like 30 million bucks.
Somehow the money is always found for internet connected cameras to spy on us.
> The upgrade in the Mercer project area isn't exactly a glowing success:
These are solvable problems. Except point 11, which is ironically complaining about it working successfully at what it was supposed to do.
Not really, all the above points was solved 40+ years ago.
https://en.wikipedia.org/wiki/Sydney_Coordinated_Adaptive_Tr...
I’m curious if you have any professional experience with this? How well does it accommodate bicyclist and pedestrian traffic flow? In Seattle they’re trying to accommodate these kinds of traffic instead of cars because it’s really expensive to build more streets. And we’ve learned over the past 20 years that optimizing for car traffic means making it less safe and harder to walk or bicycle.
Gee, Sydney here, I'd never heard of that. Sounds like it's to get buses and trams going faster.
We have some trams, mostly fairly new routes, but hardly any share the roads with traffic. There used to be a lot that did, until the 1960s I believe, but they got rid of them in favour of the supremacy of cars. We have good buses and trains (and ferries) here though.
That article you posted is just stupid. Yes, maybe now people won't be pressing buttons, but COVID won't be around forever. In a few months/years/whatever the pedestrian button will still be around, people will still press them, and they will still be a valid solution to traffic. The article also says:
> These buttons have long been decried and criticized by advocates for walking, anyway. The buttons’ purpose is less to keep people safe than to reinforce the primacy of cars on the street by forcing people who want to cross a street to “beg” for a walk signal.
This makes it sound like buttons are some kind of implement of the bourgeoise, used to "reinforce the primacy of cars" and keep the pedestrians powerless. In reality, whether pedestrians like it or not, cars are primary. The roads literally exist for cars. As a pedestrian, I would do the very difficult task of pressing a button, if it meant that as a driver I could have less traffic and hit less red lights.
Yes, I stopped reading when I got to this:
> Typically, a person expects the signal to show walk, then flashing don’t walk, then solid don’t walk. Signals follow a familiar pattern and people embed that pattern in their muscle memory. Adaptive signals, however, can flip from walk to don’t walk to walk again
That simply doesn't happen, adaptive or not.
Hey good idea! It's something I've been working on for the last two years. It sounds simple though doesn't it ;)
Keep an eye out on the hn home page I'll be posting my poc in the next month
As simple as this sounds, there are ramifications. It might make sense for YOU at that light at the time, but does it make sense for the greater good of flow?
Off hand, I'd say lights are often timed such that once you get one green you get a lot of greens, then you're asking for more stop and go traffic simply because someone showed up and threw off the sequence.
Take away that and you gain some benefits, but you also lose in other areas.
Not an easy problem.
> Not an easy problem.
That's what AI is good at. Besides, isn't a little incongruous to argue that the optimal solution for a complex optimization problem is a 1950's egg timer?
I live in the Seattle. An awful lot of intersections only have cars involved, not pedestrians and bikes. In fact, nearly all of them.
Besides, if you have an intersection that deals with 500 cars and 2 bikes, what would make the most sense to optimize for?