Traffic With Manners: Simulating City Drivers in a Pixel Art Game

The cars in Philadelphia Fiefdom drive like people who have somewhere to be, but would rather not hit anyone on the way. They keep a safe gap, signal before they turn or change lanes, wait their turn at a stop sign, don't block the box, ease over for a siren, and pull in to the curb for taxi fares and deliveries. None of it is canned: each driver follows a few rules from traffic research, with a temper of their own.
I wrote about laying out the streets from open data earlier, including the real one-ways, lanes and bike lanes. This post is about the traffic that drives on them.
How does a car know how fast to go?
Each car follows the car ahead using the Intelligent Driver Model, a model from traffic research that's good at one thing: smooth driving that never runs into the car in front. It looks ahead for whatever it has to stop for, whether that's the car in front, a stop line it can't cross yet or someone walking into the road, and works out how hard to speed up or brake.
Every driver has a temper, from pushy to calm. A pushy driver keeps about 0.9 seconds behind the car ahead, and a calm one about 1.6, which matches what real drivers in town do. It's a small number, but it's why a queue at a light doesn't move off like a train.
How do they handle junctions?
Junctions come in three kinds, as they do in the city:
- Traffic lights. The lights run off the world's clock, so every player sees the same light at the same moment. A left turn on green waits for oncoming traffic that's close.
- Stop signs. A full stop, then they go in the order they stopped.
- No signs at all. They give way to whatever's close.
At every junction, a car is only let into its turn when nothing crossing it is already turning and there's room for it on the far side, so nobody stops in the middle of the box. Drivers waiting a long time at a jam that never moves get to go first, so no knot of cars waits on each other forever.
8:30 a.m.
4 a.m.How many cars are out depends on the hour, from a trickle at 4 a.m. to the morning and evening rush.
Do they really signal?
Yes. A car turns its indicator on 30 meters or 3 seconds before its turn, whichever comes first, and keeps it on through the turn. For a lane change it signals a second before it moves over, then checks the gap again. If the gap has closed, it doesn't go. Most changes come out at three to five flashes, which is about what real drivers manage.
Lane changes use another model from the research, called MOBIL. A car moves over to get into the lane its next turn is from, to get out of a siren's way, or because the next lane is moving better and moving over wouldn't make anyone behind brake hard. Calm drivers need a bigger gain before they bother.

What happens when something's in the way?
A car stuck behind something that isn't part of the traffic, like a double-parked van or a crashed car, waits about two seconds and then goes round it once the way is clear. A queue at a light is a queue, though: nobody pulls out to skip it. If the whole street is blocked for good, a driver turns round with a three-point turn and goes back the way they came.
The horn has rules too. A driver taps it at someone stepping out in front of them, and leans on it when they're stuck behind a car that isn't moving, after a patience that depends on the driver. Some drivers never honk. At night, from 11:30 p.m. to 7 a.m., nobody honks at a jam.
When a siren comes up behind, the cars ahead going the same way slow down and ease over toward the curb, then pull out again once it's past. A car already turning through a junction keeps going to clear it.
Who else is on the road?
- Taxis. Some people heading across town walk to the curb and hail. A free taxi with its roof sign lit flashes its headlamps, signals in to the curb, picks them up and drops them off further on, then signals back out.
- Deliveries. Every so often a van near you pulls in to the curb by an open shop, and its driver carries a load inside, comes back out and drives off.
- People coming home. A car pulls in by a front door, its driver goes inside, and hours later comes back out and drives away. They only park where traffic can still get round them.
- Bikes. Cyclists ride in the bike lanes, and cars turning across a bike lane wait for a bike in it. At signalized junctions, cyclists turn left in two stages, the way Philadelphia's two-stage turn boxes ask them to.
Quick answers
Does the traffic react to trouble? Yes. Drivers avoid turning into a fire or a fight if there's another way, and a driver scared badly enough can leave their car and run.
Is the traffic the same for both players in co-op? Yes. The host runs all of it, and the lights run off the shared clock.
Can you drive? Yes, and the traffic reacts to you like anyone else. Ram a driver or pull them out of their seat, and a pushy one might get out to fight, while a calm one just leans on the horn.
Follow along
Philadelphia Fiefdom is an online sandbox set in Philadelphia. Last time was what happens when a car catches fire. Next is the fighting: counters, grabs and the street reacting. Join the playtest list to play it early, or come say hi on Discord (opens in a new tab).