FIRST VERSIONS OF TRAFFIC
For our first car simulator, even before CCD, traffic was created as an extremely logical and disciplined entity - it was planned that there would be a certain “manager” who strictly regulates and coordinates the actions of all cars. Individual cars could not analyze the traffic situation and make decisions on their own. Simply put, they had no autonomy and acted only on the order of the “manager”. It was an attempt to make a fully deterministic traffic, where no surprises occur.
However, creating such traffic is an extremely difficult task, given that there is at least one element of unpredictability on the road - the player. Therefore, the resulting result can be described with one phrase: “it somehow worked”.
TRAFFIC IN CITY CAR DRIVING
When development of the first CCD began, that system was abandoned. It was neither flexible, nor extensible, nor realistic enough for the product we were aiming for.
The only thing we took from the first version was the road network. Lanes for car traffic in it are defined with the help of splines (pre-planned mathematical curves), along which cars drive and pedestrians walk. The splines are laid out by level designers in an internal editor, which we have already mentioned in the early developer diaries. This road network turned out to be a very good solution, and, albeit with modifications, it is still in use today.
But unlike the first version, the cars were finally given free will. Each road user began to make his own decisions about where to go and what maneuver to make, and about other participants knew only what he could observe.
Machine vision, however, is not an easy issue at all. In this version it was implemented in a very simple way. The cars saw only the nearest car in front and the nearest car behind in their lane, as well as two cars in front and two behind in the neighboring lanes. To analyze the situation for a farther distance, we had to go through the cars in a chain, asking the front car its front car and so on.
It followed that the cars could not drive side-by-side in the same lane, and their movement was something like the movement of train cars. Implementation of maneuvers of lane change and overtaking caused a lot of problems, and turned out to be far from perfect, and at intersection we even we even had to make an external dispatcher, because there cars did not see each other at all!
Despite these limitations, in general the system turned out to be quite successful and has been used in many products for over 10 years. During this period the following features have been added to it:
- Dynamic trajectories for pedestrians crossing in the wrong place
- Cars entering and exiting parking lots
- Narrow forest roads with “pockets” for passing traffic
- Traffic passing other cars in the same lane on wide roads.
But the core of the system remained the same, so to implement all these features we had to resort to more and more “crutches”, and their work was not devoid of various “glitches”.
To read the diary in full, visit the City Car Driving 2.0 page on Steam