Machine learning in games: prospects for your app | Crysberry

Machine learning in games: prospects for your app


10 July 2019

Machine learning provoked a revolution in almost every industry. 

You can easily find its stamps anywhere from crop planning in agriculture to cancer diagnosis in healthcare. These topics are often more widely discussed due to their impact on the well-being of humanity. We have discussed this question in one of our previous articles How to Boost Your Business with Augmented Reality

However, machine learning in game development is also an area to talk about. Nowadays, the game industry is the most wide-reaching form of entertainment ever. 

entertainment market size comparison

Let’s take an overview of how this technology can improve gaming.

Machine Learning in games

First of all, you need to clearly understand what Machine Learning is.

In simple words, it is the ability of a system to learn and improve from gained experience without special programming. This technology is also well-known as “Artificial Intelligence” or “AI”.

Machine learning in game development can become a useful weapon. It can help to create more realistic worlds, captivating challenges, and unique content. Machine learning algorithms can respond to a player’s actions dynamically. So a video game with a machine learning engine could react and change how the world, non-player characters (NPCs), or objects behave in real-time, based on the player’s actions and decisions.

machine learning in game dev

However, it’s worth to understand that Machine learning in games is not the thing, which makes AI in games interesting by default. The main goals of AI usage here are:

  1. To create really challenging gameplay.
  2. To provide a reward for overcoming these challenges.

The simplest solutions can be used to reach these goals. And any Mario game player can prove it.

Finite State Machines in games

Nowadays, FSM (Finite State Machines) model is used for AI in games in most cases. A Finite State Machine is any device storing the state of something at a given time. The state will change based on inputs, providing the resulting output for the implemented changes.

If we talk about games, examples of states can be: “patrols”, “attacks”, “pursues” etc. This model helps to extend the number of possible solutions and make them more flexible.

For instance, F.E.A.R game. States in it were presented as links of graphs. And transitions between them were determined by the pathfinding algorithm. This approach is called Goal Oriented AI. 

Read also: The things you should know before start game development

So why do we need Machine Learning?

Machine Learning allows to create AI, which adapts to the style of user’s interaction with the application eventually. A good example is a series of racing games Forza. First, the application collects data about player driving style. Based on the gathered details, the application creates computer-controlled drivers whose behavior resembles that of a real player.

Application with the content procedural generation (PCG) function (for levels and items) can use Machine Learning for creating items that are more consistent with the desires of a player. 

Another example is Supreme Commander game. It uses Machine Learning for determining the reaction of bots to the player’s actions. Michael Robbins described in detail how to use neural networks to control agent threat response. In a nutshell: 

  • They used multilayer perceptrons (MLPs) to control how troops react to enemies. 
  • The network had 34 inputs such as movement speed, health units, damage per second, etc. 
  • Depending on the input, they created possible outputs — different reactions on possible situations. 
  • They trained Neural Network by making AI plays against itself by putting two AI platoons on the same battlefield. 

You can find more details here.

Briefly about neural networks

The task of the Neural Network is to determine one of the possible results based on the input data set. Developers achieve by processing input data through a series of mathematical transformations, which are a simple formula and a certain coefficient. The result of the neural network “training” is a set of these very coefficients, which it gives the most correct results at. We call it the “thought process”. 

Example. We have an application in which a character runs through a labyrinth. The Neural Network is involved in the character’s rotation. There can be 8 “rays” emanating in all directions from the character’s head to the nearest wall. The Neural Network uses it as input data. According to their length at each moment of time, the Neural Network determines whether the character should turn now or not. The more times the Neural Network goes through the labyrinth, the more accurate the set of coefficients will be and the better the character will avoid obstacles.

How to add neural networks to your application

You can develop a neural network manually from scratch. However, this process is rather expensive and takes time. So, it’s better to use one of the existing solutions for neural network development. At the moment, the most efficient tool is Tenzor Flow by Google. Game developers can use it for AI with Unity, but it requires some effort. And by the way, Unity can offer its own solutions for such type of tasks.

Will it be difficult? Fortunately, not much. You can even develop a neural network without being a coder. However, you still need to understand how future game agents (characters, monsters, etc.) using the network will interact with the game world. And the most important thing for understanding is tasks and principles of network operation.

Also, I recommend to check this video to learn more about this:

After designing, you will be able to provide your programmer or contractor with technical requirements to implement your idea.


Now you can see that the Machine Learning area is very extensive and there are lots of ways to use this technology in games. The main idea is that Machine Learning will help to make your game even more exciting and adapted to each individual user. Therefore, do not miss this opportunity!