• Register
Post feature Report RSS Devlog 2: AI System

Long time no see, my Scouts! Forgive us for this disappearance, but we were super busy with Playtests and preparations for the big day. Yep, you heard that right! Early Access is coming. Keep reading for more juicy info! Now, without further ado… Welcome to the second volume of Lumencraft Devlog!

Posted by on


Swarm and how it finds you
Today we want to discuss enemies - you know, the friendly little bugs that totally aren’t annoying and totally aren’t destroying all your hard work. Currently, we have 3 different AI systems for enemies.
Number one is your very favorite Basic Swarm - small, fast, aggressive.



Basic Swarm was introduced in the first publicly available build. It was the core of wave attacks and we quickly learned that the absolute top number that the game can support is 500 on the high end PC. When the tiny swarm was attacking your base every 10 minutes - this is it, that’s our AI. As you may have noticed, the behavior is pretty simple as those bugs have only one target, one purpose. Don’t expect them to suddenly do something super smart. If they do, it’s game over - for everyone, the AI is self-conscious and these sci-fi movies you like so much aren’t only movies anymore.

Jokes aside, the Basic Swarm has only 3 objectives:

  • go to the player core,
  • attack the player on sight,
  • attack anything the player constructed on the way to the core.

The Basic Swarm executes the plan by following these three simple rules: ( and Scouts hate them ;))

The Basic Swarm enemy is using simple Finite State Machine (FSM), meaning it can do the following:

IDLE - looks for target, finds a path, becomes leader, chill if nothing to do



LEADER - has no other swarm member directly in front, picks one of two attacks on the visible target, follows the target



FOLLOWING_LEADER - follow other swarm members that are close ahead, copies attack target from the leader



ATTACK_WALL - happens when swarm bumps into a wall or a gate



FOLLOWING_PATH - follows a path to the target (usually the player or reactor)



If you would like to imagine how much perception the swarm monster has, just close your eyes, plug your ears and imagine being pushed in a specific direction, you have your arm straight in front of you, and can only sense things that your hand is touching.
Now imagine you are being pushed back to chase the player that is behind a wall you don't know the wall is there. Now you have to decide: how to avoid collisions, when to turn, how fast to go, and you have no idea the player has surrounded you with walls or napalm. Poor bugs…

The Basic Swarm is, or maybe we should say “was”, the main AI system that we created from scratch. Although the result has a certain aggressive swarm-like character to it, we weren’t 100% satisfied with the supported swarm size so we wrote another swarm.

The Bigger Swarm
If hundreds of angry enemies are not enough for you, we also have another swarm AI.



This one is done following a well-established algorithm for flocking/boids introduced by Craig W. Reynolds: Red3d.com
If you are interested we recommend checking the article as it explains everything far better than we could do it here.

Swarm in Lumencraft is written as a C++ custom module for Godot. It allows spawning thousands of monsters that behave like ants. The biggest difference in the implementation was in integrating it with our world and letting monsters react to the terrain.

Lonely bugs
We talked about the swarm, but what about the rest of the gross enemies? Well, they have their own system. Next AI is intended to be used for “Smarter” enemies that can support multiple different behaviors that are not swarm-related.

The AI for most standalone monsters is a combination of Finite State Machine (FSM) and Context-based navigation. We know, it sounds as scary as being surrounded by lava! However, it works miraculously on monsters' behavior. FSM has a set of states that the monster can be in, like: wandering around, following players, attacking in a specific pattern, flanking, jumping, running away, etc. Context behavior on the other hand is responsible for navigation collisions, finding the best target, and avoiding other monsters.

FSM is a well-established algorithm and we do not deviate much in the implementation. So each monster has a set of states and transitions between them. E.g. A monster can only enter an Attack state from a Follow Target state, or an Idle state can be changed to a Follow Target state only if the target is seen. You get the idea.

Context navigation is more interesting and is based on a paper “Context Steering Behavior-Driven Steering at the Macro Scale” by Andrew Fray. You can read a bit more in chapter 18 of Game AI Pro 2 Gameaipro.com

Anyway, let's talk about how it is done in Lumencraft. We have this test dude over here:



Context navigation
So you can see vectors attached from his center. Those are interest vectors. The length of the vector is an information of how much the AI wants to go in a specific direction. E.g. Longer when the vector is directed to the player or destination. On top of that there is a copy of vectors that display danger. Usually the danger vector informs the AI that the direction will cause wall collisions, but can also inform environmental hazards.



Targeting and Decision making

Any decision the monster makes is defined by a state within the Finite State Machine based on information from other systems. Targeting systems pick targets and direct the AI on a world scale. E.g Go to the reactor core, chase players, return to spawn, etc. Context navigation informs the AI about its environment, targets around etc..
The FSM gathers the information and picks action according to the current state and options it has. Nothing much here to explain the biggest job is to make a functioning FSM and not drown in states and transition. Maybe one example:

Current state is follow_target

  • No collision ahead
  • Target in range of attack
  • Available attacks: Punch, Smash_AOE

Next state should be one of the available attacks.
So, the AI randomly chooses AOE_Smash, changing the state to attack_smash_AOE

And the result can look something like this:



Game Endeavor made an excellent video about combining various methods to create the most satisfying movement for enemies. We strongly recommend checking that one out!


Bonus clip where after months of polishing just a day before playtest started, everything decided to stop working:



The Big Day
We are super excited to inform you that Lumencraft will be entering Early Access around the end of March. The precise date will be revealed later this month.

Playtests

But! As we said many times before, we would love you to take an active part in every step. That’s why we would love to invite you to take part in playtests that we are organizing on Steam. Be sure to check out Lumencraft hands-on! Playtests are waiting for you and we are waiting for your comments. Your feedback will be super valuable. More precious than lumen!

That’s all we got for you today!
If you have any questions, find us in our Discord and we’ll be happy to answer all of them.
Discord.gg

Remember to wishlist Lumencraft on Steam/GOG.com.

Store.steampowered.com
Gog.com

We will be back with more Lumencraft fun facts!

Keep drilling,
2Dynamic & Star Drifters

Post comment Comments
HombreOG
HombreOG - - 20 comments

Interesting reading, looks so cool! I'm gonna keep an eye on this one!

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: