How-AI-is-used-in-game-development

By juegoadmin | Game Development | October 3rd, 2022

A Basic Overview of How AI Is Used in Game Development

AI is everywhere.

From your smart speakers to dating applications, AI has leaped into multiple aspects of your daily life. The presence is so ubiquitous that many don’t even know that it is AI in the first place.

Video games are an area where AI plays an integral part. AI has been a critical aspect of games since the days of single-player arcade games. Today, as technology has improved and gaming has become more widespread, the AI used in games has become more advanced.

Game AI is Different

However, video game AI differs from what we usually consider AI.

Because the ‘normal’ AI as we understand it is self-learning. It changes behavior over time based on the knowledge it acquires. In fact, most technologists and scientists expect AI to become more conscious and aware of itself the smarter it becomes.

But AI in video games does not become conscious over time, nor does it even learn.

Instead, video game AI is a collection of algorithms that respond to a set of pre-determined inputs with pre-determined actions. The range of responses the game AI is capable of displaying is narrow and constrained to what the programmers have restricted it to.

This restriction is because AI in games has to only mimic human and non-human behavior. The developers’ intention with game AI is to give players the ‘perception of being life-like’ rather than ‘be life-like.’

Because from the view of game developers and designers who make them, games need to be predictable. To deliver an engaging experience, the makers must know the entire range of actions possible within the game to build the game around it.

A self-learning AI that behaves as it wants is an antithesis of this. Furthermore, such an AI would limit game designers’ and developers’ control over the gameplay experience.

The Different Ways AI Is Used Within Games

Within the framework of limitations, game development companies have devised a few games AI techniques and procedures to create the best gameplay experiences for their players. Below we list a few of them:

  • Pathfinding

Imagine your in-game character is at a location closer to enemy NPCs. As you move around, your character makes noises that alert the NPCs of your presence. How do these NPCs find and get to your location?

The answer is pathfinding.

Pathfinding is the technique of finding a route between Point A to Point B within a space. In video games, this technique is used for NPC characters to move around within the game space and find the best route between two points while also avoiding obstacles.

Most of the time, finding the best route means finding the shortest route. Because there might be numerous routes to get from Point A to Point B. However, the longer the route the AI takes, the less realistic it seems to the player.

So, to ensure AI finds the shortest route at all times, game developers turn the game map into a graph with different nodes. Each of these nodes would be a waypoint. The algorithm then calculates the shortest distance for the NPC to get to its target location by looking at the waypoint closest to the NPC and then the waypoint nearest to the player-controlled character.

To do this calculation efficiently, the algorithm looks through the entire graph once and understands the location of each waypoint.

This method is better than exploring each possible path from Point A to Point B and then finding the shortest route among the different directions. Because such calculation would affect the game’s performance.

  • Finite State Machine

Finite State Machine is a game AI system to determine Non Playable Character(NPC) behavior. Based on pre-defined cues, the NPCs transition between different states.

Finite-state-Machine

For example, consider your in-game character is in the vicinity of enemy NPCs. Initially, these enemies would be in the ‘idle’ state, waiting for a threat to appear. However, when the enemies detect your presence, their state changes from ‘idle’ to ‘attack.’ This state change also results in behavioral change, and the enemy characters start attacking your character. If you beat the enemies and completely deplete their power level, that character enters the ‘Death’ state.

The above example is a simplistic depiction of the Finite State Machine used in game AI. Because in today’s games, the range of behavioral combinations that game AI’s exhibit with Finite State Machine is much more complex.

  • Procedural Generation

Procedural generation uses AI in games to create in-game elements using an algorithm. Based on this algorithm, assets, music, and levels are generated automatically.

This technique is primarily used in endless games. The most notable example is No Man’s Sky, a game that lets you explore virtual planets in space. There are 18 quintillion planets in No Man’s Sky, each with its flora and fauna. Because the game world is so vast, it was impossible to build it manually. Hence, the developers used procedural generation.

Creature-in-a-game-1024x576(1)

(Src: nomanssky.com)

However, contrary to popular perception, the game assets (or music or levels, but let’s stick to assets here) are not randomly spawned. Instead, they result from a set of pre-defined rules and assets.

First, the artists create different assets, which the team divides into multiple sub-assets. The algorithm then combines different sub-assets based on mathematical equations and creates infinite variations of game assets.

The result? Numerous variations of flora and fauna, like in No Man’s Sky, give the perception that the game’s artists crafted each asset.

  • Player-Experience Modeling

The holy grail of game development (in terms of user retention and monetization) would be learning each player’s preference and then tailoring the game experience to them.

Suppose Player A and Player B have variations among their preferences in session lengths. Player A prefers longer sessions, while Player B does not. Then, the game would offer A longer levels with more obstacles and enemies and B shorter levels. Both players would essentially play the same game but have different experiences.

This personalization of gameplay is called Player-Experience modeling. It is an AI technique that top mobile game development companies use to improve their games.

The vital element in this game AI method is data. The game developers rely on data to learn their players’ preferences. Then, based on the insights from the data, the game delivers each player’s gameplay optimized to their personal preference.

Unity GameTune (discontinued) was a player-modeling tool for game development companies. Based on player data from Unity’s various services, GameTune automatically optimized the gameplay for each player. Developers who used the tool reported higher LTV, retention, and revenue than non-personalized gaming.

  • Analytics

Player behavior data is a reliable set of information to learn audience preferences. Moreover, it is more accurate in comparison to even the preferences players themselves say they have.

In game development, game analytics tools are used to observe player behavior based on different metrics. These are valuable tools for optimizing the gameplay in games for better engagement, retention, and monetization.

For instance, suppose you want to test player behavior towards a new set of In App Purchase(IAP) items.  After you add the IAP, you can use analytics to get data on how your users respond to them. Then, you can recall or iterate the IAPs based on your players’ responses.

Besides, using analytics becomes an even more powerful strategy when you couple it with A/B testing. A/B testing is the method of segmenting players into two groups and offering each group a slightly different player experience. For instance, if you retake the IAP example, you can introduce two IAPs to two different audience groups and test which of them receives a better response.

This development approach combining analytics with A/B testing is a critical tool for many of today’s mobile game development companies. Because it helps them gauge their game’s performance on metrics such as DAU (Daily Average Users), Sessions (The number of times players engage in the game within a given timeframe), Retention (the period for which players keep playing the game after installation), and Playtime (the average length of each playing session.)

Using this data, top game development companies can assess the gameplay and tailor gameplay to improve relevant metrics for better long-term engagement, retention, and monetization.

Conclusion

The use of AI in games, though it has existed for decades, is not as advanced as other methods of AI.

But it doesn’t need to be. Because of techniques such as Pathfinding. Finite State Machines, Game Analytics, etc., have helped game developers use video game AI to create engaging gameplay.

Want to Develop Your Own Game?

Juego Studios is a leading game development company with 300+ developers. We make games for multiple platforms across various genres based on custom requirements.

Request A Quote
Request A Quote