Game Career Guide is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Get the latest Education e-news
  • The Importance Of Reactions In Game AI

    - Sergio Ocio Barriales
  • Reactions are an important aspect of an AI's performance, and getting them right is fundamental to any modern AAA game AI system.

    This post is NOT about decision-making, it is about good reaction design regardless of the decision-making approach. How should our NPCs react to different stimuli? I will talk about our objectives when working on AI reactions, and how these can contribute to building good game AI. I will also talk about some of the basic reactions that every open-world/action AAA game should have.

    Disclaimer: there is a wide array of video game experiences, and each presents different challenges. Some of the tips presented here may or may not be applicable to other genres.

    Apparent Artificial Intelligence

    Artificial Intelligence - it is everywhere. From manufacturing to robotics, self-driving cars to medical applications, or simply to enhancing your photos, AI has become one of the hot topics of our era. It has even been compared to the introduction of electricity a century ago (#Ng17). But what about game AI? Is it real AI? To answer this question, we should talk about our goal. What is the problem that we are trying to solve?

    In a video game, our number one goal is to create a fun and rich experience. Our objective is not to build a perfect simulation, nor it is to always find the optimal solution to our problems - we are crafting an enjoyable experience. An Apparent Artificial Intelligence. An illusion.

    Reactions and Decision-Making

    When an agent perceives a stimulus, this information goes to some decision-making system, choosing whether to ignore the event or handle it. If the event is handled, the AI is "reacting" to that change. In a sense, every change of behavior or strategy made by the AI can be considered a type of reaction, but this post is more focused on those changes that are a result of an incoming event that needs to be handled with some urgency (e.g. hearing a gunshot) vs other types of situations such as "it is 5 pm and it is time for me to stop working and need to start heading home".

    There are multiple techniques that have been used in video games to control decision-making in general, reaction handling in particular. Some common ones are:

    • State-based solutions, such as Finite-State Machines (FSMs) or their Hierarchical versions (HFSMs) can handle reactions as state transitions, so there is no real difference between a reaction and another type of behavior change. However, this does not scale when the number of reactions is very high, as the number of transitions can be hard to control.
    • Behavior Trees (BTs) are, in some ways, evolutions of HFSMs and can handle reactions in multiple different ways, from simply authoring the tree in a way that handling of external stimuli is higher priority and can cause other parts of the tree to bail out as necessary, to more elegant solutions that can inject new behaviors dynamically at certain points of the tree (#Isla05).
    • Automated planners, such as GOAP or HTNs, could require a partial or full re-plan. These scale better (#Orkin06), but reactions will be less controllable in this situation, as the algorithm can be choosing different solutions with the same input event, depending on the current state of the world and what the goal of the NPC is.
    • Some games also build solutions separate from their main decision-making system to control reactions. An example of such an approach could be a rule-based system (#Couvidou17), (#Blouin-Player17).

    Reactions are used to communicate state changes to the player, and although some of this information can also be reported through UI notifications, there is an expectation in modern AAA games of getting this information directly from the agents' behaviors and animations, so getting them right is key.

    Our Objectives

    Our first objective when playing a reaction is to always provide feedback to high-impact player actions. In other words, if the player performs an action and is expecting a reaction from the AI, we need to match their expectations.

    Our second goal is to build reactions that are contextually appropriate. Our agents must show behaviors that are believable and appropriate for the situation. We should not have NPCs dive out of the way when the player whistles at them (overreact) and we should not have an AI ignore a car that is about to run it over (underreact).

    Our last goal is for our reactions always to be readable and consistent. Players need to learn how to play with our gameplay systems, and that includes the AI. This is an especially important point in stealth games, where players often have multiple ways to toy with the perception of the NPCs, and their predictable reactions are a big part of the gameplay expectations - we can have multiple versions of the same reaction, but the type of reaction (i.e. category and intensity) cannot change.

    Suspension of Disbelief

    It is quite common to hear the expression "suspension of disbelief" when we talk about game AI. This idea was introduced back in 1817 by Samuel Taylor Coleridge (#Coleridge1817), when he talked about "the willingness of readers to accept the implausibility of a story, so long as there was sufficient truth to engage their attention".

    In a video game, we can define "suspension of disbelief" as the disposition of the player to accept our rules and get immersed in the world we are creating. As developers, it also represents our contract with our players - we should avoid breaking these rules and shattering the illusion. Reactions play an important role in this quest.

    The objectives we presented in the previous section were aimed at achieving this preservation of the player's immersion. For example, a lack of reaction violates the objective of "always providing feedback to player's actions"; the player can interpret this as broken or unresponsive AI, and start seeing behind the curtain in our game of smoke and mirrors. Similarly, inappropriate reactions can look silly and out of context, or just buggy.

    We also talked about readability and consistency as important qualities for our reactions. This is because our brains are extremely good at pattern recognition (#Mattson14). We want our players to have a high-level understanding of our systems and build certain expectations regarding the responses our agents will manifest to the players' actions. But this also means our brains will easily spot repetition - and this is not a desirable trait for video game reactions.


comments powered by Disqus