The SimCity crew have updated their blog with a posting about how Streetcars work in the game as they’ve gotten a couple requests for it. It’s really neat how the programming works behind the transport. They even mention that they are looking into how to address traffic (jam) concerns.
SimCity Street Cars
Hello mayors! We’ve noticed there have been a lot of questions about how public transit works under the hood, so today I’m going to lift that hood.
Let’s look at a city with a simple streetcar loop going through it. There are a few stops and a depot, and some cars are going from stop to stop, picking people up and dropping them off.
Now let’s look at the pathing data for the “pick up” destination. This destination becomes available to the streetcars when Sims are waiting to be picked up at a stop.
The numbers with “<- X ->” represent how many people are waiting at stops on that particular road segment, while the other numbers represent the distance to the destination minus the number of people waiting.
Going clockwise and starting from the top left, you can see there are 10 people waiting, then 15, then 5, then 1, then 48, then 21.
When a streetcar leaves the depot, it’s going to make a left turn, as there’s less “work” to get to the 21 people who need to be picked up, since the stop is very close and the 48 people who are waiting on the right are too far comparatively.
If there was a situation where 300 people were waiting at the first stop to the right of the depot, and only one was waiting on the left, then the streetcars would make a right turn as they exit every time until everyone in the crowded stop is picked up. Then the next streetcar would make a left turn to pick up that one person.
There are a couple of obvious issues with this approach though:
- If there are 300 Sims waiting for the streetcar on the other side of the loop for example, they may have to wait a long time for the vehicles to make their way. To remedy this problem, we’re looking into make crowded stops “high priority pick-up” destinations that transit vehicles will go to first.
- Another problem is that, well, all the vehicles that are in the same area and want to go to the same destination type will all follow the same path, resulting in clumping and general traffic problems. We’re looking into various ways to improve the situation so traffic will spread out better.
You can also see that the data regarding streetcar destinations is only populated on the avenue with streetcar tracks. Regular roads are not part of the calculation (it says “inf” for “infinite” in the picture.)
Now let’s talk about what happens when a streetcar makes a stop. First, we try to drop off as many people as possible, based on the type of destinations located near the stop (like workplaces, shopping, home, school, etc). Then we pick up people based on what types of destination are available near other streetcar stops. Finally, we decide where the streetcar should go next.
If there is still room in the streetcar, then there’s a 75 percent chance we’ll send it to pick up more passengers. That said, if there’s nobody needing to be picked up at any stop on the line, we’ll make the streetcar drop off passengers at the first “DropOffAtX” destination, based on where the passengers want to go.
And then if that destination is not available, we’ll make the streetcar go back to the garage. (Streetcars do not use the “Trade Pick Up” destination, that’s only for buses, ferries & other vehicles that can go to other cities to pick up commuters and tourists.)
In 25% of the cases if there’s still room in the streetcar, as opposed to 100% of the time if it’s full, we’ll send the vehicle straight to a “drop off” destination.
Finally, if the streetcar is empty, there’s a 25% chance that it will go to the closest next stop on the line, and a 75% chance it will attempt to pick up passengers. And if all the stops have been visited recently, or there is nobody waiting to be picked up, then it will go back to the depot.