When you head to a search engine and type ‘top 10 best videogame AI’, the resulting lists and articles will often contain many a familiar face if you’re been reading the History of AI series. You’ll find classics like StarCraft or Halo, and perhaps some beloved stealth games like Splinter Cell or The Last of Us. Plus some highlights of other genres, be it Forza Horizon, The Sims, or Alien: Isolation. But there’s one game you can guarantee will appear in that list every time.
Facing Your FEAR
F.E.A.R. – which is an abbreviation of First Encounter Assault Recon – is a first-person shooter released on PC and consoles back in 2005 by Monolith. And despite being over 15 years old, it’s still heralded as one of the best examples of AI for combat action games. And the secret to making it work is a mixture of AI innovations and a lot of clever game design.
FEAR is the first game to use an AI technique called automated planning: it’s heavily inspired by a system called STRIPS from 1971, which was originally designed to program robots – with modern-day planning systems now being used for the likes of Mars rovers. The game allows non-player characters (NPCs) to plan out their strategy at a very high level – where they’re going to go, where they go into cover, and whether they shoot at the player or throw a grenade. In planning, this means giving each character goals they want to satisfy. But in order for those goals to be achieved, you need to model all of the possible actions the character can do in the world. It can then make plans to achieve its goals by figuring out which actions glue together really well.
Each action has what is known as preconditions, which are the facts in the world that have to be true for it to happen, and effects, which are what happens when the action is executed. So if you see a character run over to an object and knock it down as cover, it’s because it planned out the movement, the knocking over of the object, and going into cover as three actions where all the preconditions and effects could line up. It can’t knock over an object that’s already knocked over, or run to an object it can’t reach, because the preconditions of the actions told the AI it’s just not possible.
But it’s not just a planner, once it comes up with a plan of attack, it then uses a finite state machine (FSM), much like Half-Life did, to put all the actions together. One of the clever things Monolith figured out is every action an AI makes in a game is a form of animation, be it standing firing a gun, moving to another location, or interacting with an object. So all of the plan actions are translated into three states: moving to positions, animating, or special animations with what are known as smart objects. It doesn’t matter how complicated the plan really is, it can always be distilled down to these three FSM states.
What’s crazy about is that they use the same AI for nearly every character in the game. The soldiers, the ninjas, and the elites in heavy armor. Even the rats use the planning AI, except all they plan for is how to run away from you. The only character that doesn’t use it is Alma, the haunting little girl from the story because she’s not part of the game’s combat experience. As a result, all of her interactions are pre-built and handcrafted by designers.
But the thing that FEAR also does really well, is that the developers knew when to use AI to achieve the intelligence they wanted, and when to just cover it up with clever hacks and tweaks. Like no two soldiers in FEAR know each other exists, but they look like they work together. That’s because the game tells two characters to satisfy goals that – when put together – look like they’re collaborating. So one character will fire at the player from the cover, while another will move to a location to the side of you. When those things happen together, it looks like a flanking maneuver, but they’re doing it entirely independently. The real trick that helps sell it, is the game makes them shout lines of dialogue to tell each other what to do, even though they can’t hear that dialogue or respond to it. It’s that little bit of spice that makes it look even smarter than it already is, and makes players feel like they’re against a ruthless team of soldiers.
Planning has been used in a variety of games since, with the AI of FEAR inspiring the modern Tomb Raider games, Total War, Just Cause, and Deus Ex. But it also lead to the introduction of another planning approach called hierarchical task networks (HTN). While it’s been used in games like Dying Light and Horizon Zero Dawn. HTN is a little more designer-friendly because you can not only design the actions but how actions might group together in ways that make sense. So instead of the planner figuring out running to cover and knocking it down is a good idea by itself, a designer can, for example, identify several actions that should be used in sequence to put an NPC into cover. It means the planner spends less time figuring out combinations that are obvious to players and builds more meaningful tactical gameplay.
Stick around for more of our History of AI series, plus if you want to learn more about the planning systems in FEAR, check out this video from the AI and Games YouTube channel that goes into more detail.