Artificial Intelligence Horizon Zero Dawn: Individual Behavior

http://gamasutra.com/blogs/TommyThompson/20190206/335380/Behind_The_AI_of_Horizon_Zero_Dawn_Part_2.php
  • Transfer
In the first part of the Horizon Zero Dawn AI study, I described how the game creates herds of AI-controlled animal-machines. This requires a complex agent hierarchy system in which each machine can make decisions about how to behave using the network hierarchical task scheduler, and group agents collectively assign roles and responsibilities to the machines as parts of the herd. All of this is part of a system called The Collective, which supports the ecosystem of all the machines in the world when the user is in the game.


In this final article, we take a closer look at systems that individual machines can use as part of their basic behavior. They include sensor systems, navigation for ground and flying machines, as well as the close connection of AI behaviors with animation systems, providing each machine with dangerous, but at the same time realistic behavior.

Sensors and movement


First, let's look at the sensors used by machines to trigger AI reactions, and also find out how the animation is tied to the overall process of executing their behaviors. The machine can use a significant number of unique sensors: visual sensors, for example, the eye of the “yawn” , radar and sensors in the presence of “long- distance men” , hearing sensors that detect sounds of distant explosions and throws of stones near, as well as the ability to feel players touching the machine. Each machine has a set of these sensors, calibrated by their own sensitivity values, so it’s pretty easy to get close, for example, to a “trotter” or “chewing-gum” , and it ’s more difficult to catch a trap .


The traditional sensor system can only track events occurring around AI and “see” / “hear” them, but in fact, the sensor system has much more nuances. They use packets of information attached to objects that can cause stimuli on one of the sensors of the machines: such objects can be the player, other NPCs, stones, flying arrows, other machines and nature. This data tells the recipient (the machine that felt something) information about what she found and about his condition. Therefore, machines, like human NPCs, can understand the difference between the corpse lying in front of them and the arrow whistling alongside their head; in addition, it allows the player to hide in the tall grass or behind the trees is not noticeable - the machines receive information that he is invisible in this state.

Each AI character, whether machine or person, is able to process and interpret sensory data in a different way, so certain information can be ignored by some characters, while others respond to it properly. In fact, depending on the strength of the sensor in the car, it can reduce the amount of data it receives from the touch event, which it can read. This allows you to control the emergent properties of the game so that each type of character can respond to information in its own unique way.

If the AI ​​needs to perform an action based on this sensory data, we still need to make it look realistic. Therefore, when a machine decides to take some action, for example, moving to a new location, researching a source of anxiety or attacking a player, there is a problem of animating the implementation of these actions in the most realistic way possible. Animation of these machines is a very difficult task: they must simultaneously look like live prototypes and have a distinct machine-like behavior. For this, it is necessary that both navigation and combat systems take into account the distance that the machine must travel, and the animated tulchein must adjust the root bones of the animations and mix them in accordance with the perceived distance and time of movement.


This ensures that at any distance of movement and speed of the machine it will be able to start the animation, go into the main part of the behavior, and then mix them correctly and at the right time. This is important for such behaviors as running to a certain point, when the car needs not only to slow down and stop at the desired point. But it is especially important in combat. Many of the animations used for attacks have two separate sequences: a swing, announcing the start of an attack, followed by a termination, causing damage. The Horizon Zero Dawn used a method similar to the one which I described in the article about the AI of the game DOOM: The system controls the current movement of the vehicle, mixes motion tweens or attacks to get to the right points, and then makes the machine turn out to be or stop at the end.

Navigation


There is one more serious task that I haven’t talked about yet - navigation. The task of moving cars around the world is very difficult, there is a wide variety of unique types of enemies, and they all have a different size and shape. Therefore, they must move along the relief in a natural way for them. In addition, they must recognize changes in local geometry and adapt to them or simply ignore them, depending on the type of machine. This requires a widely used AI tool called a navigation mesh. Navmesh stores information about how a particular character can move around the map based on what is considered to be obstacles in the world. Although we can calculate all this during the execution of the game,


Considering that the Horizon Zero Dawn cardhuge and at a particular time only its individual segments are required (AI is active and moves only near the player), the navigation mesh is created during the execution of the game, but only within the immediate vicinity of the player. But what is interesting is that not one navmesh is used, but as many as six! Four of them provide the movement of the character based on the size of the object: small, medium, large or huge. Therefore, people and "ryskari" can move around a small mesh, and for such machines as thunder, navmesh almost completely belongs only to them. In addition, there are two additional navmesh: one for floating machines, for example, for click-toothes, as well as a unique mesh, forcing the machines to stand in convenient locations in case the player tries to climb them.


In each of these cases, the obstacles can block or change the structure of the navigation meshes, and the system recounts changes in real time so that moving obstacles (and even other machines) can affect the ability to move around in space. The interesting thing is that the obstacles can have different properties, and are able to be completely impassable, or simply undesirable to move - but this strongly depends on the state of behavior of the AI ​​machine. As it is said in the first part, actively patrolling cars after their creation avoid vegetation in which they can hide, but when researching the closest sources of anxiety, the grass still remains undesirable, and yet the machine can still pass through it if necessary. The same principle applies to small stones and trees:"Hippos" , "stone-eaters" and "thunder" . These monsters can smash stones and uproot trees, but only if they are in a state of anger or are chasing the player. Being in a state of other behaviors, these machines perceive such obstacles as any others.

Air movement


Although this navigation armchair copes with ground-based machines of all sizes and shapes, it does not work at all for those who fly in the air. Non-player characters moving through the air must not only take into account the nearest obstacles in order not to collide with trees or cliffs, but must also know the height of the surrounding geometry. The world of Horizon Zero Dawn is full of hills, forests, cliffs and steep mountain climbs ... Two types of flying machines, the kite and the petrel , need to know how to move through the air so that you can take off, move on patrol routes, land, as well as decline and, if necessary, attack the player. For this, the game has not only a ground navigation mesh system, but also a completely separate air system.


Its creation turned out to be a difficult task for the AI ​​development department of the game. He used a technique called “planning hierarchical paths using MIP textures” (hierarchical path planning over MIP maps). MIP Mapping is a technique used in computer graphics. aimed at minimizing the amount of memory occupied by a texture or image. To do this, create a set of identical images with gradually decreasing resolution. This solution is ideal for controlling the level of detail in games: objects hundreds of meters from the player are visible, but use less texture memory than those that are near the player and use the maximum quality. This approach was used for navigation because when the car flies along the path laid in the world, it does not need to know with complete accuracy the local geometry of the place where it will be in a minute, but it is necessary to know the location of the earth just before it should land. The path planning system for airborne machines uses MIP texturing to create a height map of local geometry — a data structure that tells us the height at a given x / y position in the world. MIP textures have four levels, and as they get closer to the ground, they become more complex and realistic. Level 3 is a simple and abstract model, and level 0 texture is a fairly accurate map of the heights of the world. The path planning system for airborne machines uses MIP texturing to create a height map of local geometry — a data structure that tells us the height at a given x / y position in the world. MIP textures have four levels, and as they get closer to the ground, they become more complex and realistic. Level 3 is a simple and abstract model, and level 0 texture is a fairly accurate map of the heights of the world. The path planning system for airborne machines uses MIP texturing to create a height map of local geometry — a data structure that tells us the height at a given x / y position in the world. MIP textures have four levels, and as they get closer to the ground, they become more complex and realistic. Level 3 is a simple and abstract model, and level 0 texture is a fairly accurate map of the heights of the world.


Almost the same as the navigation meshes, mip-textures are created during the execution of the game and as needed: when flying within a certain area, the car does not need to know the heights of the whole world. When they need to fly to a different location, the flight navigation AI launches the A * search algorithm for the highest level MIP texture, that is, it calculates the simplest version of the flight route from the approximate geometry version. Algorithm A * makes flying over and under obstacles more costly than flying around them, so cars hover next to mountains and rocks more often than fly over them. Every time when the system calls the A * algorithm, it has only a limited number of iterations, so after calculating the path using the simplest mip-texture (level 3), it takes a certain segment of the calculated path, and then improves it, borrowing data from levels 1 and 0 to make it more realistic and relevant geometry. In addition, it smoothes the routes in such a way as to eliminate steep inclines and sharp turns, making them more realistic. This system works very well, any flying machine in the air always has a flight plan (even when it is bad), and if necessary it can improve it by repeatedly calling the search algorithm so that the path becomes more and more natural. In addition, it effectively uses memory, but this approach has one flaw - since it is based on the maximum height of a given area of ​​the map. cars cannot fly under bridges or stone arches, but more often than not, the player does not notice this. to eliminate steep inclines and sharp turns, making them more realistic. This system works very well, any flying machine in the air always has a flight plan (even when it is bad), and if necessary it can improve it by repeatedly calling the search algorithm so that the path becomes more and more natural. In addition, it effectively uses memory, but this approach has one flaw - since it is based on the maximum height of a given area of ​​the map. cars cannot fly under bridges or stone arches, but more often than not, the player does not notice this. to eliminate steep inclines and sharp turns, making them more realistic. This system works very well, any flying machine in the air always has a flight plan (even when it is bad), and if necessary it can improve it by repeatedly calling the search algorithm so that the path becomes more and more natural. In addition, it effectively uses memory, but this approach has one flaw - since it is based on the maximum height of a given area of ​​the map. cars cannot fly under bridges or stone arches, but more often than not, the player does not notice this. so that the path becomes more and more natural. In addition, it effectively uses memory, but this approach has one flaw - since it is based on the maximum height of a given area of ​​the map. cars cannot fly under bridges or stone arches, but more often than not, the player does not notice this. so that the path becomes more and more natural. In addition, it effectively uses memory, but this approach has one flaw - since it is based on the maximum height of a given area of ​​the map. cars cannot fly under bridges or stone arches, but more often than not, the player does not notice this.


Thanks to ground-based navmesh and air mip-textures, flying machines can coordinate attacks, landings, dive attacks and even fall to the ground in accordance with the geometry. Machines that hang over a player during an attack still use a pre-calculated flight plan, but do not necessarily move along this path, and play the corresponding animation. The speed of the machine is tied to the mode (flight, hover or hovering), so they can realistically circle around the player using the same navigation tool.

Takeoffs and landings use a separate system that interacts with flight navigation and ground navigation mesh: it searches for suitable positions in the mesh that can be landed (usually points a little higher above the ground than the local average), and then pick up the angles and speed. Landing, the machine uses ground-based navmesh, corresponding to its size. The same principle is actually applied when falling, only in this case the only suitable landing positions are based on the current course of the car, and although the wreck looks less graceful, in fact it uses the same tools. The specially programmed boundary case here is a “petrel” dive attack . "Petrel"circling over the player and then falling down towards the player’s current position. He uses the same systems, but in a much more dramatic way. However, there is another trick: circling over a player, the “petrel” often waits before an attack, until it closes the sun. Perhaps playing a game, you noticed it, and it was done on purpose. When testing the “petrel” AI , the QA department noticed that it periodically closes the sun to the player, and this makes his attack more disorienting, because during a dive the light shifts and blinds the player. Then it happened completely by chance, but then the AI ​​department decided that this should happen more often.


Finally


Horizon Zero Dawn creates a unique gameplay; a world filled with mechanical life becomes a place where the story unfolds by Eloy and the secrets of her past. Artificial intelligence and gameplay systems of machines is the most important aspect of creating this apocalyptic future for players. It was a large-scale work for a team of 10 people, which took several years of development. Creating AI systems of a similar scale that work well in games with a huge open world is becoming increasingly difficult. Therefore, it is vital for the community of game developers to share their experience with others.

Reference materials


  • Julian Berteling, 2018. “Beyond Killzone: Creating New Horizon Zero Dawn Systems”, GDC 2018.
  • Arjen Beij, 2017. “The AI ​​of Horizon Zero Dawn,” Game AI North 2017.
  • Wouter Josemans, 2017. "Putting the AI ​​back into the Air: Navigating the Air Space of Horizon Zero Dawn" , Game AI North 2017


Also popular now: