1

Squad Coordination in Days Gone
Tobias Karlsson

1 Introduction
Coordinating groups of AI-controlled characters in combat is a hard problem, made harderstill in an open-world game where the enemy can come from any direction at any time.
Solving this problem requires solving several more fundamental problems: deciding what
the group wants to achieve, identifying the best member for each required role, finding thebest position for members relative to both enemies and friends, and creating directionality
and focus for the engagement. All these decisions need to be taken in a timely manner, andthe group and its members must be reactive to the swiftly changing dynamics of combat.
This chapter explores the solution used in Sony’s Days Gone and how two comparatively
simple ideas, modelling a frontline and modelling the confidence of the individual groupmembers, were used to solve the problem of group coordination.
2 Overview and High-Level Organization
The world of Days Gone is a brutal one, where a virus has turned the majority of the world’s
population into rabid creatures called “Freakers”. Society has broken down and the few
remaining survivors have split into various factions, hostile to each other and the player.
These survivors take no chances and will attack on sight when they encounter any strangers,which results in desperate struggles. When this happens, multiple AIs must coordinate andfight as a unit to create convincing gun battles.
2.1 Decision Making and Responsibility
In Days Gone, the responsibility for taking decisions regarding coordination is divided
between the individual characters and the group, which is referred to as a “Squad”. Squads
are themselves full AI entities whose primary purpose is coordination. A Squad decides
what its members collectively are trying to achieve at any given moment, which role eachmember will be assigned, and the general location where those roles are to be executed.
While at the individual level, each member is responsible for executing its assigned role,
they also have the freedom to choose not to perform the role if they decide that the current
situation warrants a higher priority behavior instead.
A Squad-assigned role in Days Gone is a package containing an entire sub-behavior
that is slotted in at a predetermined point in the normal behavior hierarchy of the individual
AI. This means that higher priority behaviors naturally take precedence over the role. It alsomeans that when creating a new role, there is no need to modify our existing behaviors, wejust create the behavior needed for the new role.
The Squad’s decisions are driven by how likely its Squad members feel that theirside is winning the current encounter. This value is called Confidence, and when it goes up,
the Squad will take to the offensive, and when it drops, the Squad will be put on the

2defensive. The decisions of the individual AIs are also frequently affected by their
Confidence values.
2.2 Squad Creation and Assignment
Squads in Days Gone are dynamically created. Every individual AI that is valid as a Squadmember, is assigned to a Squad, even if that results in a Squad of one. To be a valid Squadmember, the unit needs to be of a type that uses Squads, and it cannot be performing ascripted behavior or otherwise be unable to act freely. Two valid AIs of the same faction,
within a maximum distance of each other, are on the same Squad. If those units belonged todifferent Squads, those two Squads are merged into one. Note that the AI does not need to
be within distance of all its Squad’s members, just one. This allows Squads to be strung out
in a line without breaking up. If two subgroups can be created from a Squad in which no
member of one subgroup is within the maximum distance of any member of the othersubgroup, that Squad will be split in two.

a

b

c

Figure 1
All the units in (a) are within distance of each other and will be on the same
Squad. In (b), one unit from the white Squad is within distance of a unit of the black Squad,
and the two squads will merge. In (c), the black units have strayed too far from the rest of
the Squad (the white units), and the Squad will be broken up into two new Squads.
During the game, Squads will often merge as AIs spawned apart are drawn into thesame battle, or occasionally be broken up by the terrain or the actions of enemies. Scripting
can also interfere with the makeup of Squad by spawning new AIs, starting scripted
behaviors, or otherwise making an AI ineligible to remain with its Squad.
3 The Confidence System
The Confidence System of Days Gone is central to its AI, and most decisions made by the
Squad, and many made by individual Squad members, are directly driven by Confidence.
Confidence expresses how confident a given AI is that its side will prevail in the current
encounter. Confidence is dynamically calculated, and is affected by several different factors
which changes with the fortunes of the AI and its allies. There are five levels of Confidence:
panicked, worried, neutral, confident, and heroic.
Squads do not have their own Confidence value, but instead rely on those of theirmembers. The Squad’s Confidence is calculated as the average Confidence of its members,
rounded towards neutral. For the Squad, the most important choices driven by Confidence
are when to press the attack, hold its ground, or retreat, though it also affects how the Squaddeals with other situations, like losing contact with the enemy.

3

3.1 Calculating Confidence
To calculate Confidence of an AI, first the quotient between the perceived strength of thefriendly side and that of the enemy side is calculated. The quotient is then compared against
predetermined thresholds to determine the effective Confidence of the AI.

Formula 1𝑠𝑥 + ∑
𝐶(𝑥) =𝑓∈𝐹

𝑐𝑓 𝑠𝑓 + ∑𝑘∈𝐾 𝑠𝑘∑𝑒∈𝐸 𝑐𝑒 𝑠𝑒 + ∑𝑙∈𝐿 𝑠𝑙

Formula 1 is a simplified outline of how Confidence is calculated for AI x. E is the enemiesof which x is aware, F is the friendlies (this can include allied units who are not part of x’s
Squad), K is the enemies killed by x’s Squad, L are the friends lost, si is the modified
strength of unit i, and ci is the Confidence-based modifier. Note that there is no Confidence
modifier for the character x, whose Confidence is being calculated. This is so that thecharacter is not influenced by its own Confidence, but rather its Confidence is a reflection of
how it sees its current situation.
A unit’s base strength is determined by how the faction of the AI viewing it values
that unit’s faction. This means that two factions can have different evaluations of the samecharacter’s strength. For instance, two factions could consider the other to be inferior tothemselves, resulting in both sides having high Confidence. Multipliers modify the basestrength based on the character’s armor, how deadly a weapon the character carries, andwhether the character is wounded or suppressed. When an AI is evaluating the strength of its
friends and enemies, their Confidence is also taken into consideration. A confident ally
boosts your own Confidence more than a worried one, and their strength is modified basedon their Confidence. This has a self-reinforcing effect allowing a few confident characters torally their Squad, while a few characters losing Confidence has the opposite effect, causing
their allies to lose Confidence as well. Conversely, seeing your enemy falter will boost yourown Confidence, while enemies that are confident in their imminent victory will make you
think twice.
A panic Confidence level is particularly infectious and will often spread to the entire
Squad, causing it to break, unless the rest of the Squad has very high Confidence tocounteract the penalty from their panicked comrade. To achieve this, a panicked character’s
strength is not added to their own side’s strength, but rather to their enemy’s. This further
boosts the enemy’s Confidence advantage, with stronger units having a correspondingly
more severe impact.
In addition to the individual strengths of the member, the strength of the enemies
killed by the Squad is added to the friendly strength, while the Squad’s casualties are added
to the enemy’s strength. If both sides trade blow for blow, these numbers will cancel eachother out, while lopsided casualties will reinforce the winning side, and undermine thelosing side. The kills and casualties also stay with the Squad after combat, so for example, if
a Squad encounters an enemy soon after it has been dealt serious casualties, the members ofthat Squad may have a low Confidence even if they are evenly matched with the new

4enemy. Both the effects of kills and casualties wane over time to prevent Squads from being
permanently suppressed, but on a timescale much longer than a normal combat encounter.
This allows Squads to recover if, for instance, they fight the player and the player breaks off
the encounter, only to return later.
3.2 Characteristics of the Confidence Calculation
The formula for Confidence might initially appear unstable as the value of anindividual AI’s Confidence is dependent on the Confidence of all its Squad mates, which inturn are dependent on that individual’s Confidence. This is not the case, and even insituations where an enemy Squad appears out of nowhere, Confidence converges quickly toa final, stable value after only a few updates.
For an AI to move from confident to heroic Confidence, the result from theConfidence calculation needs to exceed a corresponding threshold. This threshold is set
higher than the Confidence-based multiplier for confident, meaning that even if all Squadmembers just barely reaches confident, they will not automatically become heroic. Also,
Confidence cannot overshoot the Confidence an AI will eventually reach, assuming all
inputs stay the same. The only way for Confidence to overshoot would be if the calculation
resulted in a value that is higher than the final value, and that could only happen if someother Squad member’s Confidence has already overshot.
Confidence is never calculated if there is no enemy present, so there is no risk for adivision by zero. There is no upper limit to how large the value the calculation produces canbecome, nor how close to zero it can get. Since the value is translated into Confidence, theresult will top out at heroic, or bottom out at panicked regardless of how far the value
exceeds the threshold.
3.3 The Player and Confidence
Using the above calculations, the AI’s initial Confidence in an encounter is usually a good
indication of how it will end. Sometimes, a lucky grenade, or beneficial terrain can turn thetide, but more often than not, the side with lower Confidence will be losing andconsequently see its Confidence erode further, while the opposing side will see its
Confidence increase as a result of their success. Generally, this plays out well, and is thedesired effect in Days Gone. When the AI engages the player, however, a more dynamic
system is desired, and thus the player has additional factors that affect the AI’s Confidence.
When the player interacts with the AI, the desire is for the AI to act more passively
against an aggressive player, and likewise more aggressively against a passive player.
Allowing the player to take the initiative rewards an active playstyle that interacts more withthe game and gives the player’s actions greater impact. For instance, if the player attempts toflank the AI, the AI will often let that happen to give the player a small win, and therefore
encourage tactical movement on the player’s side. On the other hand, if the player remains
passive, the AI will try to pressure the player into action. The differences in playstyle affectthe AI’s Confidence in addition to the normal calculation. A stationary player will cause theAI’s Confidence to build over time, and even faster if the player is hunkering down in cover.
If the player is charging the AI, using melee attacks, or if the AI is the player’s aim assist
target, the AI’s Confidence will instead drop.

5

4 The Frontline
Positioning individual members of a Squad, as well as deciding which member is the mostsuitable for a given role, requires some degree of spatial reasoning. As Days Gone is an
open-world game, it is generally not possible to make a priori assumptions as to thedirection from which an enemy attack will come. This leads to a more general, and hencedifficult, problem compared to linear games, where scripting is a more tractable option given
the limited decision space.
For a combat scenario to present well, it is crucial that every character not only try to
defeat the enemy, but also respect and avoid their enemies’ space unless a behavior
specifically requires them to violate it. The key is to keep a distance to not only the enemy
unit directly engaged, but to all enemies, while also not straying too far from your allies tomaintain the integrity of friendly space. Having two sides intermixed also dramaticallyincreases the risk of an AI’s cover being invalidated, which can lead to cascading coverinvalidation if the first AI invalidates someone else’s cover while moving to a new cover,forcing that second AI out of cover, which continues the cycle.
Additionally, intermixing makes it much harder to differentiate the units and theirfactions, or to discern who is winning and who is losing. This makes it difficult for theplayer to assess the situation and in particular assign meaning and intent to the AI’s actions,which will erode the player’s impression of the AI. More ordered combat also provides theplayer with more tactical options. Unlike in a general melee, clearly separated opposing
sides allows for concepts like “flank” and “rear” to be readily identified. That gives theplayer the opportunity to, for instance, help shore up a weak flank, or attack the enemy in
the rear.
To solve these problems, Days Gone uses a special construct called a “Frontline”.
The Frontline describes the spatial relationship between a Squad and its enemies and is used
to answer all spatial questions needed to coordinate the Squad.
5 Calculating the Frontline
The information contained in the Frontline is used by the Squad to assign roles, and by theindividual AI’s to perform their behaviors. Specifically, this information includes:
1.
The identified direction of combat.
2.
A line representing the closest the Squad members can be to the enemy (thiscreates and preserves separation between the two sides).
3.
The width of the Frontline.
4.
A Neutral Area that defines a space that is off-limits to the Squad, and it exists asa buffer in front of the area controlled by the enemy.
5.
The area controlled by the enemy.
Figure 2 shows an example of a Frontline with many of the above concepts illustrated.

6

NeutralArea

Enemy controlled area

Figure 2
The anatomy of the Frontline. Circles denote friendly units; squares represent
enemy units. The thick, black line is the closest the Squad’s members may advance to theenemy.
The direction of the Frontline is determined by the direction between the Squad’s center ofgravity to the enemy’s center of gravity. The centers of gravity are calculated as the averageof the position of all eligible Squad members and enemies respectively (see below for what
eligible means in this context).
The width of the Frontline is used to determine how wide the Squad members may
spread. This is calculated as the maximum of the distance between the two furthest enemies
projected on the Frontline plus a fixed margin on either side, and the distance that you would
get if you lined up all Squad members abreast separated by a minimum distance. This meansthat if the enemy is spread out, the Squad can spread out to meet them, but if the enemy isconcentrated, the Squad will close ranks, while still ensuring that every member has enoughroom to maneuver (see Figure 3).
ab

Figure 3
The width of the Frontline in (a) is determined by the enemy as they are
spread wide. The width of the Frontline in (b) is using minimum width determined by the
number of Squad members as the enemies are grouped closely together.
The Neutral Area is the primary mechanism for separating the Squad from its
enemies during combat. It extends from the closest enemy to the Squad against the direction

7of the Frontline and defines an area that no Squad member should ever enter. When a Squadmember repositions, they may go up to the edge of the Neutral Area, but no further.
The Frontline can be operated in either “close” or “far” mode. In close mode, whichis the standard, the depth of the Neutral Area is fixed. The depth is chosen so that a Squadmember fighting an enemy over this distance does not look to be unreasonably close. In thismode, if the enemy moves away from the Squad, the Frontline and the Squad will be pulled
along, and likewise if the enemy moves closer, the Squad will be pushed back.
Far mode, on the other hand, is used to keep the Squad members in a specific placeby extending the Neutral Area to prevent the Squad from advancing towards the enemy.
This is used in situations when the Squad only wants to defend itself, or the area it occupies
and is not interested in pursuing or attacking the enemy.
ab

Figure 4
Close (a) versus far (b) mode. In close mode, the Neutral Area extends a
fixed distance from the nearest enemy, while in far mode, it extends all the way to thenearest ally, preventing the Squad from closing on the enemy.
The area controlled by the enemy is simply computed by creating a box starting fromthe far side of the Neutral Area and extending it a fixed distance past the enemy furthestfrom the Frontline. This area is primarily used during flanking (see below).
5.1 Lanes
In combat, Squad members need to avoid bunching up so that they do not get in each other’sline of fire. To achieve this, the Frontline is divided in to rectangular segments called“Lanes”, one for each Squad member. The Lanes are created by dividing the width of the
Frontline with the number of Squad members, and then extending them backwards from the
Frontline (see Figure 5). Squad members are each assigned a Lane in a manner thatminimizes the overall distance the Squad members will have to move to get into theirrespective Lanes. The assigned Squad member also determines how far back its Lane will
extend from the Frontline, as each individual has a maximum distance that they are allowed
to be from the enemy they are engaging. Once assigned, an AI will try to find a good spot tofight from within its Lane if possible. Using the Lanes together with the Frontline causes the
AI to naturally distribute along the front, and because they must stay behind the Frontline,
the direction of combat is easy to read for the player.

8

Figure 5

Lanes extending backwards from the Frontline.

6 Using the Frontline
The purpose of creating the Frontline is to facilitate combat behaviors, to simplify theirimplementations, and to improve their observable quality. In Days Gone, Squads in combat
are in one of four states with corresponding behaviors:
1. Forming up along the Frontline when one or more Squad members are out of
position.
2. Engaged in normal combat, which means they try to maintain their desired distanceto their enemy, but otherwise will not try to alter their position relative to the enemy.
This is the default, and is used when Confidence is neutral.
3. Trying to disengage from the enemy and retreat. This is used when Confidence isworried or lower.
4. Trying to press the enemy by attacking aggressively. This is used when Confidence
is confident or higher.
For all these behaviors, finding the right place to position the Squad members is
crucial. The Frontline is used to identify the best space for various behaviors, while othersystems that evaluate positioning and covers are used to find the exact position for each
Squad member.
6.1 Forming Up
If one or more members of the Squad are not in position behind the Frontline (flankers are
an exception, see below), the Squad must first form up. Squad members can be out of
position when a Squad has just spotted an enemy and enters combat, but also frequently
during combat. For example, members may find themselves out of position if new enemies
or allies appear, if an AI has finished a role that moved it out of position, or if the enemy
moves far enough triggering the Frontline to move accordingly.
While the Squad forms up on the Frontline, any member that is already in a good
position will attack the enemy, trying to provide cover fire for the other members of the9Squad and hold their positions. Members not in position will move to join the rest of the
Squad by running straight towards the Frontline when safe, while otherwise moving fromcover to cover and potentially firing at the enemy between moves.
6.2 Normal Combat
In normal combat, the Squad tries to maintain a good fighting distance to the enemy. The
Squad’s members will take up positions behind the Frontline and the Squad will only move
if the Frontline moves, which results in the Squad countering its enemy’s movements.
6.3 Retreating
At times, the AI will be overwhelmed by their opponents and will try to retreat. Whenretreating, the AI uses the Frontline for deciding both the direction of retreat as well as
which Squad members should retreat first and which should provide cover fire.
Determining the direction to retreat in is trivial with the Frontline. The Squad wants
to retreat away from the enemy, which is the negative direction of combat. Each AI
attempting to retreat searches for a new position to fight from that is directly away from the
Frontline. Since a retreating AI is vulnerable, the distance they move is relatively short to
reduce their exposure to enemy fire. AIs retreat in waves, with half of them moving back to
a new cover, while the other half provides cover fire. The AIs that are closest to the
Frontline, or who do not have valid cover, are chosen to move. Once a group of retreating
members have moved, the process is repeated. As a result, a Squad that is grouped together
will have its members retreating in alternating waves. A Squad whose members are spreadout, however, may repeatedly pick the same members to retreat until the Squad coalesce.
A Squad will retreat until an obstacle prevents it from moving any further, it regains
its Confidence, or it loses contact with the enemy.

Figure 6
White members are chosen to retreat away from the Frontline, while darkgrey members provide cover fire.
6.4 Pressing Attack
When a Squad is confident that it can beat its enemy, it will go on the offensive. First, the10

Squad will try to close the distance to the enemy. The process for advancing towards theenemy is much like the process for retreating but in reverse. Squad members that are farthestfrom the Frontline are chosen to advance, while the remaining AIs provide cover fire.
Once all Squad members are close enough to the enemy, some are selected to flank.
The AIs furthest away from the center of the Frontline are the first chosen to flank in orderto minimize movement. Flanking is done by finding a position either to the left or the rightof the area controlled by the enemy, and the choice depends on which is the closest to theselected AI.
In Days Gone, there is nothing preventing flanking attempts on both sides of theenemy at the same time, but flankers always leave an opening at the rear to allow theirenemies an opportunity to retreat, which allows for more dynamic combat.

Area to find flanking position in

NeutralArea

Enemy controlled area

Figure 7
White member is chosen to flank the enemy, and will search for a good
position off the nearest side of the enemy controlled area, while dark grey members are
pinning down the enemy.
7 Frontline Intricacies
Since such a large portion of Days Gone’s AI’s behavior is driven by the Frontline, thequality of the Frontline greatly impacts the quality of the AI’s behavior. The basic conceptof the Frontline is deceptively simple, but when put into practice, great care has to be takenwith the calculation to get the best results.
7.1 The Problem with Change
AIs in Days Gone use the Frontline to determine the validity of their positions. Every time aposition is invalidated, the AI is forced to find and move to a new position. A quickly andfrequently changing Frontline can disrupt the AI, causing a lot of unnecessary movement,

11which in turn makes the AI not only look indecisive but spend all its time moving instead offighting. Similarly, a Frontline that does not react to the enemy’s movement may leave the
Squad in a vulnerable position, or cause it to lose contact with a retreating enemy. Thus, alarge part of the code for updating the Frontline is devoted to ensuring that the Frontline
updates in a way that creates realistic looking behavior.
Days Gone contains several different types of AIs, a number of which have uniquebehaviors that are not well-suited to be part of the Frontline. These includes snipers who,
under normal circumstances, are confined to small sniper perches and are only expected toengage in very long-range combat. If they were added to the Frontline, their lack of mobility
would prevent the Frontline from moving when needed. Other AI’s, called “rushers”, arearmed with either melee- or short-range weapons, and try to rush their opponents to getclose to them. If rushers were added to the Frontline, they would cause significant disruption
both to their own Frontline, as well as those of their enemies due to their fast movement anddisregard for their enemy’s space. Thus, these types of AIs are not added to Squads, and are
ignored when the Frontline is calculated.
Another important technique that significantly reduces unnecessary movement is toprevent the Frontline from updating and moving in response to every little change in Squadmember and enemy position. Instead, the Frontline only updates if the difference between
either its current and new position or current and new direction is over a threshold value.
AI’s fighting from cover can also introduce small movements. The position used
when attacking from cover often differs somewhat from the position used when hunkered
down. For instance, an AI attacking from a high cover may need to take a step to the side to
get a clear line of sight to its target. It may seem like a small change, but it could be enoughto shift the Frontline so that an AI that was just on the edge ends up in an invalid position.
For this reason, AI’s in cover are always considered to be in the position of their cover slot,
regardless of their current action and position.
7.2 Dealing with Flankers
Not only can certain types of AIs be disruptive to the Frontline, but AIs that would normallybe good candidates to include in the Frontline calculation sometimes become poor
candidates due to their current actions. In Days Gone, the only such action is flanking. Whencalculating the Frontline, both friendly and enemy flanking AIs are ignored. If enemy
flankers were not ignored, the Squad’s Frontline would just shift away from the flankers,
causing the Squad to retreat and never be flanked. While this might sound like the proper
response to being flanked, the goal is to create “good-looking combat” rather than the “mosteffective behavior”. Allowing the Squad to be flanked for a while as the result of a
successful flanking maneuver is rewarding to the player when the player is the flanker, andmakes the AI look intelligent and dangerous if it successfully flanks its enemy. Hence, theAI let the enemy flank their Squad for a set amount of time, before reacting to the situation.
Once the time limit on an enemy flanker has expired, they will be considered once
again when the Frontline is calculated. This will cause the Frontline to move, which in turnwill make the Squad reposition away from the flanked position, causing the flanker to lose
its status as a flanker. When that happens, the flanking Squad may still want to press theattack, which will trigger a new flanking attempt, causing the behavior to repeat.
A friendly flanker is either a character that has been assigned a flanking role, or one

12that is in a position flanking the enemy-controlled area. Identifying enemy flankers, is a bit
more complicated as the AI could be fighting the player, or multiple enemy Squads at once
and there is no guarantee that the Squad’s Frontline aligns with those of their enemies. To
classify an enemy as either a flanker or normal enemy contributing to the enemy center ofgravity, a simple clustering algorithm is run on all enemy characters. The cluster with themost members is selected, and all its members are added to the enemy center of gravity,
along with any clusters that have at least a certain fraction of the largest cluster’s number ofmembers. Using this center of gravity, we calculate a tentative direction and closest enemy.
Any cluster that is not yet added, but is behind this tentative front, is also added to the centerof gravity. Members of the remaining clusters are marked as flankers, if they are not soalready, and given a time stamp. Finally, any enemy already marked as a flanker will havetheir time stamp checked, if they have been a flanker for too long, they are also added to theenemy center of gravity.
This approach allows the Squad not only to let itself be flanked, but also to react tomovement of a significant subset of the enemy or to large new groups of enemies appearing
as large enough clusters are always added to the center of gravity of the enemy, and nevermarked as flankers.
7.3 Adaptive Update Rate
Another technique employed in Days Gone to further reduce fluctuation in the Frontline is
to use a sliding window average to update values. In other words, the Frontline can gain
only a maximum percentage of its new value per second. This results in smoother movementof the Frontline as well as limiting short-term oscillations. The drawback of this approach isthat the Frontline becomes sluggish and unresponsive when significant changes occur. For
instance, if the enemy were to run past the Frontline, and stop on the other side of the Squad,
the Frontline should be inverted. To solve problems like this, the Frontline measures how
much the new values differ from the old, and the larger the difference, the quicker the moveto the new values become.
7.4 Ghosts
As mentioned above, AIs that are identified as flanking are not counted when the Frontline
is computed. Though this has the desired effect of preventing the large movement of theflanking character from affecting the Frontline, the removal of that character from thecalculation can also affect the Frontline in undesired ways (see Figure 8a and b).

13

b

a

Figure 8(a) shows the situation before the circular white AI tries to flank the enemy.
(b) shows what happens to the Frontline once the white character is no longer counted, theFrontline shifts and rotates as the center of gravity of the friendly forces shift.
To counter this problem, each AI that is flanking leaves a ghost behind in the Frontline.
When the Frontline is updated, that ghost’s position is used in the Squad’s center of gravity
calculation instead of the AI’s actual position. This provides stability to the Frontline (seeFigure 9).

Ghost position

Figure 9
A ghost is left behind as the white AI is flanking, making the Frontline retain
its position and direction.
Ghosts cannot move once they have been added, which can cause strange looking artifacts if
the combat moves on. For this reason, ghosts are cleared whenever the corresponding AI
rejoins the Frontline, dies, or leaves the Squad for some other reason. Ghosts are also
removed if the Frontline’s position or rotation shifts over a threshold value compared towhat they were when the ghost was placed.

14

7.5 Player Movement
Frequently in Days Gone, the sole enemy facing a Squad is the player. Unlike the AI, theplayer cannot be made to respect the Neutral Area or the Frontline and is also able to movevery quickly compared to the AI. If the player is the AI’s lone enemy, the player’s positionis always the enemy center of gravity. Thus, an aggressive player can quickly and repeatedly
trigger drastic changes to the Frontline, causing the AI to constantly reposition rather than
attack their enemy. To mitigate this, the player is treated as a special case: if the AI detectsthat the player is moving at more than a certain speed, the AI simply fires at the player while
waiting until the player stops moving before repositioning if needed. This works in Days
Gone, as shooting on the move is very difficult for the player while shooting at a moving
target is not that difficult for the AI, forcing the player to either take cover or close to melee
range.
8 Designer Direction
Although having a powerful AI that acts well in most circumstances greatly reduces theneed for scripting, there is often context that the level designers have created that is hard toautomatically detect. To this end, there are several types of markup available to thedesigners.
8.1 Defend Zones
Defend Zones are used to mark up the AI’s area of operation. This is where the AI prefer tobe during combat, and can be thought of as the AI’s territory. AIs assigned to a Defend Zone
ignore the normal rules for Squad assignment and are automatically placed in a special
Squad for the AIs assigned to that Defend Zone. Thus, designers can use Defend Zones as away to group specific AIs together in the same Squad.
Each Defend Zone has a binding strength that determines how uncomfortable the AI
is leaving their Defend Zone. Apart from the strongest binding, all binding strengths allow
the AI to exit their Defend Zone but limit how far they can go and for how long they canstay outside. These softer edges avoid many behavioral problems and artifacts that can occur
at the borders when the AI is prevented from moving across an arbitrary, invisible line.
The mechanic used to control the AI’s movement outside the Defend Zone isConfidence. As soon as the AI leaves its Defend Zone, its Confidence starts ticking down at
a rate determined by the Defend Zone’s binding strength. At first, a confident AI will
advance out of its Defend Zone in pursuit of its enemy, but over time, the Confidence
penalty will grow, and the AI’s confidence will drop to neutral, which will prevent it fromadvancing further. Eventually, its confidence will become low enough that it will trigger aretreat. The direction of this retreat is biased so that it will always take the AI back to its
Defend Zone. Once back, the confidence penalty will decrease and eventually the AI will goon the offensive again if still engaged. Clearing the Confidence penalty over time prevents
the AI from immediately leaving their Defend Zone after they have retreated to it, stoppingthem from yo-yoing back and forth.
8.2 Home Areas
As described above, a retreating Squad will normally move directly away from the15

Frontline. Though this pattern of retreat is reasonable in many cases, there is frequently
more context to why the AI is fighting in a given location. The AIs may be trying to defend
their base or prevent their enemy from capturing a resource that they are guarding. In thesecases, retreating from the enemy and leaving what the AI is fighting for behind makes lesssense. To help the AI understand circumstances like these, the level designer can add aHome Area.
A Squad with a Home Area always tries to orient their Frontline so that the Home
Area is at their backs. Exactly how much of an influence the Home Area has depends on the
distance, and the closer the Squad is to its Home Area, the stronger the influence. If close to
the Home Area, the friendly center of gravity is ignored and completely replaced by thecenter of the Home Area. Further away, the Frontline is allowed to deviate more towards thefriendly center of gravity. The Frontline is never allowed to rotate 90 degrees or more awayfrom the Home Area, however, so that the AI will always get closer to it when retreating.
In case the enemy is ever between the Squad and its Home Area, the same
computation applies, but the direction of the Frontline is inverted so that it points towards
the Home Area. When this happens, the AI is no longer allowed to retreat, and is allowed topress the attack even at neutral Confidence.
If the Squad is pushed all the way into its Home Area, it is also no longer allowed toretreat, effectively making the AI take a stand in their Home Area.
Home Areas are complimentary to Defend Zones, and most Home Areas in Days
Gone are placed inside a Defend Zone.
8.3 Fortification Zones
Sometimes, levels have strong points or choke points which are particularly advantageous tofight from if the enemy is attacking from a given direction. The level designers can informthe AI about these areas using Fortification Zones, which consists of a volume called a “KillZone” and an area called a “Fortification Area”. The target of an AI assigned to theFortification Zone is tested against the Kill Zone. If the target is inside the Kill Zone, thenthe AI will move to the Fortification Area and fight from there (see Figure 10).

Kill Zone

Fortification
Area

Figure 10
The Fortification Zone is valid if the white circle AI is fighting the whitesquare enemy as it is inside the Kill Zone. The Fortification Zone is irrelevant if the target isthe gray square enemy instead. Note that the Kill Zone isn’t directly attached to theFortification Area, and it is often the case that if the enemy gets too close, the fortification

16

should be abandoned.
While Fortification Zones more directly control the AI than any other method described inthis chapter, they also have a number of constraints to make them safer and less likely tocause scripting bugs than direct scripting commands. The most important factor is how theKill Zone can be placed. The Kill Zone, and hence the Fortification Zone, is directional,
meaning it is impossible to place a single Fortification Zone that blankets an entire level, oris applicable 360 degrees around a given position. This simple restriction forces the designer
placing the Fortification Zone to consider the circumstances in which it is valid.
An AI can be assigned to multiple Fortification Zones at the same time and will pickthe closest one available. An AI assigned to a Fortification Zone can also be assigned to a
Defend Zones, in which case if the Fortification Zone is valid, it will override the Defend
Zone and allow the AI to exit the Defend Zone if the Fortification Area is outside of it.
Finally, an AI that has a valid Fortification Zone is no longer a valid Squad member.
9 Conclusion
Coordinating groups of AIs in an open, dynamic world is a complex and difficult task. Using
the comparatively simple concepts of Confidence and the Frontline, a dynamic and capable
AI was created that can handle the complexities of Days Gone’s rich, dangerous, and everchanging world. In addition, the ability to use world markup that integrates andcomplements the system allows for an AI capable of being employed in a wide variety ofsituations to create exciting and convincing combat scenarios for the player to enjoy.