
Learn: The Game Designer Profession from Scratch to PRO
Learn MoreModern gaming cities, as a rule, imply the presence of cars. It's important for these vehicles to obey traffic rules, create traffic jams, and occasionally collide with each other. This adds realism to the game environment and makes the gameplay more engaging for users. Realistic vehicle behavior in the game helps create the atmosphere of a real metropolis, where players can experience all the nuances of city life.
Developers face an important challenge: how to optimally configure artificial intelligence to realistically simulate urban traffic. Standard flock simulations are unsuitable in this case, as each vehicle must be treated as an independent unit. It must follow its own individual route, rather than a single trajectory. To achieve realism, it is necessary to consider many factors, such as driver behavior, road conditions, and interactions with other road users. Properly tuning the AI in this area is key to creating accurate and effective urban traffic models.
Each game unit must not only find its place on the playing field but also adapt to constantly changing environmental conditions. In this article, we explore how developers of various games have addressed this challenge.
Angel Studios Games
The Midtown Madness racing game series, launched in 1999, differs from other games in the genre thanks to its open world. In the first game, players were able to freely explore Chicago, which was a novelty for racing simulators at the time. The second game added new cities—San Francisco and London—expanding the player's horizons and offering new unique locations. The third game introduced Paris and Washington, D.C., which further increased the variety of game routes and opportunities for exploration. Midtown Madness became an iconic series, combining elements of racing and free movement in cities, which attracted a wide audience and ensured its popularity for many years.
Cars moved on the roads, traffic lights worked, and pedestrians walked on the sidewalks. Police sometimes activated sirens and pursued the player. The first two games were developed by Angel Studios, which later became known as Rockstar San Diego. In 2000, it also launched a similar game series, Midnight Club, offering players open cities and exciting racing.

Angel Studios applied a unified AI development method for both games, simulating traffic flow on city streets. This approach creates a realistic atmosphere and improves player interaction with the game world. The use of advanced algorithms and technologies ensures dynamic and realistic vehicle behavior, significantly increasing the level of immersion.
From an AI perspective, the city map consists of three main components: roads, intersections, and open spaces such as parks and plazas. Open spaces also include roads, but the AI perceives them differently. These elements are used to optimize routes, allowing the AI to find shorter paths and plan traffic efficiently. Understanding the structure of urban infrastructure is key to developing intelligent navigation systems that help users find optimal routes and avoid congestion.
In the game, each car moves along a spline—a curve created in space along the X and Z axes. This curve is generated automatically as the vehicle moves. The road is divided into small segments, and as the car leaves one segment and enters the next, the next part of the spline is calculated. This approach ensures smooth and realistic car movement in the gameplay.

If the car hits an obstacle and goes beyond the set route, the system will automatically generate a spline that will return it to the path. This traffic organization ensures a smooth transition from one section of the road to another, eliminating the need to pre-plan routes for vehicles in urban environments. This approach makes driving more efficient and adaptive, improving overall safety and driving comfort.
On the roads, the artificial intelligence has a speed limit. Each car is randomly assigned a value reflecting how much it exceeds or falls below the permitted speed. This helps create a more natural and realistic flow of cars, simulating the chaotic nature of road traffic.
However, another question arises. How can we avoid constant collisions between vehicles if they are moving at different speeds? The problem is that allowing each car to check for the possibility of a collision with surrounding vehicles will significantly reduce game performance. An increase in the number of calculations per unit of time can lead to lag and deterioration of gameplay. Therefore, it is necessary to develop more efficient collision management algorithms that maintain high performance while ensuring realistic interactions between objects.
As a compromise between speed and coverage, each car analyzes only the vehicle in front of it in its lane. The distance between them is checked every frame. If the distance is too small, the car behind automatically slows down to match the speed of the car in front. As soon as the car in front accelerates, the car behind attempts to regain its previous speed, taking into account the speed limit on the given road.
Joe Azdima is an experienced AI programmer who has made significant contributions to popular games such as Midtown Madness, Midtown Madness 2, and Midnight Club. His work on these projects helped create immersive gameplay and improve player interaction with the world around them. Thanks to his professionalism and innovative approaches, games have become more exciting and realistic, which made them true classics in the world of video games.

Vehicle movement through intersections is organized using specialized logic that checks whether a vehicle meets four key conditions. This system ensures safe and efficient movement at intersections, minimizing the risk of accidents and improving the overall traffic situation. Optimizing such processes is an important part of modern traffic management.
First, approval must be obtained from the system that regulates vehicle response to traffic lights. There are four states that can be assigned to roads leading to an intersection. These states play a key role in traffic management and ensuring road safety. Correct interpretation of traffic light signals allows vehicles to effectively interact with each other and prevent accidents. Understanding these states is an important aspect for developing autonomous driving systems and improving overall road safety.
- NoStop — cars from this road can safely proceed through the intersection.
- AllwayStop — cars on this road must stop before the intersection and stand, regardless of the traffic light.
- TrafficLight — vehicles on this road will proceed through the intersection when the green light comes on.
- StopSign — the vehicle that has been waiting the longest can proceed.
The system must confirm that an accident will not occur at the intersection when cars are allowed to proceed.
When crossing an intersection, it is important that there is enough space on the road you are entering to completely accommodate the car. This condition ensures traffic safety and prevents accidents. Ensure that the road is long enough for your vehicle to fit completely, which is an important aspect of proper road behavior.
The fourth and final check analyzes whether other AI-controlled vehicles are entering the intersection. This stage is critical for ensuring road safety, as it helps avoid potential collisions and improve the efficiency of interaction between vehicles. The system evaluates the movement of other vehicles and takes the necessary measures to prevent accidents.
This check is necessary when a vehicle turns from a road with a StopSign onto a road with a TrafficLight. Stopping at a StopSign implies that the vehicle that has waited the longest has the right to proceed through the intersection. However, in practice, it will only be able to enter the desired road after the vehicles for which the green light has crossed the intersection.
Joe Azdima is an AI programmer who has made significant contributions to games such as Midtown Madness, Midtown Madness 2, and Midnight Club. His experience and skills in AI programming helped create unique gameplay mechanics and realistic NPC behavior, making these projects popular among players. Azdima continues to work in game development, improving artificial intelligence technologies to create even more engaging and immersive gaming worlds.

When all four checks are completed and the car is moving through the intersection, it needs to decide on its next direction - left, right, or straight ahead. This decision is based on the following rules.
If the car is in the far left lane, it has the option of moving left or continuing straight ahead. If it is in the far right lane, it can turn right or go straight ahead. Cars in the center lanes can only move straight ahead. On a one-way road, a car can choose one of the adjacent streets. It should be noted that sharp U-turns are prohibited, since such a movement trajectory looks unnatural and does not comply with traffic rules.
On long roads, cars can change lanes to ensure an even distribution of vehicles. The lane change process begins when the car has covered about 25% of the total road length. At this point, the car calculates a spline that ensures a smooth transition from one lane to another. At the same time, a check for a possible collision with the car in front is carried out simultaneously on all lanes, which increases traffic safety and reduces the risk of accidents.

To optimize computer resource usage during urban simulation, vehicle behavior is simulated only for vehicles in close proximity to the player. This area, known as the simulation bubble, encompasses a limited radius, allowing for efficient management of computing power and maintaining smooth gameplay.
Cars in the simulation are constantly moving, leading them to approach the boundary of the simulation bubble. When a car encounters a two-way road, it switches to the oncoming lane and begins moving back toward the player. If a car is driven on a one-way road, it is returned to the car pool, from where the game can reuse it for placement on roads.
Driver: San Francisco
Released in 2011, Driver: San Francisco takes a unique approach to generating city traffic, adapted to the specifics of gameplay. Players have access to a vast open city where they must complete a variety of missions. A distinctive feature of the gameplay is the ability to change into any car they see on the road at any time, which adds dynamism and freedom to the gameplay.
Unlike GTA, Driver: San Francisco does not require you to leave the car. The main character, a detective, falls into a coma and conducts an investigation, moving between drivers. To ensure that the car he leaves does not stop, but continues moving, the developers created an advanced artificial intelligence system. This unique mechanic adds dynamism to the game and makes the story more engaging.

Driver: San Francisco features two main types of artificial intelligence for traffic management: Civilian Traffic AI and Active Life AI. Civilian Traffic AI simulates the flow of traffic, providing realistic behavior for faceless vehicles. Each vehicle moves along a predetermined route, which is represented by a spline, creating the effect of continuous movement through the city. Active Life AI, in turn, is responsible for more dynamic interaction with the environment, adding elements of liveliness and unpredictability to the traffic situation. This combination of AI contributes to an engaging gameplay experience where players can enjoy a realistic simulation of urban traffic.
Each spline was designed to avoid intersections with other splines. This ensures road safety. Each civilian vehicle moves along its own spline, which guarantees the absence of the possibility of collisions with other vehicles. This approach significantly improves road safety and traffic management.
Chris Jenner and Sergio Okio Barriales are key developers of the popular video game Driver: San Francisco. Their contributions to the project were instrumental in creating a unique gaming experience that combines racing and open-world elements. Jenner and Barriales' work on the game's mechanics and level design has resulted in a gripping storyline and dynamic racing that attracts players worldwide. Thanks to the efforts of this talented team, Driver: San Francisco has become one of the most prominent representatives of the genre.
The Active Life AI system is responsible for vehicle control in pursuit and racing scenes. It calculates complex driving trajectories, taking into account not only the player's actions but also the environment and other vehicles controlled by the Civilian Traffic AI system. This allows for more realistic and dynamic scenarios where cars interact with each other and the game environment, significantly increasing the level of immersion and interest in the gameplay.

When the player changes vehicles, control of the abandoned vehicle is transferred to the Active Life AI. This ensures a smooth transition between different modes of transport and creates a more realistic gameplay experience.
If the player exits a police car that is pursuing a suspect, the artificial intelligence (AI) will automatically switch the police car's behavior to "pursuit of the target." In this case, the car will continue to perform the actions previously performed by the player. If the player was driving a civilian car without a specific target, after exiting, the AI will select the nearest free space on the city traffic route and attempt to merge the car into the flow. After this, control of the car will transfer from the Active Life AI to the simpler Civilian Traffic AI system.
Chris Jenner and Sergio Okio Barriales are the key developers of Driver: San Francisco. Their contributions to the creation of this project have become significant in the gaming industry. Driver: San Francisco offers unique gameplay that combines elements of racing and open-world games. Thanks to Jenner and Barriales' creative approach, the game has earned acclaim among players and critics. Their experience and professionalism allowed them to implement innovative ideas, making Driver: San Francisco one of the most memorable games of its time.

Cities: Skylines 2
In the city-building simulator Cities: Skylines 2, released in 2023, the developers focused on realistically simulating urban traffic. Cars in the game calculate their trajectories, taking into account the cars and pedestrians around them. Drivers are constantly making decisions about whether to accelerate, avoid oncoming traffic, or switch lanes. This advanced system creates a more vibrant and dynamic urban environment, allowing players to better manage traffic flows and plan infrastructure.
In the first part of the series, the route-finding system for cars was based on the direct distance to the destination, ignoring the peculiarities of the street and road network. This meant that a fire truck located on a nearby street could end up far from the scene of an incident. In practice, given all the roads and turns, it had to make a significant detour to reach the scene of a fire. This approach to routing is inefficient and can reduce the speed of response in emergency situations. Optimizing pathfinding systems to take into account real-world traffic conditions and infrastructure is key to improving the safety and efficiency of emergency services.

In Cities: Skylines 2, agents representing cars choose their routes based on travel costs. This cost is determined by many factors, including the structure of the city's road network, travel times, fares, and driver preferences. Agents can also adapt their routes based on events occurring on the road. For example, they might change lanes to avoid a car accident or steer around a stopped service vehicle. This creates a more realistic traffic simulation, where every detail influences route choice.
The Cities: Skylines 2 developer diaries are a valuable guide for players and fans of city-building simulators. In these diaries, the developers share details about the game's development process, reveal gameplay features, and discuss new mechanics. Each diary entry helps you understand how new features and improvements will impact city management, infrastructure construction, and interactions with citizens.
The developers emphasize the importance of community feedback, which allows them to implement relevant ideas and improvements. Cities: Skylines 2 promises to be deeper and more diverse than its predecessor, thanks to new customization options and a more realistic city simulation. Reading the developer diaries not only deepens your understanding of the game but also builds anticipation before release and inspires players to create unique cities.
Stay tuned for updates to stay up-to-date on all the new features and functionality Cities: Skylines 2 will offer its players.
Travel costs are calculated based on four main parameters: time, comfort, money, and behavior. Drivers primarily consider the time required for travel. If taking a long highway will get them to their destination faster than taking a shortcut, they'll choose the highway. Comfort includes optimizing the route with a minimum of unnecessary turns at intersections. It's also important to have available parking at the end of the trip. These factors play a key role in choosing a route and the final cost of the trip.

Money in the context of transportation includes fuel costs and parking fees. Driver behavior is determined by their willingness to make risky maneuvers on the road. For example, civilian cars and delivery vehicles typically avoid abrupt maneuvers like U-turns to minimize costs. In contrast, emergency vehicles, such as ambulances and fire trucks, may make such maneuvers to quickly reach their destination. This difference in behavior is due to their job responsibilities and the need to respond to urgent situations.
When choosing a route, the driver's age plays a significant role. Younger drivers are most often focused on the cost of travel—an economical option is important to them. Older drivers value travel time more highly and strive to reduce it. Retirees, on the other hand, place an emphasis on comfort and convenience. By taking these preferences into account, optimal routes can be offered for each age group, making travel more enjoyable and meeting drivers' needs.
When driving through the city, cars are distributed across all available lanes. On multi-lane roads, when one lane at an intersection is completely occupied, approaching vehicles choose the available lanes. This ensures uniform traffic flow, which promotes more efficient movement and reduces the likelihood of traffic jams. Proper distribution of vehicles across lanes plays a significant role in improving traffic conditions and increasing road safety.
At roundabouts, drivers are required to yield to vehicles already in the roundabout. However, in some situations, they may attempt to cut in front of moving vehicles, which can create dangerous situations on the road. Following traffic rules at roundabouts promotes safety and reduces the likelihood of accidents.

Road accidents in Cities: Skylines 2 are predetermined events. They occur when several factors combine on a specific section of road, such as poor lighting, adverse weather conditions, and poor road surface conditions. These elements create ideal conditions for accidents to occur, adding a touch of realism to the gameplay environment. Players should consider these aspects when designing and managing their cities to minimize the risk of accidents and improve road safety.
If a car encounters a section where all the necessary conditions are met, a randomly determined collision physics system is used to determine whether it will lose control. At this point, a rudimentary collision physics system is activated, and an invisible force pushes the car in a random direction. It's important to note that if this car collides with another vehicle, the physics system will also be activated for the second vehicle. This creates realistic dynamics of interactions between cars, which significantly increases the level of immersion in the gameplay or simulation.
Grand Theft Auto
The Grand Theft Auto series, known as GTA, has stood out from the outset for its high-quality traffic simulation. The developers created the game with an emphasis on taking place in a dynamic and living city, allowing players to enjoy destruction and creating chaos in a dense urban environment. This feature has become one of the key reasons for the series' popularity, providing players with a unique experience of interacting with the virtual world.
Cars move along the road and stop at red lights. Each car can be observed for a long time, which creates the impression that it will eventually reach its destination. This constant movement and stops at traffic lights create a dynamic atmosphere of city life, where each trip is part of a larger route.

You feel a sense of influence on the world when the system functions effectively, even in your absence. To achieve this, we needed to develop a working traffic light system that kept the city moving and regulated when cars stopped at traffic lights at the right times. In my opinion, it was naive to assume that drivers would obey the rules and stop at red lights to avoid police pursuit. In reality, many were eager to run red lights to avoid being caught, which certainly adds an element of excitement to the game.
Keith Hamilton is a programmer who made significant contributions to the first two installments of the popular Grand Theft Auto video game. His work on the development team helped create a unique gaming experience that later became the basis for a successful franchise. Thanks to Hamilton's innovation and technical skill, the games have received acclaim from both players and critics, which contributed to their commercial success and the continuation of the series.
It's a skillfully crafted illusion. In reality, traffic on the road appears beyond the screen's visibility. If you block the road with several abandoned cars and then move down the street a bit, the traffic jam will disappear from view, and you'll see new cars continuing to move away from the jam, giving the impression that the road is clear. However, if you return to your original location, the traffic jam will remain.
In GTA, cars don't disappear if you track them for too long; they continue to move in their selected lane. However, the artificial intelligence in the first game is unable to avoid obstacles. If you get in the path of a car, it will wait until you move away. If you collide with a car or push it onto the sidewalk, it will stay in place and, as soon as the road becomes clear, will return to its lane.

In Grand Theft Auto 3, released in 2001, one of the significant limitations hampering the simulation of city traffic was the limited memory on the PlayStation 2 console. Only eight vehicles could be displayed on-screen at a time. The developers implemented special code that gradually removed existing vehicles and loaded new ones, creating the illusion of a constant stream of different cars moving through the streets of Liberty City. This approach significantly improved the perception of the game world and added realism to the gameplay.

The code automatically selects cars that match the characteristics of the area. Sports cars can be seen in business districts, while older models predominate in less well-maintained areas. When the player moves to another part of the map, some loaded cars may look out of place and will not be available for use. The process of loading alternative models will take some time.
Obbe Vermeij is one of the key developers of the iconic game Grand Theft Auto 3. His contribution to the creation of this game had a significant influence on the development of the open-world genre. Grand Theft Auto 3 was one of the first games to offer players freedom of action in a vast virtual city, which changed the concept of gameplay mechanics. Vermeij, while working on the project, applied innovative approaches to design and programming, which contributed to the creation of a unique gaming experience. The success of Grand Theft Auto 3 opened new horizons for the entire gaming industry and cemented its status as a legend.
In some cases, the game dedicates some of the eight vehicle memory slots to specialized vehicles, such as ambulances and fire trucks that appear at accident scenes. It also dedicates story vehicles, which are only available in certain missions, as well as police cars, SWAT vans, and even helicopters if the player commits an offense and increases their wanted level. As a result, only one or two slots remain available for simulating city traffic.

The game requires saving information about the last used vehicle in order to The player could leave the car, take a walk, and then return to it to continue the journey. To optimize memory usage, cars left by the player in the garage are deleted immediately after closing the door. When the door is reopened, the vehicle is recreated, which avoids system overload and ensures smooth gameplay.
Traffic in the games Vice City and San Andreas functioned on a similar principle. However, in Vice City, players could observe an interesting feature: when they were being pursued by the police, police cars would drive out from adjacent streets at certain intersections, blocking the character's path. This created an atmosphere of tension and realism, adding dynamism to the gameplay. Such moments heightened the feeling of being chased and made the game more exciting.
In Vice City, police cars appear in pre-set locations, which creates a sense of surprise for the player. Unlike the traditional approach, where they are summoned from afar upon command, here cars appear at the right speed and at the right moment, which adds dynamism to the gameplay. Despite the complexity of setting up such triggers, the game only features about five such locations. To activate this mechanism, the player must raise their wanted level to three stars. After police cars appear, it's important to wait a few minutes before they can drive out again, making the game more strategic and engaging.
Obbe Vermeij is a key developer on Grand Theft Auto 3. His contributions to this iconic video game, released in 2001, significantly influenced the development of the action-adventure and open-world genres. Vermeij was responsible for important aspects of development, including game mechanics and level design, which contributed to the creation of a unique gaming experience. Grand Theft Auto 3 became a cult classic, laying the foundation for subsequent installments in the series and inspiring numerous other games. Obbe Vermeij's contribution to this game remains significant today, when discussing innovations in game design and the development of open worlds.

The developers haven't revealed any details about how the city traffic AI works in GTA 4 and GTA 5, but players have uncovered several interesting aspects. One such detail is that civilian vehicles sometimes intentionally deviate from their routes to cross the player's path and cause accidents. This feature has sparked active discussion on Reddit. Players noted that such situations add realism and dynamism to the gameplay, creating unexpected and exciting moments.

In the fifth part of the game, the behavior of cars has changed dramatically. If in the fourth part, cars swerved towards the player, creating the illusion of randomness and allowing you to avoid collisions thanks to their speed, then in the fifth game, on the contrary, they deliberately throw themselves under the wheels. This change makes the gameplay more tense and unpredictable, adding new layers of difficulty and requiring greater concentration and reflexes from the player.
According to one of the modders who studied this problem, Rockstar used a similar script for civilian cars, which is used in police cars during pursuit of the player. This script allows civilian cars, approaching the protagonist, to copy his movements. This discovery raises questions about the capabilities of artificial intelligence in games and how developers use the same mechanics to create more realistic gameplay.
This script can unexpectedly take control of a civilian car, causing it to sharply move towards the player. As a result, such a vehicle gains the ability to ram any object, cutting through traffic as if it were a tank. The purpose of this is unclear. Perhaps this was done to prevent drivers from behaving too perfectly on the road and to add an element of unpredictability to the gaming environment.

In GTA 5, the city traffic simulation has its shortcomings. For example, if a deer runs into the road, the driver of a car will stop and honk the horn to get the animal to move away. However, after that, the driver will continue driving without any specific goal, which creates the impression of continuous, but aimless movement. This reduces the level of realism of the game world and affects the overall experience of the game.
The vivid feeling of a real city is disrupted by an ambulance rushing past with its siren blaring. It seems to be rushing to the aid of someone in need. However, if you try to follow it, you will notice that it rushes through the streets, turning in different directions at intersections. After some time, about fifteen minutes, the AI simply turns off the siren, leaving a feeling of uncertainty. This creates the illusion of dynamic urban life, where each ambulance symbolizes not only an emergency but also the constant movement and change in the urban environment.
Cars in game cities act as actors, controlled by artificial intelligence, which acts as a director. This effective approach to creating a game world was mastered over 20 years ago. Future progress in this field depends on improvements in AI technology. In the future, the focus of car journeys will be on achieving the final destination, not the driving process itself. Improving AI algorithms and capabilities will allow for the creation of more realistic and engaging scenarios, significantly enhancing the quality of player interaction with the gaming environment.

Reading is an important part of our lives. It not only develops mental abilities but also enriches our inner world. Books broaden horizons, introducing us to new ideas and cultures. Regular reading improves analytical and critical thinking skills and contributes to a better vocabulary. In today's world, where information is available in vast quantities, the ability to read and understand text is especially important. Immersing yourself in literature not only helps you relax but also increases your overall awareness. Choose a variety of genres and authors to make reading more engaging and rewarding.
Flocks and Crowds in Games: Programming Realistic Flock Behavior
Creating realistic flock or crowd behavior in video games is an important aspect of game design. Effective programming of such systems allows players to immerse themselves in the game atmosphere, creating the feeling of a living world. To achieve this effect, developers use various algorithms and behavior models that simulate interactions between individual characters.
One of the most common methods is the use of a "fight, flight, and approach" algorithm, which controls the actions of NPCs (non-player characters) based on the environment and the behavior of other group members. This allows for the creation of dynamic and unpredictable situations in the game.
It is also important to consider parameters such as crowd density and the distance between characters. These factors influence how NPCs react to the player and to each other. Complex systems based on flock behavior can include mechanisms that take into account not only individual actions but also the overall mood of the group.
Furthermore, the use of artificial intelligence to manage crowd behavior allows for the creation of more realistic scenarios. Developers can implement systems that take into account characters' emotions and motivations, making interactions with them more natural and engaging.
Thus, programming realistic flocking behavior in games is a complex task that requires deep knowledge of computer science and psychology. This not only improves the gaming experience but also significantly increases player engagement in the virtual world.
Game designer profession from scratch to PRO
A game designer creates the structure of a game. He thinks through the idea, rules, gameplay and decides what emotions the plot will evoke in players. You'll master game design principles from scratch and learn how to work with popular engines like Unity and Unreal Engine. You'll learn how to retain player interest and monetize games. And we'll help you start a career in the gaming industry.
Learn more
