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.

Cooperation vs. Defection

The decision function that each particle/car uses to determine its acceleration vector at any point can include elements of elementary game theory. Specifically, cooperative strategies used in the prisoner's dilemma problem (French article) can be applied to decide whether a driver will cooperate with neighbouring drivers or defect from them when their decisions affect their common flow. The difference with traditional prisoner's dilemma games is that the payoff matrix is not static but dynamic, in that the values of cooperation/defection vary according to their contribution to the global goal to be minimized, e.g. the estimated time to arrival.

Lines of flux

Lines of traffic flow are the carrier wave of the particles along the path. The flux wave is formed by the environmental factors affecting the road, such as curvature/centrifugal force, topology and geometry of the street, etc. There seems to be a relationship between the velocity of the car and the lines of flow that it's subjected to, e.g. on a curve according to centrifugal force. In general, how to translate those factors into a wave is rather unclear. Nevertheless, the wave would act as a summary of the environment, leading to a simpler and more efficient implementation.

A case study

Let's simulate driving on the 6th of October bridge, from start (Dokki) to finish (Nasr Road for example - where's Google Maps when you need it?). To do this we need to map out the lines of flux in both directions of the bridge, noting the sections during which flux patterns are stable and the junctions at which they change. The flux is described by the paths traced by cars in each section and the velocity/acceleration along those paths. A good setup to perform this reading is by driving along, late night, taking notes on a portable digital voice recorder in real-time to be dumped later via computer.

Software implementation

The proposed software implementation will use the following tools: C++ or Java to build and run the conceptual model and OpenGL to render the 3D scene. Two views are provided: a bird's eye view somewhere above the particle, and a first-person view in the direction of motion. The path and particles are rendered.