
“Feelings” in game development is a useful metaphor for understanding, creating and discussing the part of AI that collects information about important objects in a simulated game environment. Non-game characters in a realistic three-dimensional space are usually people, animals or other creatures with vision and hearing, so this metaphor is very convenient.
But this development metaphor should not be taken too literally. Despite the seeming physical nature of the AI of the game world, this analogy is neither physical nor neurological. The line between “feeling” and “knowledge” in the game is blurred. The feeling includes the idea of awareness of the presence in the game of other elements of the game, as well as their assessment and knowledge of them. Game logic can be tied directly to such elements.
')
The system of feelings in the game must be created in such a way that it obeys the needs of the game design and is effective in implementation. The system should not be too complicated, it is enough to ensure the reliability and interesting gameplay. The result of her work should be perceived by the player and clear to him. Only a few AI games need a sense of taste, touch, or touch, and vision and hearing are mainly used. When used correctly, feelings can become an invaluable tool for creating more interesting behaviors of simple finite automata.
This article describes the approach to the design and implementation of a high-precision sensor system for AI in a first-person game with an emphasis on stealth. The techniques described here are taken from the experience of developing AI for the
Thief: The Dark Project , as well as from reading the
Half-Life code. The first part of the article sets out the basic concepts of AI feelings on the motivating example of
Half-Life . The second part sets out more stringent requirements for sensory systems in the design of stealth games and describes the system created for
Thief .
Case Study: Half-Life
In
Half-Life, stealth and feelings are not the main thing. However, due to the strong emphasis on tactical combat, it requires a logical sensory system. Therefore, this game is a great example for exploring the fundamentals of AI sensor systems. AI in
Half-Life has scope and hearing, as well as a system for managing information about detected objects. The game has interesting examples of applying simple feelings to create compelling behaviors.
In a simple sensory system, the AI periodically “looks” and “listens” to the world. Unlike vision and hearing in the real world, where stimuli are received by the senses passively, whether an object wants to or not, in the game they are active events. The AI explores the world based on its interests and decides according to a set of rules whether it sees and hears another element of the game. Such checks emulate real feelings, while at the same time reducing the amount of work needed. Most resources are spent on aspects that are important to game mechanics.
For example, a periodically called base Half-Life sensor system is as follows:
If I'm close to the player, then ...
--
-- ...
----
----
---- , ...
------
------ , ,
------
--------
------
-------- , --------
-- ...
---- ...
------
------ ...
-------- , , -
------ ""
-------- , , -
The first concept, illustrated by this pseudocode, is that feelings are closely related to the properties of the AI, with its relationship with the object and with the correspondence of the actions of the AI to the player's actions. This is partly due to the desire to optimize, but is implemented through game mechanics. In the
half-life game design, an AI character that is far away from the player is not important and does not need to feel the world. Even when he is close to the player, the AI only needs to look at objects that later should cause him to react with fear or hatred.
This logic also demonstrates the design of the visibility system as a combination of visibility distance, visibility cone, line of sight and eye position (Fig. 1). Each AI has a limited two-dimensional field of view within which it emits rays in the direction of interesting objects. Free reaching rays mean visibility of objects.
Picture 1It is worth noting two important aspects. First, sensory operations are performed in order, from less costly to more costly. Secondly, for the sake of the player's pleasure, the vision system in the game is made so that the enemy sees the player only when he sees him. In the game from the first person, the player weakly feels the body, and if the opponent notices the player earlier, this often seems to be cheating.
The most interesting piece is the limitation of the ability of the AI to see the player until the player sees the AI. It is only needed to make the game exciting. This is an example of how high-level game goals can be easily and elegantly achieved using elementary techniques in low-level systems.
The logic of hearing is much simpler than that of sight. The basic element of the hearing component is the definition and setting of what the audible sound conveys to the AI. In the case of
Half-Life, hearing is a rectilinear heuristic of the sound volume multiplied by the “sensitivity of hearing”, resulting in the distance at which the AI hears the sound. More interesting is the demonstration of the ability to hear as a template for collecting general information about the world. In this example, the AI "hears" pseudo-sounds, that is, fictional smells emanating from nearby corpses.
Feelings as an important element of the gameplay: Thief
In
Thief: The Dark Project and its followers, a slightly scripted game world is presented, in which the central mechanics of the game (stealth) conflict with the traditional gameplay of a 3D first-person game. The
Thief player moves cautiously, avoids conflicts and is punished for killing people. At the same time he can easily die. Gameplay focuses on changes in the AI’s knowledge of the player moving through the game’s space. The player must move around the area filled with fixed, moving and patrolling AI, trying to stay unnoticed, hiding in the shadows and not making sounds. Although the feelings of gaming AI are built on the same basic principles as in
Half-Life , the mechanics of stealth, escape and unexpected attacks require a more sophisticated sensory system.
The main requirement was the creation of a very flexible sensory system operating in a wide range of conditions. On the surface, stealth gameplay focuses on the fictional themes of stealth, escape, take-over, light and shadow. One of the aspects that make such gameplay interesting is the expansion of the “gray zone” between security and the threat, which in most first-person games is very thin. The game tends to maintain tension, keeping the player on the verge between different states, and then going all serious at the intersection of the zone. This requires a wide range of feelings that do not have well-defined polar values of "the player is seen" or "the player is not noticed."
The second requirement is that the sense system must be activated much more often and for more objects than in a regular first-person shooter. During the game, the player can change the state of the world in ways that the AI should notice, even when the player is not nearby. Some aspects, such as hiding corpses, require a well-functioning system. These two requirements create an interesting problem that conflicts with another essential requirement for game developers: game performance.
Finally, it is necessary that both players and designers understand the input and output information of sensory systems, and that the output information matches the results expected from the input information. This prompted the developers to create a solution with a limited amount of input data perceived by the player and discretely evaluated results.
Expansion of the range of feelings
At its core, the sensor system described here is very similar to that used in
Half-Life . It is a visibility system based on visibility cones and emitted rays and a simple hearing system that supports optimization, game mechanics and pseudo-sensory data. As in
Half-Life , most data collection is independent of the decision-making process that is performed based on this information. In this system, some of the basic principles have been expanded and new ones have been added.
Figure 2. Main components and relationshipsThe system design and data transfer through it are designed as a customizable, flexible system for collecting information that provides stable and clear output data.
In this system, AI's feelings are due to “awareness”. Awareness is expressed in the form of a set of discrete states representing AI awareness of the presence, location and identification of the object of interest. These discrete states are the only representation of the internals of the system available to the designer. In the high-level AI, they correlate with the character's alertness. In AI Thief, a set of states of alertness is similar to a set of awareness states. The state of alertness of the AI in various ways is transmitted to the sensor system to change its behavior.
Awareness is stored in sensory connections that tie AI to another entity in the game or to a position in space. These links contain important for the game details of sensory information (time, place, line of sight, etc.), as well as cached values used to reduce the number of calculations between cycles of “thinking”. In principle, sensory communication is the main memory of AI. Through verbal transmission and observation, sensory connections can be distributed between AIs with the control of knowledge distribution cascades by level. After basic processing, they can also be controlled through the logic of the game.
Figure 3. Sensory communicationEach object of interest in the game has its own visibility value, independent of the observer. Depending on the state of the game and the nature of the object, the level of detail of this value and the update frequency are scaled, which allows reducing the processor time to calculate the value.
Visibility is determined by the illumination, movement and visibility (size, distance from other objects) of the object. Its value is closely related to the requirements of the game. For example, the player's illumination is tied to the illumination of the floor under his feet, which gives him an objective and visual way to determine his own security level. These values and visibility in the form of their total amount are stored as analog values in the interval 0..1.
Visibility cones
Instead of a single two-dimensional field of view for the senses,
Thief implemented a set of three-dimensional cones of visibility going in order, defined as XY angle, Z angle, distance, set of parameters describing general visual acuity and sensitivity to different types of stimuli (for example, to movement and light) and their relation to the alertness of AI. Visibility cones are located in the direction of rotation of the AI head.
At any given point in time for the observed object, only the first cone of visibility, in which the object is located, is used in the calculations of the senses. For simplicity and the ability to customize the gameplay, it is believed that each cone of visibility creates constant output data, regardless of which part of the cone of visibility the object is in.
For example, the AI shown in Figure 4 has five visibility cones. The object at point A will be evaluated with cone number 3. The cone of visibility used to calculate the visibility awareness of the object at point B and point C is the cone number 1, in which the same visibility values for the object give the same result.
Figure 4. Visibility cones, top viewWhen checking objects of interest in the world, the system of feelings first of all determines which of the cones is related to this object. Then his own characteristic of visibility, along with the cone of visibility, is transmitted through the heuristic of "sight", which gives out the discrete value of awareness.
Several visibility cones are used to implement aspects such as direct visibility, peripheral vision, or to distinguish objects that are directly ahead and on the same Z plane from those that are in front, but higher and lower. Cone number 5 in the figure is a good example of using a low-level system to express a high-level concept. The cone of "imaginary sight" looks back. He is sensitive to movement and gives the AI a “spider scent”: the character senses when he is being moved too closely, even when the player is completely silent.
Information conveyor
The sense control system has the form of a series of components, each of which receives a limited and well-defined set of data, after which it produces an even more limited value. The cost of processing each stage can be independently scaled according to the importance of the gameplay. In terms of performance, such multiple scalable layers can be made incredibly efficient.
Figure 5. Conveyor InformationThe basic sensory system implements heuristics, which receive information about visibility, sound events, current awareness connections, data of configurations of designers and programmers, and the current state of AI, and the output shows one awareness value for each object of interest. These heuristics can be viewed as a “black box”, which the AI programmer constantly adjusts as the game develops.
Vision is implemented by filtering the value of the object's visibility through the corresponding cone of visibility, which changes the result based on the properties of each AI. In most cases, simple beam emission is used to check the line of sight. In a more interesting case, for example, when calculating the visibility of a player, several rays are emitted, determining the spatial relationship of the AI to the object when weighing the object's visibility.
Thief uses a sophisticated sound system in which sounds that are emitted and unpublished are marked with semantic data and distributed throughout the 3D geometry of the world. When the sound "reaches" the ears of the AI, it comes from the direction from which it would come in the real world, marked by weakened awareness values. If the sound is speech, then sometimes it carries information from other AI. Such sounds are added to other aspects that change the level of awareness (for example, the smell in the case of
Half-Life ) as an attitude of awareness of a position in space.
Impulses awareness
After completing the operations of sight and hearing, their results in the form of an awareness level are transmitted to a method that receives periodic impulses from the raw signals of the senses and transforms them into a simple awareness relation, all the details of which are stored in the associated sensory connection. Unlike the analog data used in the pipeline at this stage, the data in this process is completely discrete. The result of this process is creating, updating, or resetting sensory connections with the correct awareness value.
This process takes place in three stages. First, the input values of hearing and vision are compared. One of them is declared dominant and becomes the value of awareness. The auxiliary data created by each sense is cleared and combined into a total amount of sensory events.
Secondly, if the awareness impulse has increased compared to the previous indicators, then it is passed through a time filter, which determines whether awareness will actually increase. The time delay is a property of the current state only, not the target state. This is how delays in reactions and indicators of a player's forgiveness are realized After passing the time threshold, awareness passes to the target state without passing through intermediate states.
Thirdly, if the new impulse value is lower than the current reading, the “capacitor” is used to smoothly and gradually reduce awareness. Awareness decreases during a certain period of time, passing through all intermediate states. This softens the behavior of the AI after only the object of interest is no longer felt by the senses, but the alertness of the AI is not governed by this mechanism.
If the object of interest no longer generates impulses, the degree of free knowledge that is scalable based on the AI state is added to the senses. This mechanism creates the appearance of logical thinking from the AI, when the object disappears from the scope, allowing you to hide cheating from the player.
Conclusion
The system described in the article is designed for a single-player game with software rendering. Therefore, the rendering system was available all the information about the objects of the game. Unfortunately, in a game engine with a client-server architecture and exclusively hardware renderer, this may not be possible. The calculation of the illumination area of the object may not be so straightforward. Therefore, to implement such a system should be thoughtfully and carefully, because it will need information from other systems.
In addition, despite its effectiveness, the system is designed to play, largely dependent on the data output from this system. In Thief, it takes quite a large part of the time allocated in the CPU for all AI calculations. Therefore, the system can take time away from the search for ways, tactical analysis and other decision-making processes.
However, any game can benefit from the implementation of the sensory system. When collecting and filtering information about the environment and correctly processing it, the sense system can be used to create interesting AI behaviors without significantly complicating decision state machines. In addition, a reliable sensor system allows you to implement "pre-conscious" behavior with the help of managing and changing the basic knowledge input data. Finally, a sensory system with a multitude of states gives the player an artificial opponent or ally, demonstrating diverse and complex reactions and behaviors that do not add unnecessary complexity to basic decision-making machines.
Further research
Due to the fact that the Dark Engine, on which
Thief was created, depends heavily on the data, most of the concepts presented in the article and all configuration details can be explored independently using the tools posted on
http://www.thief-thecircle.com .