Programming AI with the Unreal Engine

The skills learned in both modding games and in the games courses I took were expanded on by studying artificial intelligence using the Unreal Engine.  Unreal Engine 4 is the game engine used in courses I have been teaching over the last 3 years. One of the most powerful features with Unreal is the visual programming feature called Blueprints.  Although, it takes a good knowledge of how to program, Blueprints allow the programmer to code quickly and thus be able to prototype ideas quickly.

The Unreal Editor also allows you to program AI using behavior trees.  Programming with blueprints and artificial intelligence has been my focus study in last 5 years.   Because of my skills with artificial intelligence, I have taught courses with a focus on artificial intelligence using the Unreal Engine.  Students learn how to get characters to make decisions and follow a set of goals unique to each character.

Environment Query System (EQS)

One of the tools in the Unreal Engine is the Environment Query System (EQS).  EQS is a feature in Unreal that collects data about the game environment. By using EQS,  the code written for AI characters can take the information collected about the environment, to determine the appropriate behaviors.  For instance, if a character needs to hide from the player, it can use EQS to determine the best hiding spots. However, But like with all tools, its effectiveness depends on how it is used.  

It takes a good understanding of what is happening in the background in the EQS to get the best results.  In many cases, I use EQS along with my own code to get the right solution for AI. It is important to use components and features built into the Engine, but also to write your own code for more specific AI behaviors.

AI Perception

One of the big improvements to AI in the Unreal Engine is the use of AI Perception components. AI perception is a prebuilt component that has a wide range of functions.  Using AI perception allows for the setting of simulating human senses including sight and hearing. This component allows the programmer to adjust the the range and sensing frequency of these senses along with many other settings.  

Using prebuilt  components not only saves time on frequently used code, it also increases the performance of the program.  Artificial intelligence that uses the engine’s components run fast because it is built in and tested for optimum performance.

Pushing the limits of AI

What would make characters in games more realistic?  Using motion capture animations, we can animate characters as naturally as real people.  With the rendering capabilities of today’s technology, we can create models to perfect texture quality. But this is only a small part of making game characters believable. They need to behave as though they have a mind of their own.  

People are experts at picking up patterns in human behavior.   In order to make more believable AI, we need to be able make characters unpredictable. Although there are routines people do every day, there also activities we do that are unplanned.  This is one area of AI programming that could be improved.

What if you were playing an RPG that has a shopkeeper that you saw do the same routine everyday, then one day he decides to leave town?  What if all characters in a game had a chance of doing something out of the ordinary. Whether or not this type of AI is necessary would depend on the scope of the project.  But, it is the details of behaviors that make characters seem more realistic.

Character dialogue is also a big programming challenge in games.  How many lines of dialogue can each character say? In the game Fallout 4,  there are over 111,000 lines of dialogue. Even with all this effort, does it still seem characters are saying the same lines over and over again?  Usually the characters in the game only say a handful of lines until the player has reached the next chapter of the story. Could this be improved so that there are an extra 50 lines of dialogue said at any time of game?  How far can we push the limits of AI? The more we push these limits, the more life-like characters can be.

My interest in AI stemmed from experience with an early age of video games with characters had very few actions.   In the early 80’s shooter games, the enemies in the game just needed to shoot the player and avoid getting shot by the player.  There wasn’t much else the enemies were programmed to do. They had no personality other than the their visual appearance. This was mainly due to the limits of technology at that time.  Technological advances now allow us to make characters do anything we can imagine. Characters in games are now only limited by the minds, the resources and budgets of the game developer.

I first took a interest in artificial intelligence in games, when I bought  the game Elder Scrolls IV: Oblivion in late 2009. I was so taken into the world that was created, I would play it for the next year any chance I could.  What really captivated me was the game world that was built for Oblivion. By today’s standards it is old technology. But at that time, no one had ever seen anything like it.  Characters in the game had personality. They would have jobs or other activities that seemed to have a purpose. They reacted to my actions. The world would change based on my actions.  It was not just the characters in the world that made it seem alive. Nature and animal life also made it feel like a real living world. So many small details of the real world were put into the game such as day and night cycles and weather changes.

A couple of years later, I became even more interested in game worlds when the game Elder Scrolls V: Skyrim was released.  It was at this time I decided to study how games were made. I took courses in game design and game programming. I also expanded on my study on games by learning how to mod games.  When Skyrim was released in 2011, it also included the Creation Kit, the game editor used to make the game. I was excited to learn everything I could from the editor and source files.  I studied the code that was used to make the game and how all the game systems worked. I studied how the artificial intelligence worked in Skyrim. I began to write my own stories and make mods for Skyrim.  I became so familiar with the Creation Kit, it was used in my game course at the school I was attending. Most specifically, I used the Creation Kit to program AI behaviors in a narrative sequence.