Most of the time, game AI enemies follow some kind of preset decision-making process. It's usually either a series of conditions that get evaluated until some decision is made, or it's a [finite state machine] that transitions from state to state based on timing and conditions being met. Regardless, decisions are made whenever the proper conditions are met.
Sometimes (usually through uncaught errors on the part of designers like me), the AI gets into a bad state where there's no valid actions to take. In the case of a finite state machine, this could be an orphan state with no exit condition, or a series of states that infinitely loop over and over. In the case of a condition series, it could be an edge case of some weird condition being met that has the AI brain bail out before it reaches any valid action to take. Decision-making that requires certain timing, for example, can also result in this kind of state if the timing conditions for the next step doesn't get met. Regardless, AI that don't do anything are usually stuck in a bad situation that they have no valid means of handling.
Most of the time, we build in some form of debugging visualization to help us figure out what step of the AI decision-making process each AI is currently up to. This way we can catch the various errors that crop up for unhandled edge cases. Unfortunately, the more obscure edge cases can sneak through our testing and make it out to the live game.
[Join us on Discord] and/or [Support us on Patreon]
Got a burning question you want answered?
- Short questions: Ask a Game Dev on Twitter
- Long questions: Ask a Game Dev on Tumblr
- Frequent Questions: The FAQ