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

  • Combat State Transitions

    The lifetime of an agent in a video game can usually be represented (at a very high-level) as a state machine with a very limited number of states. For example, the typical action game could be depicted, at a very high level, as an FSM with four states - PRE-COMBAT, COMBAT, SEARCH and DEATH (note: these states can be split further into smaller parts, but this is not in the scope of this post).

    Transitions between any of these states should be communicated to the player, as they are a big event in the lifetime of our NPCs. Players need to get clear feedback about these changes.

    Player Sighting

    In our high-level state machine, any transition into the Combat state is an interesting one. These transitions happen when the AI becomes fully aware of the player (enemy) and it is ready to engage, and we definitely should build a different reaction for each of the transitions that take us into Combat (e.g. Precombat to Combat; or Search to Combat).

    There is, however, an even more special transition into combat, which happens when the player just pops in front of an AI at a very short range. This should cause an almost immediate change of awareness, where the agents become fully aware of the player almost instantly. It is important to differentiate this particular case from just regular detection - it will make perception feel much more realistic and snappy.

    The agents' confidence in their knowledge of the player's whereabouts may also play into the type of reaction produced. If the AI is certain the player is at some location, but the player is spotted at a completely different position, the reaction should be different. NPCs that show surprise towards a player action are reinforcing the player's behavior (i.e. the game is acknowledging the player has bested it), enhancing the gameplay experience.

    Player Absence

    In action/stealth games, it is very common to avoid having AI agents that magically know the whereabouts of the player unless he/she is currently visible. Instead, the AI will create a "last-known position" model through the different perception stimuli it has received over time.  When we have this type of system, there are two big reactions that we should consider building:

    • The player is located at a different location: If the player is detected at a different location that is far enough from our original guess, the AI should acknowledge it has been outsmarted, by looking surprised. Some games forget this reaction, and the result on screen is an instantaneous change of orientation in the AIs to face the new position, but this looks very unnatural. If instead, the new location is very near to the old one, a special reaction is not really necessary. In fact, adding a big reaction could negatively affect the look of our AI. Player detection updates can also inform what our locomotion should do: if the AI is moving toward the position (e.g. if it is trying to investigate it) and the position is updated and still in the same general area as the old LKP, all we should probably do is update the destination of our move command; on the other hand, if the new position is anywhere else (e.g. behind the moving agent), the AI should play a stop animation before restarting the movement.
    • Confusion: If our agents decide to clear the position where they think the player is, but they discover that their belief was wrong (i.e. the player has moved away), it is common to simulate the notion of "confusion", or the degree to which the AI beliefs of the world have just proven false. In this case, we should once more acknowledge the player is "smarter than us", and clearly feedback that "we are going to start looking for him/her". This is actually the transition from "combat" into "search" in our high-level FSM.

    Tactical Failure

    To give the illusion of smart AI, we should try to find a way to detect situations in which players are taking advantage of an AI weakness, and react to them. Letting the player know "this is not going to work anymore", and modifying our agents' tactics accordingly will be a big boost to the believability and quality of our AI.

    For example, let's say the player has a tool to lure AI agents to his or her position and keeps using this as a strategy to deal with all the agents in an area with low or no risk. We could "counteract" this on the AI side by changing the regular reaction and behavior of the third agent that is attracted by this tool - the NPC should acknowledge "something is not right" and change its strategy (e.g. calling for reinforcements or escalating the situation).


    In this post, I have shown different ideas that can help readers create more engaging and human-like characters through reactions -building good ones can change the player's perception of the quality of our games!

    As a summary, the key takeaways are:

    • Use smart barks that can convey a feeling of intelligence, but do not overuse them. Writers are your allies.
    • Use animation variations as much as possible - this will avoid repetition problems.
    • Randomize reaction times - this will make your agents' responses look and feel more human.
    • Match your players' expectations when it comes to reactions - if a player is expecting a response from the game, make sure you have built one.


    [Ng 17] Ng, A. 2017. Artificial Intelligence is the new electricity. (accessed May 2020).

    [Isla 05] Isla, D. 2005. Handling Complexity in the Halo 2 AI. In Proceedings of the Game Developers Conference.

    [Orkin 06] Orkin, J. 2006. Three states and a plan: the AI of FEAR. In Proceedings of the Game Developers Conference (vol. 2006, p. 4).

    [Couvidou 17] Couvidou, L., Sadoulet, X. 2017. Taking Back What's Ours: The AI of ‘Dishonored 2'. Game Developers Conference 2017. (accessed May 2020).

    [Blouin-Payer 17] Blouin-Payer, R. 2017. Helping It All Emerge: Managing Crowd AI in ‘Watch Dogs 2'. Game Developers Conference 2017. (accessed May 2020)

    [Coleridge 1817] Coleridge, S. T. 1817. Biographia Literaria. Chapter XIV.

    [Mattson 14] Mattson, M. P. 2014. Superior Pattern Processing is the Essence of the Evolved Human Brain. Frontiers in Neuroscience 8, 265. (accessed May 2020)

    [Orkin 15] Orkin, J.. 2015. Combat Dialogue in FEAR: The Illusion of Communication. In Game AI Pro 2: Collected Wisdom of Game AI Professionals, ed. S. Rabin, Boca Raton, FL: A K Peters/CRC Press.

    [Ruskin 12] Ruskin, E. 2012. AI-driven Dynamic Dialog through Fuzzy Pattern Matching. Empower Your Writers! Game Developers Conference 2012. (accessed May 2020)

    [Shroff 15] Shroff, J. 2015. Realizing NPCs: Animation and Behavior Control for Believable Characters. In Game AI Pro 2: Collected Wisdom of Game AI Professionals, ed. S. Rabin, Boca Raton, FL: A K Peters/CRC Press.

    [Rabin 15] Rabin, S. 2015. Agent Reaction Time. In Game AI Pro 2: Collected Wisdom of Game AI Professionals, ed. S. Rabin, Boca Raton, FL: A K Peters/CRC Press.

    [Campbell 18] Campbell, J., Loudy, K. Embracing Push Forward Combat in ‘DOOM'. Game Developers Conference. (accessed May 2020)

    [Walsh 15] Walsh, M. 2015. Modeling Perception and Awareness in Tom Clancy's Splinter Cell Blacklist. In Game AI Pro 2: Collected Wisdom of Game AI Professionals, ed. S. Rabin, Boca Raton, FL: A K Peters/CRC Press.

    [Welsh 15] Welsh, R. 2015. Crytek's Target Tracks Perception System. In Game AI Pro 2: Collected Wisdom of Game AI Professionals, ed. S. Rabin, Boca Raton, FL: A K Peters/CRC Press.


comments powered by Disqus