You are on page 1of 11

1

Research on the AI design in open world games

Table of contents
Prelude

pg. 3

- What we have now


- Goal
C.1 Case Study

pg. 4

- Case
- Case study
- Observation
- Parallel

pg. 5

C.2 Desk Research

pg. 8

- Modern AI design
- The AI design of Shenmue

pg. 9

C.3 Conclusion

pg. 10

- Future Improvement
Add. Reading list

pg. 11

2
Research on the AI design in open world games

Prelude
In preparation of the full-scale(post vertical slice) production of Baraka it was noted that there was a
distinct lack of direction as it pertained to the AI system used in Baraka. As such a short but thorough
research is needed; as presented in this paper. This paper was meant as a short study of AI systems
in other, comparable games in order to give the information required to make informed decisions
about the design of the AI system in Baraka.
This system is preliminary. If, in a later stage of development, it is discovered that the system simply
does not work, the system has to be changed and possibly completely overhauled.
What we have now
When work was started on Baraka, it was thought up to essentially copy the system that Assassins
Creed used, simplifying it as much as possible. Simply put, agents (also called NPCs, civilians or
pedestrians) walk on a network of nodes, one put on every street corner. Every node is then supplied
with a list of other nodes that this node connects to (called neighbours). Every civilian walks from
node to node, choosing a neighbour of the node if it is reached.
Later on this system was expanded with a system that despawns agents if they walk too far away
from the player, and a system that re-uses these despawned NPCs (essentially by moving them closer
to the player).
NPCs popping into existence was also a problem. At first the problem was solved by checking if the
NPC is in view (visible to the camera) when spawned, but this turned out to be way to heavy on the
processor and as such could not be used. Later, a whole new system was made, using tangents and
pure math (no actual mesh Line-of-Sigh/Raycast checks) which is in use now.
When the player fires a gun and when someone dies, a bubble is spawned onto of that position.
When an NPC walks into such a bubble, they will turn around 180 degrees and run for 100 meters
before returning to the walk state. This often gives bad results such as NPCs running off cliffs or into
the river, or NPCs getting stuck in walls/running up against walls. There are more, smaller problems
but this is the main problem of the current design.
Goal
The goal of this research paper is first and foremost to find out whats best for Baraka. To do this, Im
studying other games in the genre, and investigating other games that sport a mass AI system of
some kind. The result will hopefully be such, that it does not only provide answers to the questions
and problems presented above but also give new perspective on the design of the overall AI system,
and possibly even give whole new ideas that otherwise wouldnt have been thought of, factors that
otherwise wouldnt have been considered. Criticism against open world games is often that their
worlds dont feel alive. Not long ago, it almost seemed like this living world buzzword was used so
often that actually having it in your game seemed like some sort of quest for replay value. A
secondary goal of this paper is to come closer to what having a living world actually entails beyond
just buzzwords.

3
Research on the AI design in open world games

Chapter 1: Case study


The first part of the research consists of a case study. In this case study we investigate an already,
finished product in an attempt to reverse engineer the systems used to fake illusion of walking
around in a living city, that exists without the players interference. Keeping the limitations of last
generations hardware (Xbox 360 and equivalent) in mind, we know that actually doing this
simulating an entire city at the same time is improbable.
Case
The game were looking at is Electronic Artists The Saboteur. This game was
chosen because of the striking similarities between The Saboteur and
Baraka. The style and age of the game (older algorithms are easier to
replicate) were also taken into account.
The actual case study was done by observation: following civilians around as
they move through the streets, watching the reactions of civilians as they
pass by street vendors, watching the civilian react to explosions and
observing when civilians spawn and when they despawn.
Observation
It appears there are three states the civilians find themselves in: the first, and most common, is the
walking state. It is when the civilian is walking down the street, moving from node to node, much like
the system Baraka has in place. This system appears to be common among open world games and as
such is a trope of sorts.
The second state is the fleeing state. The civilian will flee when he hears an explosion or sees anyone
committing violence. This does not have to be the player; soldiers will occasionally hit civilians too,
when they bump into one another. Because of this, civilians sometimes run at you for apparently no
reason. In the Saboteur, the civilians are supposedly on your side and as such do not react to the
player pulling out a gun, but they do respond to the gun firing. When a fleeing civilian bumps into a
civilian that is not fleeing, the civilian that is bumped into will flee as well.
The third state is the action state. Sometimes, when civilians walk by street merchants, they will stop,
look at the wares for some time, and walk off. Civilians also walk around only to stop to sit down on a
par bench, or lean against a wall. Once they enter this state, they do not appear to leave it, unless
they are put in a fleeing state.
When civilians bump into each other, they, instead of playing a bumping animation and walking on,
tend to stand there for a second and talk to each other, before walking on. The conversations are
either in French or English, the French conversations usually making little sense How are you?
being replied to with Good Afternoon.. The German soldiers also talk to each other (in German),
and to the player, and those conversations make little sense as well( Germans asking for papers at a
checkpoint after just showing them and the gates having been opened).
Not all civilians move around. Some, like the street merchants mentioned earlier, do not move on
their own. This is comparable to civilians sitting on benches, with the difference being civilians never
seem to enter the state of tending to such a shop. They are spawned like that.

4
Research on the AI design in open world games

A civilian browsing a street vendor (but never buying anything)

Civilians spawn some distance away from the player, never close to him. The distance between the
player and a civilians that spawns is about 100-150 meters. Civilians that are further than 150 meter
from the player despawn immediately. This distance is slightly larger for cars, presumably because
cars are larger. The spawn/despawn range seems to increase as the player looks down the scope of a
sniper rifle, with civilians popping in and disappearing as the player zooms in and out.

Left: normal, Right: Looking through scope

Parallel
For a more broad perspective on design tropes, I decided that it was a good idea to take a quick look
at other similar open world games as well. I did this with two games: Mafia 2 and Assassins Creed.
Mafia 2:
Mafia 2 appears to be using a system that is very similar to that of the Saboteur. Pedestrians walk
from point to point, stop by street vendors (to buy newspapers, for example) and run away or cower
when the bullets start flying. Big Difference that the player can also buy from some of these vendors;
the player can get his shoes shined, which does nothing in gameplay terms, but helps to increase
immersion. The player can also enter many buildings, while in The Saboteur most buildings cant be
entered. In these buildings, for example clothing stores (which is a planned feature for Baraka, too)
or diners, civilians will never move. Even when shot at they will cower in place. They will spawn in
this state and will never leave it, so they are in that regard no like other normal civilians.

5
Research on the AI design in open world games

Left: The player getting his shoes shined, Right: A pedestrian buying a newspaper

Assassins Creed
Assassins Creed also uses a system that is very similar to that of The Saboteur. This is no surprise,
keeping in mind that Barakas original system was based on that of Assassins Creed. Assassins Creed
is also the oldest game in this list, and it shows. Out of all games, Assassins Creed seems to have the
least number of pedestrians walking the streets, having a very limited amount of interactions.

As you can see on this picture, there are only 6 real Pedestrian NPCs in the screen. The majority of
NPCs are actually forming a static crowd, which is not nearly as expensive as creating a moving
crowd. Keeping in mind that civilian #6 in the picture is a beggar (as described below), designed to
harass the player, you can see that the civilians actually walk in straight lines, kind of like a train
would. This refers back to the node based navigation network that the other two games also used,
but in those games the NPCs walk near the lines, and not on it.

6
Research on the AI design in open world games

In fact, this `large static crowd trick is used quite often. Because of this, the cost of the sheer amount
of pedestrians (customizable in the options menu up to 105 NPCs, which is double what Baraka has
now) is greatly reduced. These static NPCs will flee if provoked, and also count against the maximum
NPC limit.

Left: Civilians standing near a salesperson, Right: Crowd standing near public speaker

This system is somewhat comparable, with the difference being most NPCs will never change states
and more NPCs group together, where in The Saboteur, at most, a single NPC would be browsing the
wares of a street seller. In the Saboteur this NPC leaves after some time, but in Assassins Creed they
do not. Also note that in none of these three games you can actually buy from these street
merchants.
It should be noted that when you fire a gun, or kill an enemy, you provoke the pedestrians on the
sidewalk. With that I am referring to a crowd of NPCs breaking up and fleeing in panic. In both Mafia
2 and The Saboteur, it seems like the NPCs use real-time path finding to run away from you. In
Assassins Creed, NPCs run away too but they still seem to use the same node network used for the
walk state, the exception being the node furthest from the player is chosen. In Assassins Creed,
NPCs keep running until they despawn, while in the other games they stop running after some time.
A feature that Assassins Creed does have that Mafia 2 and The Saboteur do not have, are civilian
NPCs that directly engage with the player. In paper that sounds like a cool idea, but in reality I am
talking about beggars and madmen. This idea is novel though, and gets old pretty fast before actually
getting annoying. The idea could potentially work but needs more thought.

7
Research on the AI design in open world games

Chapter 2 - Desk Research


A desk research is a form of research that is done by looking at talks, discussions, data and opinions
of others. A list of the works referred to can be found at the end of this paper, in the Reading list
addendum.
Modern AI design
Most modern open world games use similar AI systems. Like the current system in Baraka, AI agents
walk from node to node. More advanced games, like Saints Row 4, use modular systems; all AIs use
the same base code but it is the specific code fragments that really specify the behaviour of these
agents. These fragments are highly reusable, such as specific code for aliens, police agents, gang
members, et cetera. Other systems, like police road blocks, are generated on the fly.
One interesting note is that Saints Row has a
system where Line-of-Sight checks/Raycasts
are done on separate processing threads in
order to be able to use hundreds of them at
the same time. It is sad that Unity does not
support this, seeing as Raycasts can only be
called from the main thread, but this could
potentially be a huge gain for the CPU
performance for Baraka. Note that these
checks are not done immediately; requests are
made, then later done by the background
threads (which do not run synchronously with
the main thread), done in order of request.
Example of a 20x increase in Line-of-Sight performance
(15 vs. 0.75 seconds)

A popular modern method of handling mass AI is a system usually referred to as GOAP: Goal
Oriented Action Planning. With GOAP, every NPC has a list of goals, some finite (kill X, collect Y),
some infinite (defend X, patrol between Y and Z). Because of this, every NPC has multiple things he
could be doing. In the background, a planner algorithm then calculates the fastest option of
completing each goal by giving every action a cost, such as walking (distance in meters) and attacking
(distance from the target + set cost of attacking). The cost of attacking depends on the weapon
carried. This way, an NPC wielding dual swords has a lower cost for melee attacks and is much more
likely to do that.
The cost of the fastest way of completing each goal is then compared, and the option with the lowest
cost is chosen. The NPC will then act on that plan until the planner thinks of a plan with a lower cost
or until the plan is completed. Some goals can be prioritized, such as patrolling between two points,
internally lowering the cost of that goal making it more likely for the AI to pursue it. The Game
Shadow of Mordor has expanded this even further: It uses GOAP, but also assigns specific roles to the
AI. For Example: if a patrolling squad of Orks comes across a corpse, the entire squad will move over
to the corpse, while one of them investigates, the others watch his back. If a single Ork comes across
the corpse he will investigate too, and if another comes across it he will watch the other Orks back.
Any further Ork will then disregard the corpse immediately.
These last few years, especially before GTA 5 came out, there has been much criticism about many
open world games. These are usually levelled to open world games where there is no real gameplay
8
Research on the AI design in open world games

aside from the storyline and occasional run-ins with law enforcement. Games Like Mafia 2 are said to
have no real activities outside of those meant for making money and even then, the money cant
be spend on much of anything. Mafia 2 does have shops in the game but since half of these shops
(clothing shops) are part of the game mechanics (changing appearance lowers wanted level) these
are a necessity and not a commodity. Even Middle Earth: Shadow of Mordor has been called
repetitive over time. In Lonely planet: the solitude of open-world games when the story is over,
an opinion piece published in The Guardian, writer Keith Stuart expresses his boredom with the
game, even though the games revolutionary Nemesis system was supposed to fix that.
There is hope, however. Games like GTA are still being played an masse, and aside from that one
well-funded, hyped-up superfranchise there are many more Open World games that are being The AI
design of Shenmue
Shenmue is a game originally developed for the Sega Dreamcast, by console manufacturer Sega
themselves. While made during the late 90s, it came out in early 2000, having has a long
development cycle and great investment cost making the game. Sega hoped for the game to become
a hit, a hit that never happened. Sega never made another console after the Dreamcast, and the
failure of Shenmue, among other things, caused Segas eventual withdrawal from the console
market. Because of this, Shenmue remained a somewhat obscure game until, in the late 00s, the
game was rediscovered by the YouTube community and became a cult classic of sorts.
One of the reasons of its newfound popularity is because of its revolutionary AI system. Unlike other
games from the time period, in Shenmue you could walk around an entire city, talk to strangers and
interact with all sorts of little things; from mini-games to vending machines. It is touted by some as
the first open world game, though that claim is disputed. The first GTA games came way before
Shenmue, though not in 3D, and there were more games that came before GTA that could be
considered open world.
In Shenmue, NPCs live according to a daily schedule. In the morning, they will go to a convenience
store to get food. Then, they will attempt to go to work, go home, eat, sleep, et cetera. This repeats
until the week is over, at which point the AI will change its schedule to one that is appropriate for the
weekend. Players can talk to these AIs, and hold a though limited- dialog with them. The idea
behind this is that player is able to live in a virtual world, and the player was supposed to do just this
in the first part of the game. Later, the player had to investigate a murder by talking to NPCs using
this conversation system. A conversation along the likes of Hey Mister, you wanna play basketball
with us? No, maybe later. Doesnt seem like much today, but at the time this was revolutionary.

9
Research on the AI design in open world games

Chapter 3 Conclusion
Many modern pre-GTA V suffered from the dead open world trope. These games, while having a
full open world, these worlds felt dead and where rarely played after all missions have been played.
To make the game and its city feel alive you need to have a good AI system which takes care of
random pedestrians walking the streets, going about their day.
What the studied games do, is use a node-based system. Every street corner has a node and civilians
walk from node to node. Not every NPC uses this system. Some, like merchants stand still, and sell
goods to pedestrians, which may walk by to buy things. Because of this, especially in games released
in the early PS3/Xbox 360 days, most NPCs walking around open world cities where of the latter kind,
not moving around unless provoked to run away from the player. Actual interactive NPCs werent
used as much.
More modern game use the GOAP system, which assigns multiple tasks to an NPC and uses a math
calculation to choose the most efficient one. This lends itself more to stealth/gunplay gameplay
however, and is not as useful for pedestrian AI. It also strains the AI programming side of the game
even more, and might not be viable because of that.
In the past there have been games that have a much more in-depth AI system, simulating schedules
and running the AI trough a daily routine. While this lends itself well to the gameplay of HMG, I,
again, strains development time, and Im not convinced theres much use in simulating this on every
NPC.
Future improvement
The following changes/decisions have been made based on this research:
-

The node-based system is kept. Up to 52 pedestrians roam the streets closest to the player.
On high-end system this number may be increased via a .ini change.
Aside from these roaming pedestrians we are adding static NPCs such as shopkeepers.
Roaming pedestrians will occasionally walk by these merchants an buy from there. Players
can also buy from street merchants to lower their risk rating.
Soldiers will use a light GOAP system when in combat with the player. This system will also
be used for stealth-based missions.
A full daily schedule is simulated but only on a target NPC when the player is doing an
assassinate or similar mission. The time of day never changes while in-game, so the scope
is this system is limited.

10
Research on the AI design in open world games

Addendum
Reading list:
Published expert talks
http://www.gdcvault.com/play/1020110/Free-Range-AI-Creating-Compelling
http://www.gdcvault.com/play/1020805/Classic-Game-Postmortem
http://twvideo01.ubm-us.net/o1/vault/gdc2015/presentations/Conway_Chris_GoalOriented_Action_Planning.pdf
http://twvideo01.ubm-us.net/o1/vault/gdc2015/presentations/Higley_Peter_Goal-Oriented_Action_Planning.pdf
Opinion Pieces
http://www.theguardian.com/technology/2015/jun/05/lonely-planet-the-solitude-of-open-world-games-whenthe-story-is-over
http://killscreendaily.com/articles/shenmue-and-rise-lonelycore-games/
Discussion
http://www.escapistmagazine.com/forums/read/9.247507-Open-world-games-that-arent-open-world

11
Research on the AI design in open world games

You might also like