Russia 1917: Building the enemy AI – the Whites

The February 2025 update on creating, in GDevelop, a strategic artificial intelligence for the White armies.

Russia 1917 prototype showing the strategic map between Murmansk, Arkhangelsk and Helsinki
Russia 1917 prototype showing the strategic map between Murmansk, Arkhangelsk and Helsinki

I am currently working on a game set in Russia in 1917, in the midst of the Civil War. The player takes control of the Bolsheviks, but I need an artificial intelligence to control the White armies, the forces opposed to the Bolsheviks that are trying to regain control of the country.

The objective of the game? Move your troops, capture strategic cities and confront the enemy. To make this interesting, the AI controlling the White armies had to be capable of making coherent military decisions.

The problem: GDevelop, the engine I use to make the game, does not naturally handle complex artificial intelligence. I therefore had to find a reliable method that would allow the AI to work step by step without causing bugs.

The White armies’ AI: a step-by-step military strategy

In my game, the White army has to work in stages:

  1. detect unoccupied cities to capture;
  2. assess the nearby Bolshevik threat;
  3. decide whether to attack or reinforce its position;
  4. move its troops intelligently.

To make everything work correctly, I set up a logical and well-structured method. Here is how the AI makes its decisions:

  • it begins by creating an invisible detection circle around each of its cities and units;
  • if an enemy soldier comes into contact with one of these circles, it means that the enemy is nearby and represents a threat;
  • the AI then identifies the troops closest to that enemy and orders them to attack;
  • if no enemy is detected, the AI sends its units to capture a new city and expand its territory.

Russia 1917 icon inspired by Russian Constructivism

The “Russia 1917” game icon used at the time of this article.

The classic GDevelop trap: everything runs at the same time

At first, I had written my AI like this:

  1. create detection circles around cities and troops;
  2. move to the next step to identify enemies;
  3. move to the next step to choose an action;
  4. move to the next step to move the troops.

In theory, that looks clean. In practice? A disaster.

Why? Because saying “step = 2” does not mean that step 1 has actually finished. The AI therefore started doing everything at once: creating circles, analysing enemies and moving troops during a single frame of the game.

The real solution: validate each action before moving on

This was the major lesson I learned while working on this AI:

You should never simply change a variable to move forward in a process. You must always create a condition that checks whether the previous action has actually finished.

In practical terms, instead of doing this:

❌ “If step = 1, then do this and move to step 2.”

I do this instead:

✅ “If step 1 is complete — for example, if all the circles have been created — only then do we move to step 2.”

Diagram of the four decision-making stages of the Russia 1917 artificial intelligence

The AI in action: creating detection circles, analysing the situation, making a decision and executing orders.

Why this method is essential

With this approach, the AI does not rush ahead and works smoothly. Each action is fully completed before the next one begins, which prevents the bugs that occur when everything is executed at the same time.

And that changes everything:

  • the AI appears more intelligent because it reacts progressively to what is happening;
  • bugs in which all actions are triggered simultaneously disappear;
  • the game becomes more strategic because the White armies genuinely respond to the player’s actions.

Conclusion: a technique worth remembering for GDevelop

If you want to create effective AI in GDevelop, or even structure a complex algorithm, remember this:

Never just do “step = 2”. Always check that step 1 has actually finished before continuing.

That is the key to preventing GDevelop from executing everything at once and to creating AI that is smooth, logical and strategic.

Now that I have managed to structure this system, I will be able to add even more intelligence to the White armies. Perhaps even give them more advanced strategies, such as coordinated attacks or tactical withdrawals…