The main problem of AI in state machines, therefore, comes down to manpower and resources – creating that many states for so many purpose would become difficult at best, and impossibly unrealistic from a game design standpoint at worst. Obviously, programmers have found a way for more complex AI functions than “move here when player inputs X” to happen, and we call these the “goal-oriented planning system”. F.E.A.R., that game with the freaky girl that is difficult for me to play due to my jumpiness, is mostly well-known for its brilliant AI and the squad tactics they often employ.
Think of it like a priority system that functions in real time; no longer does a character only perform one particular action in one particular preset state. Instead, actions occur due to context and the goal of the AI characters in question. Everything’s based on the big-picture of the preset goal (in the case of F.E.A.R., that means “killing the player as quickly and efficiently as possible), and they will take whatever steps that look most effective to reach that goal.
In this case, the developers merely chart out a list of actions and states that the AI can use; obviously, it will direct it so, for example, the F.E.A.R. enemies will try to shoot you in the face before meleeing you to death, so there’s priorities (also, they don’t try to hug you). The point of the system is to replicate the unpredictable nature of human action, and in F.E.A.R.’s case it works brilliantly.
Of course, it isn’t just limited to foes; you can see this at work in strategy games where units will attack when an enemy’s in range, or retreat when they lose morale, or make sure they’re not being flanked. This relative automation allows the player to bring their focus away from intense micromanagement to focus on the big picture scenarios. That doesn’t mean the micromanaging goes away, merely that the game does some of the menial, tedious work for you so that you can have fun. Games where you control all of the factors still use state machines, though, just so that the player can predict the results when they undertake a particular action (unless, say, you intentionally automate development, or set an AI governor to a province, etc.).
In other words, a goal-oriented planning system arranges all of these state machines into something resembling an intelligent AI that allows for adaptability and unpredictability; it chooses a state appropriate for the task while continuing to adapt when necessary. Not only does this look elegant from a programming perspective, it also creates a wonderful illusion of intelligent AI; players, indeed, notice the difference between “good” and “bad” AI when planning machines emerge.
Of course, there’s a further problem here: most AI cannot actually see the environment they’re navigating. We often assume that, say, an enemy can see our character and we can see him, but that’s far from true. If it were, that would (again) require a huge amount of processing power and development time unavailable in a market with deadlines and promises to keep.
Developers literally draw a navigation map – basically a bare version of the game world that the players see -so that the AI can see the traversable area. The navmesh shows the AI the limitations of the terrain and what exactly they can do (for example, not waltzing through a wall or something). Remember that the AI on a planning system will still look for the ideal efficient actions, and the developers can “plan” around this as well by placing specific obstacles and pieces in the environment for them to overcome. Since the animations and decisions will turn out as context-specific, this means the terrain’s just as important to creating exciting set-pieces as “good AI”.
If you just plop the same old enemies with the same old patterns in similar spaces without giving them added animations or tools at their disposal, things will tire quickly with the repetitiveness and lack of intelligent obstacles. I can remember playing through Halo myself, eventually getting tired since the Covenant’s low enemy variety and relatively similar situations turned most firefights into the same firefights. Things improved when the Flood emerged, adding some element of variety to the proceedings, but you really don’t need an entirely new enemy type; F.E.A.R. made that clear enough, given that each fight feels equally exciting in a boring office space/industrial environment.
Destructible environments, an effect of the continual increase in realism, also adds to the possibilities. Changes in the navmesh in an active sense create new efficiencies for the goal-oriented planning systems, and that keeps things dynamic without needing to make an entirely new planning system for minor changes. Most modern AIs actually re-analyze the environment on the fly (about a half second in our time), meaning they can continue to make new decisions and evaluate the proper response. Heck, some of these games (the open world ones specifically) even allow the AI to detect their environment like we read a map, using latitude and longitude to figure out their exact location relative to the player and their own AI routines.
Heck, the advances made in all of these systems just makes my head spin. I can’t imagine most people “in the moment” could take time to even bother thinking about the “realism” regarding what’s happening on screen. Also, why would you need MORE advancement? How much more fun are the games becoming? I’m curious what kind of answer someone could throw out. There’s limitations, however…