Streets of Cairo
It's a game where you have to drive through Cairo traffic to perform your errands. You have money, gas, nerves and time as resources. You can impersonate different classes of drivers (private with different cars, taxi, bus, microbus, motorcycle, truck). Cairo streets are full of dangers: other drivers, pedestrians, animals, police, speed bumps, presidents passing by, you know. Depending on who you are, other people's reactions to you differ. For example, police won't stop you often if you are driving a fancy car but people will fear you more if you are a microbus driver.
Interesting things about the game: Real patterns of Cairo traffic should emerge when running the software but should not be hardcoded in it. Traffic flow literature should be used. Real Cairo maps should also be used.
Model
To explore the nature of traffic flow via simulation, we have to build a model and its associated software representation. The model proposed here is very simplistic, to get started somewhere and add complexity only when needed.
A particle moves along a path. The particle parameters are position and acceleration. The path is a directed graph with additional geometric information (such as piecewise Bezier curves) associated with edges. The path curve define a 2D manifold in 3D space. A function determines the acceleration of the particle at successive time frames, and the next edge to travel at vertex points.
The particle acceleration function is the key to the traffic flow. It can be fully local functions, such as following the path curve or fully global, the total traffic function at every instant. Or somewhere in between.
Since cells take independent decisions as to how to set their position and acceleration at the next instant, a decision function must be used. Again a a simple decision function will suffice as a start. For example, minimizing the estimated time needed to travel between the starting position and the target position along some path in the graph. But the "estimated" times is a very vague definition, and it should be, since it is a subjective function. Further down are some observed patterns of traffic flow, that might be used as heuristics in more elaborate decision functions.
Patterns of traffic flow
- Cars tend to organize in clusters, with some cars at the lead opening the traffic, the rear cars aligning the trailing flow, and the body providing power(?) to the cluster.
- Obviously the order of the car in the cluster is relevant. Seen on a unidirectional multi-lane path, the order is mainly the rank of the car from the head - think Pole Position.
- A driver wanting to arrive faster will progress from the bottom of a cluster to its lead through the body, and maybe escape the cluster ahead to tackle the next one. He then has to progress throughout the whole rank of each cluster.
- Other drivers are happy to keep the rear or remain in the body, thus creating the cluster pattern by this preference.
- The shape of the cluster is determined by the behaviour of the cars. More abstractly, the 3 main positions (lead, body, rear) play specific roles in shaping the cluster. Of course, the environment (other clusters, stopped cars, the shape of the path) plays as important a role in the shaping. But we should not attempt to model the clustering effect. Instead, we should model the cars to have different effects/take different decisions in the flow depending on their positions and accelerations along the path.
Further explorations in traffic flow patterns can be found here.