In recent years video game engines have become increasingly more accessible for developers
all over the world. What were once expensive pieces of software adopted solely by AAA video
game studios are now readily available to anyone with a desire to learn how to make
their own games. But a common question that comes my way is what engine should you use
if you're going to try and build a certain type of AI system for a hobby project? Or
what tools are available in your chosen engine as you're starting out. So in this episode
of AI 101 we're going to be looking at some of the most popular video game engines on
the market in 2019 and what artificial intelligence tools and technologies exist within each as
well as some suggestions for the types of games you're trying to make.
Now let me begin by saying I don't think there is such a thing as the BEST engine to work
with. Let's just get that outta the way: each have their own strengths and weaknesses and
are catering to different audiences. My aim is to give some insight for those of you keen
on starting out, as well as provide sufficient kindling to start flame wars in the comments.
But in addition, there is a huge disparity between what AI tools are available to developers
depending on the engine they decide to work with. Naturally AI isn't the only consideration
you have when making your games - and typically it's much farther down the totem pole once
you consider programming language, source code access, physics tools, animation and
rendering pipelines and much more - but it is something work thinking about depending
on the design of the game.
For this episode I've decided to focus on engines that are available to the public either
for free or under a license model that is largely accessible: Game Maker Studio, Cry
Engine, Unity, Unreal Engine, Godot and Source. So let's work through each in turn and discuss
the benefits and drawbacks and even some notable examples that indicate the type of work you
can pull off using these tools.
First up, let's talk Game Maker: a fun and flexible 2D game engine that is readily accessible
for novice developers. Despite this, it still provides plenty of functionality for more
experience developers to shine, with notable releases in recent years built in the engine
including Nuclear Throne, Gunpoint, Ten Second Ninja X, Hyper Light Drifter and Minit.
Game Maker has one notable AI tool: the Motion Planning system. Any 2D game intent on having
AI characters in it needs to address one critical issue: how to have them move around the world.
This could be to hunt down and fight the player, to follow you around as an assisting character,
or just run a patrol around the space. The Motion Planning system enables for navigation
paths to be calculated but with different variations. There are three motion planning
function types: linear, potential and grid.
- Linear is really simple, it just calculates the straight line path to reach a given destination
and start making motions towards it. In this instance, it's looking for a clear straight-line
path that heads directly towards its objective.
- Meanwhile potential is calculating paths that try to go around obstacles. This is based
on a principle of potential fields, whereby obstacles repulse the moving object as if
they were both magnets. You can configure how far out it's allowed to rotate around
a given obstacle point.
- Lastly, the grid approach is using an A* algorithm to compute a path between from start
point to end having broken down the environment into a 2D grid. It will then calculate the
path along that grid.
Next let's check out Unreal: an engine that has transformed much of the games industry
in the past decade becoming one of the most viable options for studios ranging from indies
all the way to the biggest studios in AAA. Unreal Engine 4 is now completely free to
use, but with royalty payments due should a game exceed earning thresholds when published,
or if you host it over on the Epic Store, which I am contractually obliged to bring
up so someone can complain about it in the comments.
So let's talk AI tools. First up UE4 has navigation meshes. While GameMaker works with navigation
on 2D surfaces, nav meshes are what we use for movement on 3D surfaces. The navigation
volume tools are allow you to define whole areas of your game level as navigable for
an AI character, as well as identify areas that are more expensive or less desirable
to walk through. After that, you can then call the navigation tools to have your actors
move around the map. Like all of the AI tools in UE4, you can either interface with the
navigation through C++ code or you can do it through the Blueprint visual scripting
tool. If you need to learn more about navigation meshes, be sure to check out the first episode
of AI 101 which talks about them in much more detail.
Next up is behaviour trees: arguably the most commonly used AI tool for managing the behaviour
of a character or system. Behaviour trees are have largely been standardised throughout
the industry and Epic have done a great job of continually updating these tools to better
reflect how developers seek to use them. You can build trees of startling complexity reliant
on one or more blackboards to store information that your characters can utilise. Behaviour
trees were the focus of the second episode of AI 101, so yeah be sure to check that one
out too if you want to learn more!
Working in tandem with the behaviour trees is the Environmental Query System or EQS.
This tool allows you to gather useful information you might need for a behaviour tree to make
decisions: such as where enemy targets or items are located, prioritising enemies based
on specific properties and much more. The EQS system is highly flexible and it can be
used to provide information for a variety of different situations. In addition to this,
there is the AI perception component that consolidates sensory information for actors.
This includes being able to see enemy and friendly actors, being able to hear noises,
whether they've received damage from an external source and even if they're being touched by
other actors. That's not meant to sound as creepy as I wrote it, but yeah... they can
sense being touched.
Unreal's AI tools are arguably the best among all publically accessible engines for what
is typically required in the AAA gaming space. But that doesn't mean they're comprehensive.
Despite that, one of UE4's biggest strengths is the access to the engine source code. This
allows for developers to build new tools that integrate within the existing engine framework
and can really streamline development. A good example of this was highlighted in my second
episode on the AI of Sea of Thieves, where the team explained how they wrote a separate
navigation system for sharks - given underwater navigation isn't supported in the engine.
However, given the developers integrated it into the existing navigation framework, which
meant it could operate and be called in blueprints and behaviour trees much like the normal navigation
tools.
Next up let's take a look at Unity: an engine that is immensely popular with students, indie
devs and even some larger studios given the cost and relative ease with which to prototype
games and cross platform development. It's arguably the biggest competitor to Unreal
Engine at this time with the features in each engine aligning more and more with each new
release.
Despite that, Unity is - at the time of this video - in a weird space when it comes to
AI. Like Unreal Engine it has a fairly comprehensive if occasionally limited navigation mesh system.
It has many of the same features as Unreal, but one key differentiator is that realtime
navmesh baking - whereby you recompute the nav mesh during gameplay - isn't supported
in Unity by default. However, new new navmesh tools are available via the Unity GitHub pages
and while it seems these new tools will continue to be developed over time, none of it has
been built into the main branch just yet.
The disappointing thing is that, right now, that's it. Unity lacks tools for managing
more complex behaviours such as finite state machines or behaviour trees. However, Unity
is investing tremendous resource into new AI research to build new tools that could
later be integrated into the engine. So while at present it doesn't cater to a lot of the
meat and potatoes of game development, there are two exciting tools currently in preview
you can play with right now: the AI Planner and the Machine Learning Agents Toolkit.
The AI Planner is designed to provide means through which to build domain models that
can model problems abstractly, then make plans that can execute solutions that solve problems
within that encoding. This is very much akin to popular AI tools such as Goal Oriented
Action Planning, popularised by F.E.A.R. back in 2005. The AI planner is still in preview
at this time and only accessible in Unity 2019.2 onwards, and you can download it using
the package manager. I'm still playing with it myself, but it seems to provide a useful
collection of tools for modelling domains, visualising plans it's created, managing execution
at runtime, but also being able to handle continuous and ongoing tasks. This is achieved
through use of trial-based heuristic tree search - a generalised implementation of Monte
Carlo Tree Search, which appeared in episode XX of AI and Games when looking at the AI
of Total War Rome II. This is a really exciting introduction, given it allows for the system
to create handle situations of uncertainty by simulating the possible outcomes and then
plan accordingly.
Meanwhile the Machine Learning Agents toolkit seeks to allow for developers to train Machine
Learning Agents - or Brains as they're referred to in the engine - through use of TensorFLow:
an open source library developed by Google for training neural networks through reinforcement
learning. This requires users to install a working Python setup whereby you then train
the networks through this, then later deploy the trained AI as part of the main game. This
like planning is still in an experimental phase, but could prove valuable once the tools
flesh out a bit more. One of the interesting challenges this faces is integrating the tools
for training and testing new machine learning agents into Unity engine itself. This is continuing
to be improved with new integrations into the Open AI gym as well. What's more interesting
to me, is that the UI and features are built to accomodate the notion of training 'brains'
to solve problems within your game and how developers will take to that in the coming
years remains to be seen.
Next up let's jump over to CryEngine, another feature rich engine aimed at the AAA market
- largely popularised by the Crysis series but has been in games ranging from Prey to
Everybody's Gone to the Rapture. It's worth mentioning that there's also Amazon Lumberyard
which is essentially a separate branch of CryEngine built by Amazon Game Tech, but with
new netcode hooked specifically into Amazon Web Services and Twitch as well as VR integrations.
But I'm going to be focussing on the tools in CryEngine for now.
There's a lot of overlap in CryEngine with what you find in Unreal Engine, which is no
real surprise given they're both vying for the same corners of AAA games development.
But the actual implementation varies quite a bit and is governed largely by CryEngine's
focus on making first and third-person shooters. You have navigation areas that users can define
the shape of by hand which can then utilised by AI Actors. Actors can be controlled through
behaviour trees that are defined in XML rather in the visual editor and a unique take on
gathering environmental knowledge for your AI known as the Tactical Point System or TPS.
TPS is much like the EQS system in UE4 and allows AI to ask intelligent queries about
objects or features of the local environment. This is great when you need AI to quickly
calculate cover positions that will provide sufficient defence prioritised by distance
and whether other AI characters may use them. Arguably the most interesting unique feature
of CryEngine, is that AI Actors can be assigned to territories and waves. Territories are
volumes of space built-in editor that are part of what is called an 'action bubble'.
When a player enters an action bubble, only AI actors within that territory will be enabled
at that point in time. In addition, an AI actor in a territory can be assigned a wave
for spawning in and fighting against the player, with news waves only spawning under specific
conditions. This effectively manages the spawning/destroying/intitialising and debugging of AI actors and is very useful
for creating specific combat sequences.
On top of all this, there is also source code access for the engine, so if you need to add
and tweak any tools to suit your needs, you can jump in and play about in the C++ codebase.
The last of the big engines out there is Valve's Source engine, which has been used by the
publisher for their titles ever since 2004's CounterStrike: Source and Half-Life 2 up to
recent releases such as Artifact and Dota: Underlords, but is also used by other AAA
developers, most notably Respawn Entertainment for both Titanfall games as well as Apex Legends.
The public version of Source Engine is accessible from Steam itself and is ideal for making
your own mods to many an existing Valve game, but the costs for subsequently making a game
based in their engine are a lot higher - given you not only need a source engine license
but you need to pay Havok - whose physics tools are part of the engine - $25,000 before
you release the game. So yeah, stick to mods, or go try another engine if you're serious
about making a game for sale.
Source's tools for AI are largely an extension of that used in Half Life 2, so it's really
focussed on non-player characters that fit first person shooters, but much more layered
with additional tweaks and options available. It still stems from the fundamentals of the
original game, which I covered in the AI 101 episode on Finite State Machines, with tasks,
conditions and schedules all largely still operating in the same manner as before. However,
htere are new additions, with the ability to define behaviours that are effectively
generic schedules for different NPCs to adopt, as well the ability to manage the memory of
AI characters and establish relationships between them. Memory allows for information
such as last time the player was seen or last known positions to be retained for periods
of time, while relationships help with squad management and team combat given an AI character
will know whether or not they like, hate or are scared of another character in the game.
Though I will warn anybody who is keen to try it out, none of the AI is properly documented
by Valve. There is a community written wiki which caters to some of your needs, but it's
not entirely fleshed out.
Last one on the list is Godot: a free and open source engine which started development
back in 2007 and launched version 1.0 in 2014. It's not as popular or as pervasive an engine
as the others listed above, but has a growing community of developers, including school
kids in the United States and there are small number of games emerging based on the tool.
There's isn't much to show here, beyond some pretty useful navigation mesh tools, with
a lot of tutorials out there to help you build simple steering behaviours of finite state
machines. One point to mention is that given the engine is open source, the community does
appear to be working on new plugins and tools that could add more features, such as TensorFlow
integration similar to that found in Unity. But I didn't find much else when conducting
my research for this video.
This is far from an exhaustive overview of the AI tools available in game engines. There
are still engines I didn't cover and I might have missed something in the ones I did. If
you have any thoughts, be sure to share them with others in the comments. But another factor
is that so many games are built in toolchains that are not available for the public to use.
Most AAA developers or publishers have their own internal engine that's being continually
updated to enable for different experiences, be it EA's Frostbite used in everything from
Battlefield 4 and Battlefront 2 to Anthem and Fifa, Ubisoft's Snowdrop used in Tom Clancy's
The Division, and Mario + Rabbids Kingdom battle and the id Tech engine used in Rage,
Wolfenstein and DOOM. Despite that, hopefully you've got a grasp of what each engine can
do and if you're an aspiring games developer or researcher, you've identified one or two
engines you'd like to play with.
Thanks for watching this episode of AI 101, if you like it, push all the buttons and join
my wonderful subscribers in supporting this show and helping it grow. I'm keen to come
back and do another episode on what AI technologies are missing for game engines too, let me know
in the comments if you want to see that episode as it's an increasingly long list. A special
shout out to my supporters on Patreon, who not only continue to support this show every
month and make all of this possible, but it was a discussion in our Discord server that
led to this episode being made, along with some valuable feedback on the way! You can
join all of these wonderful people on screen now by clicking the links on screen now and
in the description. Stay safe, have fun, I'll be back.