GameDev

How to program flock and crowd behavior in games — the boids algorithm and other approaches

How to program flock and crowd behavior in games — the boids algorithm and other approaches

Learn: Unity Game Developer Profession from Scratch

Learn More

When creating large-scale clusters of creatures or NPCs in video games, developers face the problem of performance. It is impossible to simply program the behavior logic of one character and then fill the location with its clones, as this will lead to significant delays in the game due to the high load on computing resources. To avoid this, developers use various optimization techniques that preserve the naturalness of the gameplay while minimizing computing costs. In this context, it is important to consider the methods used to achieve a balance between graphic quality and performance.

The Origins of Flock Simulation

Tim Burton's Batman Returns features a striking scene in which a flock of bats attacks the citizens of Gotham City, as well as a scene with marching penguins. These elements were created using computer graphics, and the realistic behavior of the animals was achieved using an algorithm developed by computer graphics specialist Craig Reynolds, also known for his work on the film Tron. This algorithm, called Boids, allows for the simulation of flocks of animals, creating the effect of natural behavior in a variety of environments. The use of Boids in the film industry demonstrates how modern technology can significantly improve visual effects and make them more believable.

Craig Reynolds was not the first to try to simulate the behavior of animal groups. Nevertheless, his Boids algorithm has become a fundamental tool for game developers creating flocking simulations. This algorithm effectively simulates interaction and coordination in groups of creatures, making it indispensable for designing realistic game ecosystems. Boids remains relevant in modern game development, inspiring new developers to create impressive visuals and complex game mechanics.

In 1986, I developed a computer model that simulates the coordinated movement of animals, such as flocks of birds and schools of fish. This model was based on 3D computational geometry used in computer animation and computer-aided design. I called these virtual creatures "boids" (from "bird-oid", meaning "bird-like"). The basic model of flock movement includes three simple rules that describe how each boid maneuvers based on the position and velocity of nearby members of its flock. This model was an important step in the study of collective behavior and has found applications in various fields, including robotics and the simulation of natural phenomena.

Craig Reynolds is a prominent scientist and programmer known for developing the Boids algorithm. This algorithm models the behavior of a flock of birds and is a major advancement in computer graphics and simulation. Reynolds' work on Boids opened new horizons for the study of collective animal behavior and has become the basis for many projects in animation and video games. The Boids algorithm uses simple rules for interactions between individual objects, allowing for the creation of complex and realistic models of flock behavior. Craig Reynolds's contributions to this field of science continue to inspire researchers and developers around the world.

At the time, Craig Reynolds worked for Symbolics Graphics Division, which developed graphics software used in the film industry for creating films.

The company's software was used in films such as Star Trek III: The Search for Spock and Free Willy. In 1987, Symbolics Graphics Division released a three-minute cartoon, "Stanley and Stella in: Breaking the Ice," which first demonstrated the Boids algorithm. The cartoon's plot is simple and captivating: a cosmic sphere, divided into two parts by ice, contains water with schools of fish below, and air with flocks of birds above. One day, a bird named Stanley falls in love with a fish named Stella and decides to break the ice with his beak, connecting the two worlds. This event allows fish and birds to enjoy freedom together in a single space.

Frame: animated film Stanley and Stella in: Breaking the Ice / Whitney / Demos Productions

In the cartoon, flocks of birds and schools of fish exhibit behavior similar to how these living organisms behave in nature. This project was presented at the SIGGRAPH'87 conference dedicated to computer graphics. During the event, Craig Reynolds gave a talk in which he explained in detail how he was able to faithfully reproduce the complex behavior patterns that evolution has shaped over millions of years using computer algorithms.

Each boid in the group adheres to three main rules. These rules help create natural behavior and interactions between the boid and its environment. The first rule is separation. Boids strive to avoid proximity to other boids to prevent collisions. The second rule is alignment. Boids try to coordinate their directions of movement with their neighbors to maintain the overall flow of the group. The third rule is attraction. Boids strive to move toward the center of the group, which contributes to the creation of a cohesive and organized movement. These simple principles enable the complex and realistic behavior patterns observed in nature. Separation is an important aspect of boid behavior, as they must avoid collisions with other members of their flock. This helps maintain the safety and integrity of the group. Each boid uses information about the location and velocity of its neighbors to maintain an optimal distance, preventing potential accidents. Effective separation management promotes more natural flock movement and improves the overall dynamics of interaction between the boid and the environment. Alignment is the process by which an agent, called a boid, changes its direction of movement to match the direction of its nearest neighbors. This behavior allows for the creation of natural and realistic groups of objects, such as flocks of birds or schools of fish, where each individual strives to follow the others, maintaining a common vector of movement. By adjusting their direction, boids ensure harmonious interaction and synchronization within the group, which is a key aspect of simulating collective behavior in computer graphics and animation.

This alignment phenomenon is an important element in modeling complex systems, where interactions between elements lead to interesting and unpredictable results, making it relevant for applications in various fields such as robotics, biomechanics, and artificial intelligence.

Cohesion in boid behavior implies that each boid should occupy a position that is average between the positions of its nearest neighbors. This means that boids should remain close to their peers, which promotes group formation and improves intra-flock interactions. Cohesion is an important aspect of movement dynamics, allowing boidoms to effectively coordinate their actions and avoid disunity.

Separation. Data source: Craig Reynolds' official website. Infographics: Maya Malgina for Skillbox Media.
Alignment. Data source: Craig Reynolds' official website Infographics: Maya Malgina for Skillbox Media
Cohesion. Data source: Craig Reynolds' official website Infographic: Maya Malgina for Skillbox Media

Each boid in a flock is an independent unit, capable of moving independently. However, when another boid comes into its field of view, it begins to adapt its behavior, following three basic rules. This means that a boid will turn in the direction in which its neighbor is moving, maintaining a small distance to avoid collisions, but at the same time trying to stay close. Thus, the interaction of boids creates a dynamic and cohesive group, which is a key element in modeling flock behavior.

If several more boids join the original boid, it will begin to make calculations taking into account the new comrades. However, if another hundred more are added, the original boid will continue to consider only the closest fellows. It will not focus on the behavior of the entire group of one hundred boids, but only on those who are nearby. This principle also applies in real life: when you leave a crowded subway car, you don't pay attention to the direction of movement of all the passengers, but focus only on those who are close to you. This approach allows for more efficient interaction and less information overload.

Using the Boids algorithm, you can create groups of bats like these (the cluster at the top). Note: the tree split one flock into two smaller ones. Screenshot: Vampire Survivors game / Luca Galante.

Two key parameters are important for effective interaction between a boid and its neighbors. The first parameter is the search radius, within which the boid identifies nearby opponents. The second parameter is the field of view, which allows the boid to monitor not all of its neighbors, but only those in front of it. If a group of boids encounters an obstacle and splits up, a large search radius helps them quickly reunite. Conversely, a small radius can lead to the disintegration of a large flock into several smaller groups. Furthermore, a wide radius helps prevent situations where boids lose contact with the group, not noticing the comrade through whom they joined. These parameters play an important role in maintaining the integrity of the flock and ensuring its stability in various conditions.

Data source: David M. Bourg, Glenn Seemann. AI for Game Developers. Infographic: Maya Malgina for Skillbox Media.

If you set a narrow field of view, Boids will focus only on the neighbor in front of them. As a result, the flock will form a snake-like shape and disintegrate at the first sharp turn, as the leading Boid will move out of the line of sight of its followers. In contrast, a wide field of view promotes the formation of a cohesive flock, where group members stay firmly together. This helps maintain unity and consistency in the flock's actions under any conditions.

Data source: David M. Bourg, Glenn Seemann. AI for Game Developers. Infographics: Maya Malgina for Skillbox Media.

The search radius and viewing angle of boids can be individually configured for each of the three rules: Separation, Alignment, and Cohesion. This allows for the creation of a variety of behavioral models. As an example, we used a completed Unity project by blogger SuboptimalEng, which is built on the Boids algorithm. While working with the program, we constantly adjusted the radius for each of the rules, which caused immediate changes in the boids' behavior. They would fly chaotically, ignoring each other, then gather in small groups, then line up in long chains, or fly off in different directions, losing contact again. Such experiments with parameters allow for a deeper understanding of the dynamics of boid interactions and create unique visual effects.

The Boids algorithm offers endless possibilities for modification, and everything depends on the needs of the developer and their creative approach. It can be used to create simulations of animal behavior, displaying their interactions at remote distances, or to implement troop movement systems in real-time strategy games. It is important to consider whether the algorithm will be applied in 2D or 3D space. Swarms can simply move around a given area or perform additional functions, such as attacking the player. The applications of the Boids algorithm are diverse and open up new horizons for the development of interesting and dynamic game mechanics.

The complex behavior of large swarms is formed on the basis of three simple rules that all its members adhere to. Now let's look at how similar principles have been applied by developers of various video games.

Half-Life

The algorithm developed by Craig Reynolds can be seen in the original 1998 Half-Life game. In the final scene, the G-Man tells Gordon Freeman about new career opportunities. The scene takes place in the world of Xen, where a flock of bird-like creatures flies behind the G-Man. These creatures use the Boids algorithm, which creates the effect of natural flock behavior. Interestingly, in the game's file structure, the models of these birds were called Boid, which emphasizes the importance of this algorithm in creating a dynamic game world.

A flock of alien birds behind G-Man, seen only in this scene. Image: Half-Life game / Valve / MarphitimusBlackimus

YouTube channel author MarphitimusBlackimus conducted an in-depth analysis of the behavior of virtual birds in the game. Their realistic interaction became one of the key technological features introduced in the early version of Half-Life Alpha. When activated, the birds chose a leader and followed them, emphasizing the level of development of the game world and artificial intelligence. This added depth to the gameplay and immersed players in an atmosphere of realistic interaction with the environment.

A flock of alien birds moved around the location without following a predetermined route and confidently avoiding obstacles. Their behavior was especially convincing because the speed of their wingbeats depended on the flock's acceleration and maneuvers during turns. This created an impressive harmony and coherence in their movements, emphasizing the unique adaptive abilities of these creatures.

Screenshot: Half-Life game / Valve / MarphitimusBlackimus

When the leader bird dies, the flock chooses a new leader and begins to follow him. At the moment of loss, any of the birds begins to make loud angry calls, indicating a deep emotional response to the loss. This behavior emphasizes the importance of social structure in the life of the flock and their ability to adapt to change.

In Half-Life, these creatures appear only once, when the player cannot interact with them. They serve a purely decorative function. However, thanks to free movement, rather than predetermined routes, each player who completes the game observes their own unique version of the birds' flight after the G-Man. This element creates a sense of a living world and makes the gaming experience more memorable.

Assassin's Creed Unity

The developers of Assassin's Creed Unity did an impressive job of creating street crowd behavior. The game can display up to 120 NPCs at a time, each with detailed models and animations. Of these, only 40 have sophisticated artificial intelligence. However, in certain scenes, players can see up to 10,000 NPCs, which from a distance appear to possess sophisticated AI and high-quality graphics. This creates the effect of a living city and significantly enriches the gameplay, demonstrating achievements in technology and design.

Screenshot: Assassin's Creed Unity / Ubisoft Montreal

The first game in the series had a limit of 100 NPCs. This number included all the residents the player might see on the streets, including guards and key gameplay characters. A maximum of 20 ordinary citizens, serving purely decorative purposes, could be placed. To avoid a feeling of emptiness on the streets, the developers distributed these NPCs throughout the level. Ultimately, the main character had no more than four active NPCs. Full streets with a large number of characters are found only in certain missions, where the developers were able to focus their resources on creating a richer atmosphere.

Screenshot: Assassin's Creed Unity game / Ubisoft Montreal
Screenshot: Assassin's Creed Unity / Ubisoft Montreal

Assassin's Creed Unity has refined its use of simplified models, improving game graphics and interaction with the surrounding world during the events of the French Revolution. The developers implemented the Bulk system, the name of which comes from the English word meaning "volume" or "mass." In this system, each individual NPC is called a Bulk, similar to how each creature in a flock is called a Boid in Craig Reynolds' Boids algorithm. This innovation allowed for the creation of a more realistic and dynamic population of the game world, significantly enriching the user experience.

At the beginning of the game, the crowds on the streets are represented by simplified models of citizens. However, as the hero approaches them, the game gradually replaces these simple characters with more complex and detailed models. This creates a sense of dynamism and realism in the urban environment, allowing the player to become more immersed in the atmosphere of the game world. This approach enhances interaction with the environment and makes every moment more intense and engaging.

A simplified model of a townswoman with animation that doesn't even allow her to realistically hold a chair. Frame: GDC / YouTube

If the distance to the NPC exceeds 40 meters, the player sees a character with a simplified model consisting of 2,000 polygons and 11 bones for animation. At distances between 40 and 12 meters, the player sees an NPC with a full model, but with a limited behavior system and simple animations, as well as basic collision checking. When the distance to the NPC is less than 12 meters, the character is replaced with a highly detailed model containing 20,000 polygons and 300 bones for animation. Such an NPC has artificial intelligence, which allows it to adequately respond to the player's actions, which significantly improves the gameplay and makes interaction with the world more realistic.

Screenshot: Assassin's Creed Unity game / Ubisoft Montreal

A unique system for calculating NPC crowd collisions was developed for the game, as using hitboxes for thousands of characters in the city would have been too resource-intensive. This system allows us to efficiently handle interactions between NPCs and the environment, ensuring realistic and smooth gameplay.

We have a map displaying the location of each NPC in the game world. For each character, we determine whether they are within range of another NPC. If so, the character plays a simple animation and moves to the side. This is not a physical collision, but a visual effect. To prevent NPCs from clipping through buildings and other obstacles, we use a navigation mesh.

François Cournoyer is a talented programmer who worked on the popular Assassin's Creed series. His experience and skills have significantly influenced the creation of unique gameplay and the implementation of innovative technologies in this franchise. While working on Assassin's Creed, Cournoyer helped create a rich and detailed world that attracts players from all over the world. His contributions to the project not only improved the quality of games, but also helped shape an entire generation of action and adventure video games.

Image: GDC / YouTube

Artificial intelligence controls animation and Character behavior is controlled through special objects called "shepherds." These invisible elements create and control crowds around them. The developers used "shepherds," rather than regular citizens, to effectively regulate the size, density, and behavior of crowds on the streets. For example, NPCs might simply stroll or participate in protests, depending on the settings the developers set. This allows for a more realistic and dynamic gaming environment.

Each circle represents a crowd controlled by one "shepherd" Frame: GDC / YouTube

The game features "Wandering Shepherds" control the behavior of NPCs moving through the streets. NPCs follow predetermined routes and move in circles. If you follow one of the pedestrians, you'll return to your starting point after a while. Additionally, the "wandering shepherd" provides a variety of characters specific to each district of Paris, adding depth and realism to the game.

This is what the looped routes for NPCs on the streets of Paris look like. Frame: GDC / YouTube

A Plague Tale: Innocence

The main feature of A Plague Tale: Innocence is the numerous rats that play a key role in the plot. The developers from Asobo Studio used this element to demonstrate the horrors of the plague in France during the Hundred Years' War. These rats not only create an atmosphere of fear, but also serve as a metaphor for the devastating effects of epidemics affecting people's lives at that time.

We aimed to create a fascinating story about the Black Death. Since confronting the virus in gameplay proved to be a difficult task, we chose a well-known symbol of the plague - rats, which spread the disease throughout the world. We were inspired by this concept, but its implementation required many rats - thousands - to create a believable atmosphere. While this sounded great in theory, it presented significant technical challenges, as it involved thousands of rats displayed on a single screen.

Kevin Shoto is the game director on A Plague Tale: Innocence. Under his leadership, the project captured the attention of players with its unique storytelling and atmospheric gameplay. Shoto is actively involved in the development and implementation of ideas that make the world of A Plague Tale: Innocence alive and memorable. His experience and creative approach contribute to creating an immersive and emotional experience for players. The game stands out from other projects thanks to its strong characters and deep themes, making it important in the modern gaming landscape.

During the game's development, the team used documentary footage of mice and rat infestations on Australian farms, which can be found on YouTube. When comparing the rats' movements in the game with those in real-life footage, it becomes apparent that the in-game characters are less agile. This was done intentionally to allow players to escape from the rodents, which adds an element of strategy and tension to the gameplay.

Screenshot: A Plague Tale: Innocence / Asobo Studio

Early in development, the studio decided to have up to 5,000 rats onscreen at any one time. In the sequel, A Plague Tale: Requiem, this number increased to around 300,000. Each rat in the game has unique behavior: one chases the player, another attacks guards, some try to hide from bright lights, and some simply wander in search of food. This approach to creating a living world makes the game more engaging and realistic, immersing the player in the atmosphere of a brutal struggle for survival.

To optimize behavior, several rats can share behavior patterns, but overall, each rat retains its individuality. When isolated, one rat displays typical behavior. If you look at a group of ten rats, you will notice that each one exhibits unique traits that differ from one another. This underscores the importance of considering individual differences when studying animal behavior.

Kevin Shoteau, Game Director of A Plague Tale: Innocence, is a key figure in the development of this unique project. His vision and creativity helped create a captivating atmosphere of medieval Europe, permeated with drama and tension. Under Shoteau's leadership, the development team was able to realize a rich story, saturated with emotion and intriguing twists. Thanks to his experience and leadership, A Plague Tale: Innocence has become one of the most memorable games of its genre, receiving high praise from both critics and players. Kevin Shoteau's work confirms that high-quality gameplay and a deep story can harmoniously combine to create an unforgettable experience for users.

We started with a small group of 10-20 rats to convincingly demonstrate their behavior in the game. Then the idea arose to increase their number hundreds of times. However, processing the behavior of even a single rat requires significant resources, so simply increasing their number to thousands proved ineffective. The solution to this problem was the optimal use of technologies and algorithms to reduce the system load and more efficiently simulate the behavior of many rats simultaneously.

Successful implementation of the project required careful planning and significant optimization efforts. The developers immediately realized that they would not be able to implement their plans using graphical techniques such as particle generators or animated textures, which are often used in sports simulators to create the effect of spectators in the stands. This understanding became the starting point for searching for more effective solutions that ensure high visual quality and performance.

We started with a concept reminiscent of a water simulation, but it turned out to be ineffective. The rats were perceived as particles rather than living beings.

Kevin Shoteau, Game Director of A Plague Tale: Innocence, is a key figure in the development of this unique project. His experience and vision helped create an immersive gameplay experience that combines elements of adventure and psychological thriller. A Plague Tale: Innocence immerses players in the grim world of medieval France, where they face the dangers of plague and the Inquisition. Shoto focused on creating deep characters and a compelling story, making the game not only entertaining but also emotionally charged. Under Kevin's direction, innovative mechanics were introduced that enhance the atmosphere and player engagement. A Plague Tale: Innocence has received high praise from critics and won numerous awards, which confirms the success of the team led by Shoto.

Screenshot: A Plague Tale: Innocence / Asobo Studio

Creating the behavior of the rats that pursue and attack both the protagonist and NPCs presented a significant challenge. The developers couldn't simply let each rat independently calculate a route to the player character, as this would have overloaded the processor. With 5,000 rats, such calculations would have become impossible. Therefore, optimized algorithms and systems were needed to effectively manage the behavior of these creatures, ensuring realistic interactions without significantly consuming resources.

The team chose an unconventional approach to development. Instead of the rats themselves finding paths to the goal, it is the goal that determines the routes the rats can take to get there. The game creates a kind of conveyor belt leading from any point in the level to the player character, and the rats simply follow the created routes, joining the nearest one. As the target moves through space, the routes for the rats are recalculated. This mechanic is known as flow field pathfinding and allows for more dynamic and effective interaction between characters and the game world.

Flow field pathfinding in C++ performed by Funneractic Frame: Funneractic / YouTube

How this process works

The process of this method is based on a clear interaction of various components. First, data is collected, which provides the necessary information for further analysis. Then, the data is processed using algorithms, which helps identify key patterns and trends. The next step is visualization of the results, making the information more accessible and understandable for users.

This approach provides an effective solution to problems associated with processing large volumes of data and enables informed decision-making based on analytics. Importantly, regular data updates ensure that the results obtained are relevant, which is critical for the successful functioning of the system. Thus, the entire process works synergistically, ensuring high accuracy and reliability.

In each location with rats, the game forms an invisible grid of squares on the floor. Each square contains data on the direction in which a rat that lands on it should move. This mechanic allows you to control the behavior of rats, creating a unique gameplay experience and increasing the player's interest in exploring the environment.

Cages located in or near illuminated areas cause rats to retreat. A similar repulsive effect is exerted by cells located near permanent obstacles, such as walls and columns. This allows rats to avoid collisions with these objects and prevents texture breaks. This behavior improves the perception of room geometry.

When the position of the player, NPC, or light source on the grid changes, the system recalculates the direction for each cell. This method allows for efficient direction setting for multiple objects simultaneously, significantly saving computer resources. This approach optimizes game performance and ensures smoother gameplay.

This is what the grid on the floor looks like, each square of which sets the direction for the rats to reach the goal. Screenshot: A Plague Tale: Innocence game / Asobo Studio / AI and Games

To prevent a situation where 5,000 rats simultaneously attack a single target, such as a guard or a player, the developers set a certain number of rats required to carry out an attack. For example, if a guard is attacked by a sufficient number of rats, the rest will not join the attack as a second or third layer. This allows for a more realistic and manageable game environment, where the number of attackers is controlled, which improves gameplay and interaction with NPCs.

Initially, guards, upon noticing rats, managed to run away, which made using rodents against them useless. However, the developers found a solution to this problem. Now, when rats attack, guards have an increased time to turn around. As a result, they do not have time to turn around and leave, making the rat tactic effective in the game.

The development team took into account the possibility that the player can use a torch to drive a crowd of rats into a corner. If the rodents find themselves without an escape route, they disappear, leaving behind only sparks. This trick serves as a deception mechanism for players attempting to catch the rats by chasing them around the level with a torch. This approach adds a strategic element to the game and emphasizes the importance of tactical thinking when interacting with the game environment.

Screenshot: A Plague Tale: Innocence / Asobo Studio

Some rats, when at the edge of an illuminated area, suddenly rush into the light and then quickly retreat. This effect blurs the line between danger and safety for the player. Although such single attacks do not cause damage, they serve as an important visual device, creating an atmosphere of tension and uncertainty.

When a rat notices the protagonist, it rises on its hind legs and turns its head in their direction. This gesture indicates that information about your presence is beginning to spread throughout the horde, creating a wave of wariness. Thus, the rat's behavior serves as an indicator of the group's reaction to the appearance of a person, emphasizing the importance of careful observation of the environment.

We aimed to create characters that are aggressive and imposing, evoking a feeling of fear and threat in players. Our goal was to convey to players the idea that stepping beyond the protection of light will lead to deadly consequences.

Kevin Shoto is the game director on A Plague Tale: Innocence. He played a key role in the development of this project, which has won acclaim from critics and players alike for its gripping storyline and unique gameplay. Under Shoto's leadership, the team was able to create an atmospheric world reflecting the horrors of medieval Europe while simultaneously conveying a deep connection between the main characters. His vision and creativity helped A Plague Tale: Innocence become one of the most memorable games of its time, as evidenced by numerous awards and positive reviews.

The game has an interesting feature that players often overlook. To optimize performance, only the 400 rats closest to the player have unique animations and behavioral modeling. Each of these rats is detailed, including elements such as a tail that moves with the body. This optimization allows the game to maintain high performance while minimizing system load, despite the large number of objects on-screen. The distant rats have a generic animation and lack tails. The developers describe the furthest rats as "just potatoes," as they lack animation and are presented only with a simplified model. The game effectively combines all three rat types, creating the impression of a creepy, homogeneous mass. This enhances the game's atmosphere and adds a touch of horror to the visual experience.

Detailed rats marching in the forefront. Screenshot: A Plague Tale: Innocence / Asobo Studio
Potato rats far from the character Screenshot: game A Plague Tale: Innocence / Asobo Studio

Hitman:

In Hitman: Blood Money, during the level "The Murder of Crows," players can observe a dense crowd of pedestrians on the streets of New Orleans during a parade. However, it's worth noting that this crowd is primarily decorative. For example, 47 can't hide from pursuers among the crowd, nor can he stealthily eliminate people from this crowd or use them as human shields. If 47 starts shooting, the pedestrians initially react with a synchronized movement, dispersing and protecting their heads with their hands. However, after a few seconds, they return to their activities as if nothing happened. This demonstrates a feature of game mechanics, where environmental elements do not always interact with the player's actions.

Screenshot: Hitman: Blood Money / IO Interactive

In the game Hitman: Absolution features significant improvements to crowd behavior. Players can use pedestrians as human shields, adding a new layer of strategy to the game. Remaining motionless in a crowd will prevent enemies from noticing you. However, as soon as a gunfight or explosion occurs, NPCs will react more realistically: they will panic and rush for the nearest exit. These changes make gameplay more engaging and tense, adding elements of surprise and dynamism to every mission.

In Hitman: Absolution, a crowd can contain up to 1,200 NPCs, with up to 500 visible on-screen at a time. All NPCs navigate through the game's environments using a navigation grid, reminiscent of the mechanics in A Plague Tale: Innocence. The floor on which NPCs move is covered by a grid, with each square containing information necessary for their movement, including whether the square can be occupied and who is already occupying it. This approach ensures realistic interaction with the environment and creates a dynamic gaming atmosphere.

Screenshot: Hitman: Absolution / IO Interactive

Some cells mark exit zones from the location, others serve to create NPC movement routes, others indicate dangerous zones that should be avoided, and others indicate areas that become forbidden if the protagonist begins to cause panic in the crowd. This allows the shooter 47 to remain out of reach of others.

Image: GDC Vault

The behavior of each NPC in the crowd is controlled by a state machine. Depending on the situation and environment, artificial intelligence selects one of several states, such as standing, waiting, moving, alert, afraid, or even dying. This system allows for more realistic interactions between NPCs and the surrounding world, significantly improving gameplay and player immersion. Developing such mechanisms requires carefully crafted behavioral scenarios to ensure varied and natural NPC responses to various stimuli.

In the "wait" state, a pedestrian assesses the surrounding space for obstacles, such as walls and other pedestrians, and waits for the path in one direction to become clear. Once this occurs, it switches to the "go" state. While in this state, the NPC navigates the surrounding area using the wander steering behavior algorithm developed by Craig Reynolds. This approach allows for more natural and realistic pedestrian behavior in a virtual environment, improving user interaction and the overall perception of the game world.

Screenshot: Hitman: Absolution / IO Interactive

The algorithm ensures more natural character movement without restricting them to strict routes. This creates the feeling that NPCs are truly moving freely around the game environment, significantly increasing immersion. The realistic behavior of NPCs makes gameplay more engaging and dynamic.

Each frame of character animation includes small, random deviations from the character's movement vector. These deviations are minimal to avoid abrupt changes in direction. If a character moves up and to the right, in the next frame, their movement maintains the general vector but occurs with a slight change in angle. This creates a more natural and smooth movement, which improves the perception of the animation.

Random deviations to the character's direction are created on an invisible circle in front of the character. Each frame, the deviations change by the amount of random offset represented by a small circle. Data source: "Steering Behaviors For Autonomous Characters" by Craig W. Reynolds / Craig Reynolds' official website. Infographic: Maya Malgina for Skillbox Media.

In a panic situation, NPCs (characters not controlled by the player) automatically determine the shortest route to the exit of the game location. This path is formed based on a grid of cells that represent exits. If at a certain point other NPCs block the path, the character fleeing from danger switches to an alternative route leading to the nearest exit cell. It is important to note that a level can have multiple exit cells and pre-calculated routes to them. This is achieved using a modified Dijkstra algorithm, which allows for the efficient finding of the shortest paths between multiple connected points. This approach ensures realistic behavior of NPCs in emergency situations, improving gameplay and interaction between characters.

Screenshot: Hitman: Absolution / IO Interactive

Left 4 Dead

The hordes of undead that stalk players in Left 4 Dead have their roots in the bots from Counter-Strike: Source. Programmer Mike Booth explained that while testing Counter-Strike: Source, the team noticed that fighting 30 bots armed only with knives was incredibly engaging. As a result, when Counter-Strike: Source was released, Valve began actively developing this idea. However, for a new game about the zombie apocalypse, it was necessary to significantly change the behavior of bots to match the atmosphere and mechanics of Left 4 Dead.

Screenshot: Left 4 Dead game / Valve

The "Infected Horde" is the central element of Left 4 Dead. We invested significant effort in creating believable enemy movements. This includes hundreds of motion-capture animations that are algorithmically combined with physics systems. The result is characters that interact realistically with both the environment and each other.

Phil Robb, co-founder of Turtle Rock Studios, also known as Valve South, played a key role in the creation of Left 4 Dead. The game became a cult classic in the co-op zombie shooter genre and had a significant influence on the development of multiplayer games. Turtle Rock Studios continues to expand its horizons in the gaming industry, creating projects that inspire players around the world.

The behavior of the Infected Horde varies depending on the active mode. By default, they are in "wander" mode, where zombies slowly move around the area, coughing and making other sounds. Some of them may be fighting among themselves, while others are simply leaning against walls, sitting, or lying on the ground. When heroes appear, the zombies enter "alert" mode. In this state, they begin to carefully scan the surroundings for the source of trouble. If the infected notice the player, they become their target. The zombies rush towards them at maximum speed, overcoming any obstacles, including jumping and climbing. This makes interactions with the horde especially tense and unpredictable, emphasizing the atmosphere of fear and danger in the game.

Screenshot: Left 4 Dead / Valve

All levels in Left 4 Dead have a linear structure, but each of them is replete with rooms and nooks and crannies. These nooks and crannies serve as zombie spawn points, allowing them to attack players unexpectedly. In these hidden areas, the developers have provided randomly generated health kits, grenades, weapons, and Molotov cocktails, encouraging players to explore. Exploring the environment not only adds an element of surprise to the gameplay but also provides players with useful resources, making each game unique and engaging.

While the idea of ​​advanced zombie AI may seem strange, we devoted considerable attention to developing the AI ​​systems for horde generation. A key focus was their ability to navigate spatially. The locations in Left 4 Dead have complex geometry and are filled with destructible and movable objects. One of the key objectives was to ensure that there were no places where players could hide from the zombies. This required not only robust pathfinding algorithms but also sophisticated mechanisms for allowing zombies to follow these routes. Zombies moving along a given path must constantly evaluate the surrounding geometry and make decisions about when to crouch, stand, jump, or avoid obstacles in the environment. This approach creates a more realistic and immersive gameplay experience, where zombies can effectively pursue players, increasing tension and interest in the game.

Matt Campbell is a renowned video game developer who played a key role in the creation of the popular game Left 4 Dead. His contributions to the development of this cooperative shooter were significant, and he became one of the key figures responsible for the gameplay mechanics and interactions between players. Published by Valve, Left 4 Dead quickly gained popularity thanks to its unique gameplay experience and innovative approach to the zombie apocalypse genre. The work of Matt Campbell and his team helped define the standards for multiplayer games and continues to influence the industry.

Screenshot: Left 4 Dead / Valve

Under development The team encountered a limit on the amount of data the server must transmit to each player. In multiplayer games like Counter-Strike, it's sufficient to send information about other players, their weapons, and bullet trajectories. However, in Left 4 Dead, the behavior of numerous zombies must be constantly updated, significantly increasing the amount of information transmitted. This requires optimized network code and efficient data management to ensure smooth gameplay and minimize latency.

The developers employed a clever solution. In locations with predominantly flat floors, zombies transmit their coordinates only along the X and Z axes. The Y coordinates are updated only if their height changes, such as when a zombie ascends or descends one floor. This allows you to optimize data processing and reduce the load on the system, while maintaining the necessary functionality in the game.

Screenshot: Left 4 Dead game / Valve

The game Left 4 Dead features A limited number of locations. However, replayability is achieved thanks to the AI ​​director, which populates the level with zombies each time depending on the skills of the players. Although one of the developers later claimed that the AI ​​director does not exist and that a random number generator is used instead, this element adds an element of surprise and variety to the gameplay.

Of course, I am ready to help with text editing. Please provide the text itself that needs to be reworked.

We have developed a unique system that tracks the stress level of each survivor, based on parameters such as the damage received by the player and the number of zombies killed in their immediate vicinity. When a survivor's stress level reaches a critical point, the system automatically intervenes and reduces the zombie population, giving the team the necessary time to recover. This allows players to deal with threats more effectively and improves the overall gameplay.

Gautam Babbar is a renowned developer who made significant contributions to the creation of Left 4 Dead. Thanks to his efforts and creative approach, the game has become a cult classic in the co-op shooter genre. Left 4 Dead offers a unique gaming experience that combines a gripping storyline and dynamic gameplay, making it popular with millions of players worldwide. The work of Gautam Babbar and his team continues to inspire developers and fans, emphasizing the importance of teamwork and innovation in the gaming industry.

The developers implemented a system that populates locations with only the zombie species that match their environment. For example, zombies in medical uniforms are found exclusively in hospitals, police officers roam the streets, and office workers wander through offices. Using randomized facial textures, varied clothing colors, and distinct body models, the development team created up to 1,500 unique zombie species. This allows players to not immediately notice that the undead in the surrounding crowd are repeated, which significantly improves immersion and creates a sense of variety in the gameplay.

Days Gone

Days Gone is a game set in a post-apocalyptic world engulfed in a zombie apocalypse. The developers were inspired by the film "World War Z" and sought to recreate the effect of mass attacks of the infected, as in scenes with Brad Pitt. Although they did not succeed in achieving the effect of a zombie tsunami, they accurately depicted numerous clusters of freakers - people transformed into monsters by the virus. Animals can also act as freakers, but this article focuses on human characters. The game offers a unique experience of interacting with this world, allowing players to feel the full atmosphere of survival in conditions where everyone they meet can be an enemy.

Screenshot: Days Gone game / Bend Studio

A single pack can reach 500 individuals. The developers didn't simply distribute them among specific locations, but took into account the unique needs of each pack. Each group inhabits its own environment during the day, meeting its specific needs and habits. This allows for a more realistic and dynamic ecosystem that reflects the natural behavior of such communities.

Of course, I'm happy to help you with text editing. Please provide the text itself that needs to be reworked.

Freakers in the game don't just remain in the sawmill. They can enter buildings, where they hibernate during the day. At night, they venture out into the streets, heading to bodies of water to quench their thirst, after which they continue to roam the surrounding area. All 40 Freaker types exhibit this behavior, adding realism to the gameplay and increasing exploration.

John Garvin, creative director of Days Gone, is a key figure in the development of this project. His experience and vision helped shape the game's unique world, filled with gripping storylines and interesting characters. Garvin worked extensively to create the atmosphere of the post-apocalyptic universe, making Days Gone a standout in the action genre. His approach to storytelling and level design contributed to its wide audience appeal and critical acclaim. Thanks to the efforts of John Garvin, Days Gone offers players a unique gaming experience that immerses them in a world full of danger and adventure.

Screenshot: Days Gone game / Bend Studio

There was a problem: how to create the illusion that a crowd of 500 characters weren't made up of identical twins? The team only had eight unique models, and players would quickly notice the similarities between them. To add variety, the developers changed the size of some characters in the crowd, which also affected their movements. These changes helped create a more believable atmosphere and made gameplay more engaging.

Changing character height by one-tenth of a meter can significantly increase diversity in a game group. Even such a simple change affects the character's gait, which, in turn, automatically changes the Freakers' movement speed. This creates unique gameplay situations and increases player interest in the mechanics of interacting with the world.

Jeff Ross, game director on Days Gone, is a key figure in the development of this popular project. His experience and vision significantly contributed to the creation of unique gameplay and a captivating story. In Days Gone, players are immersed in a post-apocalyptic world filled with zombies and complex moral choices. Under Ross's leadership, the development team was able to create an atmosphere that combines elements of survival, exploration, and environmental interaction. Jeff Ross actively shares his knowledge and ideas, which helps not only improve the game, but also inspires new developers in the video game industry.

Screenshot: Days Gone / Bend Studio

To prevent the protagonist from being overwhelmed by multiple monsters at once, the developers implemented a gradual enemy spawn system. An invisible circle surrounds the protagonist; if an enemy is caught within it, it begins to move toward the character. During battle, the circle gradually expands, encompassing all enemies, so that even stragglers don't lose sight of the player. This mechanic creates tension and forces the player to constantly stay on the move, adding dynamism to the gameplay.

Another problem arose in the game: the Freakers, pursuing the hero, formed a long line, preferring the shortest route. This limited tactical diversity, as the monsters were essentially queuing up to be destroyed under automatic weapons fire. Therefore, the developers were forced to find ways to disperse the crowd to make it more difficult for the player to choose a target. However, the specific methods used to solve this problem remain unknown.

Subnautica

In Subnautica, a game about exploring an alien ocean, fish generally prefer solitude. The only exception is small schools of small fish that swim together.

The player can catch larger individual fish for food, while schools of fish serve a decorative function. Schools have no hitbox, so you can easily pass through them. They, in turn, can also move freely through various objects, such as rocks, other fish, submersibles, and even the walls of your underwater base.

One of the most famous bugs in Subnautica is fish swimming in your shelter, creating the illusion that the room is filled with water. This visual effect can significantly affect immersion in the game, as players expect their shelters to be protected from marine life. Fixing this bug will help improve the gaming experience and restore the realism of the environment.

Screenshot: Subnautica / Unknown Worlds Entertainment

In the game In Subnautica, a school of fish isn't a multitude of individual objects, but a single, invisible element with a particle generator inside. This trick, used by the developers, significantly improves game performance while providing a stunning visual experience. Optimizations like these help create a more realistic underwater environment without a noticeable performance hit, which is especially important for open-world games like Subnautica.

The only way to create a large number of fish in the game is to use particle effects with fish textures, as is done in the current version. Using individual fish models in such large numbers significantly reduces performance due to the geometric complexity and the load from the AI ​​of each fish. Using particle technology optimizes the process and improves overall performance, which is especially important for resource-intensive games.

One of the Subnautica developers responded to a player's question on Steam regarding the realistic behavior of fish in schools. He noted that in-game fish don't display true schools due to gameplay features and technical limitations. The developers aimed to create a captivating and atmospheric ocean world where players can explore the underwater depths and interact with diverse flora and fauna. However, the realism of fish behavior has been adapted to ensure a smooth gaming experience.

Screenshot: Subnautica game / Unknown Worlds Entertainment

Groups of creatures in the game, such as Flocks, schools, herds, crowds, and swarms can significantly enhance the spectacle and realism of gameplay. While such elements aren't always necessary, their proper implementation can enrich the gaming experience. It's important to implement flock behavior with optimization in mind to avoid overloading the computer's computing resources. By using effective algorithms and approaches to group management, developers can create dynamic and engaging scenes that will engage players.

Some games, such as Subnautica, can use a simple particle generator to create crowd effects. However, in projects like Assassin's Creed Unity, Left 4 Dead, and Hitman: Absolution, where crowd scenes play a key role in gameplay, such simple solutions are not suitable. In these cases, it is necessary to develop custom algorithms or apply existing technologies from the gaming industry. One such solution is the Boids algorithm, developed by Craig Reynolds in the 1980s. This algorithm, which models flock behavior, continues to be used in modern games and films to create realistic group interactions.

Profession: Unity Game Developer from Scratch

You will master game development from scratch. Прокачаете навыки программирования: научитесь писать на С# и создавать 2D- и 3D-игры на Unity.Язык просто выучить, даже если вы никогда раньше не кодили. Поэтому вы сможете разработать мобильную или десктопную игру, о которой всегда мечтали, и получать реальные заказы во время курса. А персональный менеджер поможет вам найти работу в крутой геймстудии.

Узнать подробнее