Introduction


I decided to invest some of my time in the field of artificial intelligence (AI) because I'm not satisfied by the quality of AI used in video games. From my point of view, most of the time AI implemented in video games depreciates the global work done by the development teams and is also a disconnection factor for players. Therefore, in order to solve this problem, I decided to try to create a method to design realist AI for non-player characters (NPC). Then in order to validate it, I implemented through an extension the decision trees created via my method in the video game “The Elder Scrolls V: Skyrim”.
I chose the video game Skyrim as model because:

  • Skyrim is in the Top 10 Bestselling video games of All Time. Therefore it has a huge users base.
  • The developer (Bethesda Game Studio) allows her customers to publish extensions for their games and has published an official development platform (The Creation Kit) to develop extensions. Bethesda Game Studio also provides an official distribution platform (Bethesda.net).
  • Although it is one of most sold video game, I was not satisfied by NPCs' AI.
  • The editor planned to implement a paying extension system in collaboration with Valve (Steam) and thus it would have allowed me to legally commercialize my work.

This project was supposed to be an 1 year volunteer job. However after 1 year of development, due to promising results and due to the will of Bethesda to implement a paying extension system, I decided to try to make a living with this job.


Results


  • Created an extension called “Immersive Citizens – AI Overhaul”. Full description available here.
  • More than 1 million unique downloads.
  • Extension in top 10 in “Most Popular” category for each platform (PS4, Xbox One and PC) on Bethesda.net. Ranking: PS4 ; PC ; Xbox1
    Note: You must enter your birth date to access the ranking page. Ranking is viewed from left to right and from top to bottom. For example, Immersive Citizens is the second most popular mod for PS4.
  • Extension in top 10 in “Most favorited” category for each platform (PS4, Xbox One and PC) on Bethesda.net. Ranking: PS4 ; PC ; Xbox1
  • Extension in top 10 in “Highest Rated” category for each platform (PS4, Xbox One and PC) on Bethesda.net. Ranking: PS4 ; PC ; Xbox1
  • Featured by Bethesda Game Studios. Link.
  • Featured on PC Gamer. Link.

According to these data, I added a significant value to Skyrim one of the 10 Best Selling video games of all time. Therefore, these data valid my methodology and my skills as AI game designer. If I managed to add value to one of the 10 Best Selling video games of all time, it is reasonable to think that I can be useful to a video game company.


General objective and strategy


The aim was to significantly increase player in-game immersion by greatly improving Artificial Intelligence (AI) used by friendly (non-hostile) and unique non-player characters (NPC) whose total number is around 600. I worked on 2 different types of AI: the AI used during combat and the AI used during NPCs routines (also called sandbox AI).

I decided to design a generic decision tree as starting point. In other words, a decision tree that could be used by any friendly NPCs. This strategy allowed me to release rapidly an extension in a decent state (with all must-have features) and then to customize AI of each NPCs. This strategy had also the advantage to allow me to support extra NPCs added by others extensions. In total I’ve been able to support the addition of more than 2 000 extra NPCs.


Combat AI


Problem: Skyrim NPCs have no sense of self-preservation. It means what whatever their chance of success, they will try to counter their aggressor when they are attacked. As a result, it’s very common to see for example NPCs charging a dragon and fight to death whereas they are no chance to survive.

My solution: To solve this problem I improved the AI used by NPCs when they are in a combat state. To summarize, if an NPC is attacked and has no chance to survive against an aggressor, that NPC will avoid battle and attempt to find a safe place (a hideout). The hideout is chosen randomly, and the number of hideouts NPCs can access depends on the size of the city in which they live.

I use four parameters to determine whether or not an NPC has reasonable chance to survive:

  1. The NPC's current level
  2. The aggressor's current level
  3. The NPC's current health
  4. The NPC's current resistance to physical damage (armor & spells)

The NPC’s current level is compared with the aggressor’s current level. NPC combat AI is modified at the root of the decision tree designed by Bethesda’s developers. Every 2 seconds the game engine check if my extra decision trees should override it or not.

Here is an example of generic decision tree used to implement my “Survival Instinct” feature at the root of Bethesda’s decision tree used for combat.

Then, in order to give more personality to some NPCs, specific decision trees have been created and assigned to several NPCs (but not all) according to their personalities and their social rank. Below some example of templates.

Cautious NPCs: An NPC is considered cautious when meeting ALL of the following requirements:

  • The NPC wears a cloth outfit (or is naked)
  • The NPC has no knowledge of protective spells

The NPCs categorized as "Cautious" will flee when attacked by an "impressive" aggressor, even if the NPC has a higher level. Specifically, the following creatures are listed as being impressive: dragon, giant, giant spider and mammoth.

Wizard NPCs: An NPC belongs to this category when meeting the following requirement:

  • The NPC has a mana pool higher than an arbitrary number

The NPCs categorized as "wizard" will stop fighting for a few seconds once their health is reduced by half. During this sequence, they will break away while healing themselves and refreshing their protective spells. Once finished, the wizard NPC will go back into the fight.


Routine AI


Problem: The general behavior of Skyrim NPC’s while not in combat could be improved. Indeed, most of NPCs stay at the same place or just patrol aimlessly in a town whatever the time of day and whatever the weather.

My solution: The first step was to make NPCs act realistically according to the time of day and according to the weather.

Basic Behavior and level design

The cities in Skyrim have not been designed to be used by NPCs using realist AI. Indeed, for example, among 600 citizens, around 30% do not sleep, mainly because they have nowhere to sleep. To solve this problem I added extra beds in the world of Skyrim. Here is an example of level designer work that I have accomplished:

This work as well my improvements on AI citizens allowed me to make all citizens sleep at least 6 hours per day.

Weather dependent behavior

In Skyrim, the weather is sorted among 4 categories (pleasant, cloudy, rainy and snowy). I improved citizens AI to allow them to adapt their activities according to these 4 categories of weather. For example, if it is raining or snowing, NPCs will stop outdoor activities unless they can continue under a shelter or if they have an important job. Otherwise, they will go back home or to the closest tavern if they don’t have home.

Here is the generic decision tree allowing NPCs to react realistically to a snowy or a rainy weather:

Unpredictable Behavior and level design

Then, in order to humanize the citizens of Skyrim, I decided to make them unpredictable by allowing them every day to perform one or several activities chosen randomly among a predefined list customized to many citizens. The bigger the city in which a citizen lives, the more activities that citizen can access. Here are some examples of activities:

  • shopping at the market, a general goods store, or at a specialized store
  • praying at the local temple
  • drinking at the local tavern
  • praying or standing in front of a grave

To summarize, each day NPCs will act differently. In order to allow NPCs to interact realistically with shops, temples, taverns and other public areas, I have added a lot of markers whose purpose is to allow NPCs to perform animations in relation with their local environments. These markers have been positioned according to environment of each public area.

Here is an example:

Result:

Specific Behaviors and animations

Then I have deeply customized the AI of several citizens (around 200) according to their personal stories, social ranks, jobs and personalities. As a result some NPCs will regularly perform specific or unique activities. In order to diversify NPCs activities, I have fixed and used several animations which wasn’t used in-game. This allowed me for example to allow NPCs to fill buckets with water, transport them and pour their content in drinking troughs.

Here is an example of fixed animation with 3ds Max allowing NPC to carry buckets:

Here are examples of specific activities (most of them are associated with a job). Some of the activities described below have been combined and assigned to several NPCs. In order to create a unique behavior for each NPC.

Rambler: Some NPCs will stroll outside their city/village for various reasons:

  • to enjoy the view of some landscapes
  • to gather some alchemy components
  • to travel to another village/city

Lover: NPCs involved in a romance will meet regularly in low-populated areas. If it is a forbidden romance, they will meet outside their city/village.

Mercenary: Mercenaries will train themselves regularly in the art of fighting.

Hunter: The NPC will hunt game (deer, hare, and fox) in the areas around the NPCs associated city/village. This will occur around 3 times per week during the morning hours. During the hunt, the NPC will check different areas to locate and hunt prey. If successful, they will pick up pelt and meat. The hunt process is reiterated until a specific amount of meat is gathered, or when the hunt time frame expires.

Here is an example of generic decision tree allowing an NPC to hunt deer and to pick up pelt and venison.

Enhanced Social Interaction

Another way to humanize the citizens of Skyrim was to make them interact between each other in a realistic way. Therefore:

  • I implemented all NPC conversations available, but not used in-game. This allowed me to approximately double the number of unique conversations between NPCs (Video 1, Video 2, Video 3, Video 4). Another simple but effective modification has been to set a reset timer of 18 hours (in-game hour) for all conversations.
  • I designed AI taking decisions according to decisions made by other AI or according to the state of some NPCs. For example, if an NPC dies, the behavior of some other NPCs will change.

Here is an example of generic decision tree allowing an NPC to have interactive behavior with another NPC.


Miscellaneous Link


Linkedin: https://fr.linkedin.com/in/d-orchymont-arnaud-ba73ab126
YouTube: https://www.youtube.com/channel/UCEFdan-sAeAgM-4VUutkHrQ
Flickr: https://www.flickr.com/photos/128143940@N04/albums


Contact


Arnaud D’ORCHYMONT
Email: a.dorchy@orange.fr
Phone: +33 6 42 10 34 40
Home address: 36 rue de Metzeral, Strasbourg 67 100, France