Revisiting the AI of Alien: Isolation
We revisit my most popular video of all time, with even more insights
AI and Games is a YouTube series made possible thanks to crowdfunding on Patreon as well as right here with paid subscriptions on Substack.
Support the show to have your name in video credits, contribute to future episode topics, watch content in early access and receive exclusive supporters-only content
Alien: Isolation left an indelible mark on artificial intelligence for video games. A game where the success or failure of its core premise relied heavily on players believing in the intelligence and cunning of its primary antagonist. If the design and implementation of the xenomorph did not stand up to scrutiny, then the game would have quickly collapsed in on itself. From a developer’s perspective now in 2020, there have been many exciting and novel applications of AI across the games industry - including many we've seen on this channel - but I don't think any other game has quite caught the attention and imagination of players in recent years.
It's a testimony to the hard work of everyone involved at Creative Assembly. And while I have previously explored the inner workings of the AI of Alien: Isolation, there are still many secrets left to uncover for developers seeking to replicate its inner working, or for players old and new as they attempt to escape the Sevastapol space station.
Recap
If you never read or watched my original piece, or need a recap, here's some of the key information you need to know about the xenomorph in Alien: Isolation. It's important to recognise there are two systems that control the alien. The xenomorph itself is controlled by whats known as a behaviour tree - a very common technique used in AAA video games to control non-player characters. I explain how behaviour trees work in episode 2 of my AI 101 subseries, so check that out if you need to know more. The xenomorphs behaviour tree can search the corridors of the space station, hunt down errant noises or investigate areas the creature is interested in. With specific behaviours such as searching lockers and crawling into smaller vents only activated after the player has repeatedly escaped its clutches using these methods several times, thus providing the illusion that the creature is learning. The behaviour tree is ultimately responsible for ensuring the alien hunts down and kills the player. But it has to do this of its own accord and rely on what it detect within the world from its own audio and visual sensors. However, this can lead to the alien either trapping the player in a corner of the map or completely losing you as you make a break for it. And that's where the second AI system kicks in.
The second system is an AI-director, much like that seen in Left 4 Dead and is designed to manage the pacing of the game. The director always knows not only the location of the xenomorph is, but where the player is as well. The directors job is to periodically tell the xenomorph to head towards the player throughout a given level. It never tells the alien exactly where you are, but advises it to head towards your general, and the xenomorph's behaviour tree will take it from there. This means that while the director is trying to keep you under pressure, the xenomorph still needs to hunt you down and kill you on its own merit. When the alien is wandering the corridors, this is whats known as frontstage. The alien is searching for the player either because the director told it to go that location or it heard something that caught its attention. Once the alien is in proximity of the player, the director maintains a 'menace gauge', which is designed to record the intensity of the creatures presence. The menace gauge increases at different rates depending on whether the creature is nearby and whether the player can hear it moving or actually see it in front of them. Once it reaches a threshold, then the alien will go into the vents for a time, known as backstage mode. During which it wanders the vents and potentially lays a trap for you.
This is all the core systems in a nutshell. But there are still so many unknowns about how the Xenomorph works, not to mention a lot of the other AI characters in the game, the Working Joes, the Facehuggers and the all the human characters be they friend or foe. Hence I was keen for this episode to dive deeper into the AI systems. But more critically begin to better understand the inner workings of the xenomorph itself. To do this I reached out to Matt Filer - a game developer based in the UK - who has developed OpenCAGE, a suite of modding tools named after the Creative Assembly Game Editor. OpenCAGE provides a variety of tools that allows anyone with the PC build of the game to manipulate the AI behaviour in the game, alongisde many other features.
As mentioned the xenomorph is reliant on a behaviour tree architecture for controlling its behaviour. In previous developer talks - and in my own video - it was highlighted that this was a rather large behaviour system. Thanks to the Filer's mod tools, we can actually look at it and spot specific aspects of its behaviour. However, it might be a little hard for you to see in the video. Y'see, the Xenomorph has 36 branches it can take from the root of the tree. This ranges from attacking the player to investigating disturbances that its sensors have detected, climbing in and out of the vents and fleeing from fire. But also some special tools and other secrets that hint at cut content from the game. In addition, Filer's tools expose several of the aliens sensory systems which are alluded to in the behaviour tree. Giving us a richer and more comprehensive view of the xenomorphs behaviour.
So let's take a look at some of the interesting elements of the aliens behaviour and new things that have come to light.
Sense
As mentioned previously, the xenomorph must hunt down and kill the player on its own. While the director always knows where the player is, the creature has to earn its kill. To achieve this, the alien has a variety of different senses, it has multiple modes of vision, it can hear noises within proximity and recognise their severity and also has some basic touch senses that allow it to recognise when the player bumps into it or its been hurt by gunfire or the flamethrower. But critically, the creature needs these senses to be working together in order to attack the player. There are three ways to guarantee the alien will sense and then try to kill you: either the visual or touch sensors say with absolute confidence that they register the player, or one of several sensors activate while you're in a crawlspace or similar hiding spot. And thanks to Filer's mod tools, you can essentially disable its vision sensors, making it blind - like you can see right here. The alien cannot see me right now, but its other senses are still active and it knows there's something nearby. Hence it's still a highly credible threat. So let's walk through how these senses work and what it needs to know before it can go for the kill.
Vision is the easiest way for the alien to register you as a target. For it's vision, the alien uses what is known as a vision cone or view-cone, where it can see in front of itself within a certain range, typically in the shape of a cone and registers when objects have been in the cone for a period of time. View cones are a very common technique for visualising how an enemy can 'see' something in the world, given they're easy to visualise and debug. In fact many games communicate whether they're being detected by a view cone, such as that in Splinter Cell or Far Cry while others such as Metal Gear Solid explicitly showing the view cone via the in-game HUD such that players can react to it accordingly.
All characters in Alien: Isolation, be they human, android or xenomorph have four different view cones. The normal cone for reading directly in front, which can see pretty far ahead, a tighter view cone known as 'focussed', which it uses when it's looking at specific objects or locations but within a shorter range, the 'peripheral' cone that is shorter in length but much wider, and lastly a cone called 'close' that is very short, but very broad and is designed to catch anything right next to it. Meaning you can't go crawling around sitting mere inches away dodging all of its other visual sensors.
Now the typical idea is that should the player intersect the view cone and there is nothing that would block the line of sight from the alien to the player, then in theory the xenomorph has seen you, but the sensor doesn't register the player as spotted immediately. The longer you stay in a given view cone, the signal from that visual sensor becomes stronger. Once that sensor reaches a certain value it enables certain paths within the behaviour tree to become available to the alien, because it most definetely can see you now. Now the strength of the signal from each view cone varies and will increase at different rates depending on which view cone the player is sitting in.
However, it's worth nothing that the vision of the alien and other characaters can be obscured based on light levels as well as smoke in the environment. In fact each view cone has modifiers that dictate how well the alien can see you in different conditions. Hence using the air purity controls on the space station is a very useful tactic, given it can help obscure the creatures view, even if it does limit your own! In addition, the light levels within a range of the map have a huge impact on the vision strength of humans and Working Joe's, but has - as near as I can tell - absolutely no effect on the xenomorph.
With all that said, the aliens next best sense is sound, where the creature can hear a variety of different noises at different strengths. Each sound you make in the game has a variety of strength levels. In a manner similar to vision, a sound being heard by a given NPCs is driven by activation thresholds, with weapon firing in particular scaled to trigger sensor activation much faster than other sounds. These sounds pinpoint the alien to a location to invesigate and if it is quite far away from the point of the side, it will run towards it rather than more gracefully walk. In the case of louder noises with stronger signals, this will also force the alien out of backstage mode to investigate.
Movement has three stages of noise, crouched, walking and running, and the noise generated and sound radius is quite different. Meanwhile weapons used, including even hitting your wrench on surfaces, will trigger the aliens interest and have a much faster rate of activation than movement. Loud sounds are very much the players enemy, given not only will they lure the alien to your location if it's out on patrol, they will also trigger the alien to leave its backstage mode in the vents and come down to investigate: so running around and especially firing a gun is a very bad idea. It will know exactly where that sound came from.
Now despite all this, there are some useful tips to take on board: each sensor detection has a rate of decay and the alien will eventually forget a specific sensory reading. Plus there are a handful visual and audio cues that - from what I can gather - have zero impact on the alien and other NPCs. This includes the opening and closing of lockers, doors and vents. But the important one to remember is the motion tracker: it only makes audible noise that other NPCs can hear within a very short radius. So if the alien is nearby while you're in a hiding spot, keep it stowed, otherwise it will hear it.
But like I said at the beginning, the alien can only attack if it can outright see you or you're rubbing yourself against it. So if you're being smart and hiding, then it checks against several sensors for activation. Many crawlspaces in the game are built by designers to ensure that either the alien can no longer see you, or it's chances of doing so are drastically reduced. That said, there are still ways to catch the aliens attention and its behaviour tree has a specific set of conditions for when the player is hiding. The easiest way is to accidentally turn on your flashlight. The flashlight has a scaled trigger and response activation compared to normal visuals. Hence you have to be very careful using it, given the alien will spot it almost immediately. Plus you can accidentally touch its body while hiding, make too much noise or expose yourself enough that the aliens vision sensors are registering you beneath a lower-than-normal threshold.
Now with the alien having seen you, it has a handful of final checks to make before it makes its move. This includes not being in a vent (unless its an ambush attack, which I'll come back to in a bit), having a valid path to its intended target on the navigation mesh, meaning can it reach you. But also whether it maintains the target in either it visual or combined sensor thresholds. Hence in theory, it is possible to escape the creature and once it no longer registers you, it will have to find you all over again. Not that I've had much luck doing that.
And speaking of surviving an alien attack, let's talk about it's extra special flame touch sensor! The flamethrower is your one true friend in many of the latter stages of the game, given while it can't kill the alien, it can sure as hell hurt it and scare it off. The alien distinguishes attacking a target - a human that has no weapon - as separate from that of an armed character, known as a threat. While the sensory conditions as mentioned earlier are the same, how it behaves differs in execution. However, the critical part is that it has a sub-tree for reacting to being attacked by the flamethrower and how it should respond.
The alien records whether it has previously interacted with the flamethrower and that influences how it attacks. Hence after its first interaction with the flamethrower, it approaches the problem in different ways in subsequent attempts. This ranges from merely hissing at the player for holding it at bay, to setting ambush attacks in the vents to trying to flank you to attack from different angles depending on the distance, so as to catch you off guard.
If it does make a move and you let lose some fiery rage, the alien has a separate touch sensor for recognising being hit by the flamethrower and once that reaches a threshold, it's going to force it to retreat, but not before it tries to take a swipe at you. The hit-and run sub-tree makes a quick calculation of how far away the player is and whether the path to them is occluded in any way, if it isn't the alien executes a hit-and-run where it smacks you to the ground as it makes a run for it. If those conditions can't be met, it will just run away. But all that said, you still have to be careful as this is all based on whether the alien is not too close. If it is within one unit of distance, it will just fight through the pain and grab you. So make sure you always maintain your distance before scorching the creature.
In any case, triggering the hit and run will cause the alien to retreat, typically into backstage mode. And on that note, let's take a look at the new things we've discoverd about the aliens front and backstage routines.
Menace
As mentioned earlier, the alien operates in two modes: front-stage when its out hunting you and backstage when it crawls around in the vents, giving the player a breather and allow you to progress.
When in either frontstage or backstage, the alien will move around the map in activity known as a Sweep. When backstage, the alien has parameters for how long it sweeps, the overall distance and the amount of time it will sit idle in the vents before sweeping again. You'll note that when the alien is in the vents it's capable of moving around a lot more freely than it does when it's on the ground. And that's because the air vents don't really exist and it can freely move around above the level, but only in straight lines. And when you hear those noises in the vents, it's not a fake out: the alien is actually still moving around. The alien jumping into a vent is an animation that, once completed, will disable the creatures renderer. So when you hear those movement sounds above you, it's because the alien is now invisible in the map and moving around and the sound effects are triggered in points of the world relative to where the alien currently is.
Now in amongst all of this ambushes: where the alien will sit in the vents and wait for you to swan idly by so it can pull you up into the rafters. Ambush flags are laced throughout the behaviour tree and allow for the alien to decide when it wants to go into an ambush. This can either be part of the backstage sweep where it shifts to an ambush or it might be as a result of a previous attack phase. In fact the previously mentioned hit-and-run will result in the alien setting flags that means it wants to either jump back out and attack you again as soon as it can, or set up an ambush in the vents. Each ambush has a set duration and after a time the alien will give up and move on unless provoked.
Once the alien climbs back out of the vent, the duration of the front stage sweep is tied within certain ranges defined by designers. This range means it's either shorter or longer with each separate instance, but still maintains the overall pacing by having it give up and go back into the vents periodically. Plus the distance of the sweep as it moves around the space is also constrained to within a certain region, so it won't wander off too far around the map in one sitting. It's tied largely to a region defined within proximity of the vent that it emerged from. In addition, there is an important distinction be made when the alien is simply wandering around - or sweeping - to when it is exploring an area based on a disturbance. As mentioned in the original article, when a sound is detected, the alien will go into a search phase, referred to within the codebase as 'stalking', you don't want the alien to respond to any disturbance that triggers a stalk, because one of the first things that happens in the behaviour tree is that it disables any intentions of withdrawing back to the vents.
When stalking there is a defined radius around the target location, and that radius changes between the first stalk and any subsequent ones. While these are largely random paths of movement and looking behaviours, the overall area within which it occurs shrinks. The stalk radius gets tighter on subsequent passes around the location as it tries to hone in on its prey. Sometimes the search area is more or less a circle, meaning the minimum radius to the target is zero, while in other cases is provides a protective range around the point of interest. Making the search area look more like a donut.
This same stalking behaviour can also be used to objectives within the game, meaning the alien will patrol around the location the player is trying to visit. That said, the objective radius is typically more donut shaped, meaning that the alien will avoid standing right next to that switch you've spent 10 minutes trying to reach.
Now the important thing to appreciate is that there are several different configurations of the front and backstage parameters that designers can switch to throughout the game. There are configurations for keeping the alien in vents where you can hear the alien moving around, it will lay ambush traps in the vents, but it won't come down to attack - the visit to Seegson Communications and the rogue Working Joes is a good example of this. Meanwhile other configurations are much more aggressive and the time spent in the vents is reduced by quite a bit. Judging from what we can see in the Alien Config Editor thanks to Filer's mod, there are at east 12 different configurations. Some of these configurations are designed for specific locations such as the Canteen in Solomons Habitation Tower and the vents in the Crew Expendable add-on, while others appear to be designed to be used at different phases throughout the campaign.
This also has a huge impact on the aforementioned menace gauge. The menace gauge has a collection of parameters that influence how frequently the alien is going to try and get all up in your personal space. This includes cooldown timers that prevent the alien from coming back for a certain amount of time, the time it takes for the menace gauge to peak before it tells the alien to leave and the overall number of times the alien can menace you before it returns to backstage mode. This is quite funny as it means the alien is counting the number of times it menaces you in one frontstage sequence, which I can't be think sounds rather cute.
Speed Round
As I start to wrap-up, here's some other interesting, often amusing and random bits of information I picked up along the way while researching this piece.
The alien has lots of branches for error catching, such as navigation failures, ensuring the alien does not get stuck in the geometry.
The alien also has a trigger to either backoff or despawn entirely if the game knows its going into a cinematic, a point I made in my last article.
The aliens senses are influenced by difficulty, with the novice difficulty reducing the aliens vision and responsiveness to movement sounds by over a third. Meanwhile responsiveness to weapon sounds is nerfed drastically.
The difficulty levels also have a huge impact on the aliens backstage mode, as the difficulty increases the xenomorph spends even less time in backstage mode, the menace gauge durations are increased and the patrol region relative to the player decreased.
There are debug tools for spawning or removing aliens from the game world for testing purposes, which I would love to play with.
Lastly, there is evidence of an AI lodding systems that was implemented but never actually used in the game.
If you're not familiar, lodding in video games is a process where we minimise CPU and memory resources based on the priority of an object. You typically hear about it in the context of graphics: were items are not rendered or textures run at lower resolution when an object is farther away to keep memory costs down. But it also applies to other in-game systems such as AI, where we want to make sure the AI is still making useful decisions but if they're far away from the player then those calculations are arguably less complex and use less CPU. In previous articles I've talked about lodding applied to the calculation of flight paths in Horizon Zero Dawn, as well as how Tom Clancy's The Division 2 ensures AI factions are still making decisions but using less of the servers resources when miles away from players. It's suggested that the alien would have had a LOD system for its decision making if it was very far away from the player, but it was ultimately scrapped and never used. Whether that was due to a shift in design or simply a recognition that it wasn't needed is open to debate.
And of course, other random facts about the other AI characters and systems in the game…
While the alien has the best vision sensors in the game, the human NPCs and the Working Joe's view cones are almost identical. However, human visibility is massively reduced in the dark while the Joe's only suffer a minor penalty.
Working Joe's have around six times the max health of the average armed human, while the Joe's you meet down in the Reactor have an extra 50% on top of that.
The alien technically has a maximum amount of health, but you'll never live long enough to deplete it.
The Facehugger has its own behaviour tree, it's not very big and 90% of it is managing edge cases where the game doesn't want a facehugger well… hugging yer face!
The armed human's can react to an armed player in several different ways. They can ask you to back off, stand their ground in a gunfight, or jump into cover.
Armed humans fight the alien and working joe's using a completely separate sub-tree, it has most of the same behaviour, but it filters out certain behaviours in the player sub-tree.
Working Joe's have a designated combat area and will give up trying to attack you if you manage to get far enough away.
Lastly, many of the AI characters - including the Joe's and the Xenomorph have a debug tool in the behaviour tree that would allow for developers to control them via gamepad.
Closing
Alien: Isolation continues to be a game that people celebrate and discuss five years after its original release. While the game is not without flaws, no other title I've explored on AI and Games has had such a visceral and primal connection with its audience and I hope your enjoyment and fascination with this game continues to stay strong.
References & Links
Special thanks to Matt Filer for his help in putting this episode together and of course for all of his hard work on the OpenCAGE project.
The original piece on the AI of Alien: Isolation