How AI works

Home Forums General Discussion How AI works

Tagged: ,

This topic contains 5 replies, has 3 voices, and was last updated by Runeshadow 2019-02-12 at 3:22 pm.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #972

    Hey guys, thought I’d write a thread about how complex the AI is in this game, compared to most other games. I’m sure most of you agree that AI is a crucial part of almost any game, especially single player games. There is no point in playing the game if the AI is really bad. Take Skyrim for example. Amazing game right? It also has amazing AI and that’s part of the reason why that game is so great. But take other games that I don’t want to name, because I’m sure all of you can think of one that has bad AI. Those games are pretty bad aren’t they? Well I hope to make Gaia’s AI better than average to improve player experience. I’ll try my best to explain the depth of Gaia’s current AI state and remember that it’s still a work in progress.

    First off, AI is divided into multiple groups. These are Undead, Creature, NPC, Animal and Human. There are currently no NPC’s in Gaia though, so we can forget about them for now. Now these groups, or factions, can have relations with other factions: friendly, neutral or enemy. Let’s take a brown bear. The bear is neutral to every faction except humans, to which it considers them enemies. So the bear will attack any human, player or other human AI, that is coming too close to him. An AI can also be enemies with its own faction, like the King Scorpion. Although the King Scorpion is a Creature, it will consider every other Creature, Animal, Undead and Human as an enemy and will attack on sight including other King Scorpions. Amaroks, which are Undead, consider every faction an enemy except fellow Undead which it considers Friendly. The difference between Friendly and Neutral is that an AI that sees another AI as friendly will help it if it comes under attack from a Neutral/Enemy faction. So for example, Rompos are part of the Creature group and they view other Creatures as Friendly and Undead as Neutral. So imagine an Undead AI attacks a Sand Scorpion near the Rompo. The Rompo will come to the scorpion’s defense and fight the Undead with it. Weevils are Friendly to Animals, Enemy to Humans and Neutral to everything else. So Weevils will attack you if they see you attacking an Animal.

    I hope that was clear enough about the factions. Now a bit about AI’s deeper behavior. an AI can be AB, AF, PC, PB, PF, TC, TB or TF. Each letter means something. ‘A’ stands for aggressive and will attack anything on sight. ‘P’ stands for passive, ‘T’ stands for territorial. ‘B’ stands for brave meaning that it will fight up until it reaches a certain HP, at which point it will try to run away, ‘F’ for foolhardy which will fight until death and ‘C’ for coward which means it will run as soon as it gets damaged. These last 3 can be combined with the first 3, except C with A because that’s a nonsense. So you can have aggressive AI that fights until death or is smart and runs away to Regenerate health if it sees it’s dying, or you can have passive AI that runs away if hurt like a chicken, or fights back if hurt like a wild boar. Or you can also have territorial AI like scorpions, bears or wolves that howl or make a threatening noise and gestures towards anything that dares approach them, giving them a warning that they will attack if they don’t back away. TC AI is the AI like deer, who run away on sight.

    My main goal with the above 2 features is to make an ecosystem in Gaia, kind of like a predatory vs prey thing. The big hunt the small and so on. And if you, the player, disturb this ecosystem too much, it would have consequences. For example, if you kill a big number of deer from the map for your hunger needs, Amaroks and others won’t have anything more to eat so you will eventually get a wave attack from Amaroks. Or they might just die from starvation in the wild! This isn’t in the game yet though, but it will in the future for sure.

    Now about other cool things AI in Gaia currently has. an AI can be D, N or ND, meaning that they can appear during the Day, Night or both. All AI for now are ND, except for Amaroks and Harpies which are N. You also have different wander types for ground AI. All ground AI can walk or run, with Rompos running much faster than cows for example. But you can also have stationary AI, like Jenu the mushroom. Jenu is no joke though… It considers every AI faction its Enemy and will probably win most 1v1 fights if any AI or you dare approach him in melee range.

    AI are also affected by fire and radiation. Each AI will burn and accumulate radiation at different rates. AI on fire will also spread more fire to the environment if it runs or walks around. Some are almost immune from radiation, like the King Scorpion. Every AI also has a different setting to chasing its target if it runs away. For example, a bear will chase you for around 70m before giving up, while a rompo for around 35m.

    EDIT: Line Of sight turned off For Alpha 2. All AI’s use the 360 degree vision for now.

    AI can have 2 types of target detection: Line of sight or 360 degree vision. Take a bear with a line of sight vision. If you approach it from behind, it won’t know you’re there until it turns around and sees you or you attack him. Now of course, just like 90% of the games out there, there is also a 360 vision option. All human AI are on that setting, along with a few other non Human AI. AI also has different priorities when it comes to targeting potential dangers. A Harpy might pick the closest potential target as its main target while another harpy might pick the first potential target it detected. Target selection depends on a whole other bunch of checks, not just those 2. The AI is smart enough to select a target that is not too far away from it and smart enough to select a target that represents more danger to it, such as a big heavy turret versus a minigun turret or an assembler. An AI also needs a direct line of sight to a potential target. For example, if there’s a tree in front of you, the AI shouldn’t be able to see you unless it’s already been aggro’d. All of this in addition to the basic checks that 100% of all other AI in every game does, like making sure there’s a path to the potential target etc.

    What I’ve talked about so far was only about ground AI. It’s a pretty advanced AI I must say, but I will keep improving it every Alpha version of the game when it’s out on Steam because complex AI is just such a big part of a successful game.

    Air AI have different set of rules as they function differently. Currently in Gaia, the only air AI are Ironhammers (think of them like a navy destroyer, lots of firepower, low protection), Progenitor Carriers (think battleships) and Dropships (only ferries human AI like raiders, marauders, mercs and pirates onto the map and nothing else). I eventually want the Progenitor Carrier to be able to act as a mothership, just like a real aircraft carrier but in the air. In addition to its numerous weapons, it would carry squadrons of small ships that can act as a swarm and overwhelm enemies, a.k.a. you. But anyway, this behavior is a little bit too complex for a pre alpha game, so it will come later.

    Air AI shares some of the features from ground AI like the faction system, meaning that they’re part of the Human faction and they will fire at all Undead they see and so on. But not all features. Air AI has some of its own unique features (note that by AIR AI, I mean spaceships only. In the future, I might add some flying creatures which will act much more different of course).

    So what does Air AI have that’s unique? Air AI can have an energy field around them that absorbs damage. It’s like a second HP bar basically. They also have a number of turrets on them. Now these turrets come in 6 different types. But before we get to the turrets, there is something special about the distribution of turrets on the AI. Each AI has a number of turrets on top and a number of turrets on the bottom of the ship. The turrets on top can’t target you because of angle issues, they just can’t see you. But… When you try to escape the planet and you find yourself stranded in the air, those turrets will come into play because spaceships will be maneuvering a lot, doing barrel rolls, change in height compared to your own ship and so on. An Air AI with more turrets on top will try to position itself in such a way that it can fire with its top turrets more often than its bottom turrets and vice versa. This only happens when you try to escape though. When you’re on the ground, Air AI will just be hovering on top of your base, which brings me to the next point.

    When on the ground, Air AI currently has 2 unique settings, randomly chosen when spawned: Raid and Assault. A raiding Air AI will make one pass over your base, shooting everything it can with its turrets and then at the end of the pass, it will enter hyperspace and leave the planet (no special effect for that yet sadly, you’ll just see it accelerate to obnoxious speeds as it disappears into the horizon). An assaulting Air AI will make multiple passes over your base before it leaves the planet, destroying everything it can. Currently, the passes happen by having the AI circle around your base. In the future, there’ll be different type of passes, like flying in, then keep slowly flying horizontally over your base, then fly out and then fly back in after a certain delay. A Ironhammer can do both Raids and Assaults, while a Progenitor Carrier will only do Raids for now.

    Now about the turrets on the AI. Each turret is its own object, just like the turrets you can build yourself on the ground and on your ship. There are the MKII, MKIII, MKIV, MKV, PMKI and PMKII. Each Air AI has a certain number of certain types of these turrets. For example, the Ironhammer has 1 MKV and 4 MKIV on its bottom side and 2 MKIV, 2 MKIII and 1 MKV on its top side. MKI stands for Mark One and so on. PMKI stands for Powerful Mark One and so on. The lower the number on the turret, the weaker the turret is usually but also faster firing. You can think of MKII as a sort of an assault rifle while a MKV would be a tank cannon.

    I hope you enjoyed the read, even if it was a bit long! As you can see, the AI is pretty deep in Gaia but a player not reading this wouldn’t know. He would only notice all these details after playing a certain number of hours. That’s why before Early Access is released and probably before the Kickstarter as well, I’ll be implementing a ‘Glossary’ in the PDA that shows all or part of the information I just wrote here. The Glossary will contain info about every item, every AI and so on. Many games have this and Gaia should as well.

    What I’m about to say is not final, I’m still thinking on how it will work. But I’m currently leaning towards this way: The player has to kill or harvest a certain number of things before it shows in the glossary all the info concerning the thing. Although this would be a perfect solution for other games, it’s not for Gaia. I try to design Gaia for replayability, meaning that you can play the game over hundreds of hours and still enjoy it over new random maps with random settings. So having to ‘discover’ every item every time you start a new game is obviously not a good design choice in this case.
    Maybe I should make it so that once the item is discovered, it should stay discovered across different gameplays? For example, in your first run, you discover copper and bloodstone, so your glossary is updated but then you die and decide to start another run. In this second run, the copper and bloodstone would show as discovered.

    Tell me what you guys think, I’d love to hear your opinion! Same goes if you have any suggestions!


    Good day. The idea is interesting. From my point of view, it would be interesting if there is any structure that will study the elements brought by the player, be it ore or plants. After a short study time, the data can be loaded into the database, and already in this case, elements already studied are displayed at a certain radius.


    Interesting, but that would only work with items like ores and plants. It wouldn’t be possible with other prefabs or AI. But the main problem with that is that it will also become pointless to do after a few gameplays. By then, the player will know the details of most items so he won’t want to study them anymore. It’s really hard to come up with a good enough system for this haha


    Modification of resources, combining, depending on character development. In any case, this mechanic will have an end point, it just needs to be made useful for the entire period of the game. Justify the limitations of the capabilities of the character, not giving immediately get everything and use the knowledge to get something more. Although, this can lead to a weaker stretching of the gameplay. Complicated.

    In my head a lot of things are climbing, I’m just an ordinary player, with my own tastes. And it’s hard for me to advise something useful that would be interesting to a large circle of people.


    It’s alright, thanks for sharing!


    wow this is the most complex AI I have seen. I’m getting ready to write up an incident report on my first ground attack from a troop ship. This is good stuff here.

    Reminds me of Jagged Alliance when I was many hours into a game, and realized one merc won’t tolerate another merc. That’s after spending many hours and dollars on their training! You had to fire one or the other, or they would just quit and walk away. Man that was a bummer, but the developers made it awesome with great writing- the personalities of those NPCs and their dialogue was hilarious. After a while I dug into the Bio of a merc before hiring them, and you could figure out who was going to be a problem for the group.

    Especially when you consider the concept of Gaia, not just as the name of the game. Gaia is something we, as humans can only just barely understand. Our poor hardware (our brain) may not be able to run the software (Gaia). Even James Lovelock, in formulating the theory, was limited by his own experience, place, and time.

    Real-life consequences. Some players will get PO’d by that. Not a problem for me, but perhaps the difficulty setting could affect the amount of long-term consequences. But, I digress.

    The replay-ability and having to “Discover” something that you have discovered 1000 times already is a tough one. I kind of like the idea of having a persistent player-config
    file that would remember certain, but not all of the discovered items. (like the way keyboard mapping, and game settings are persistent) Then it would simply be deciding what is, or is not persistent. We should always have to discover the unique, or advanced items.

    Subnautica (SN) caved on this one. In the beginning, you could over-fish an area- like the safe area around the start-point. I thought it was awesome, I planned to capture fish, or breed them for re-release into the depleted area.

    They drastically nerfed the concept. IMO, human nature is to blame. Good players who were looking for a more basic, simple experience were also naturally the ones making all the noise on the forums. The players who tended to take what they got and be happy- they didn’t complain or even speak up. You are wise to keep an eye on this.

    Replay-ability is where it’s at. I have a lot of friends who play SN, with an average of only about 40-60 hours of play. I think it is because the beginning stages are SO tedious. It takes forever to build up to the point where you can relax from the survival part and explore or just hang out.

    Empyrion (EGS) players have hundreds or even thousands of hours. Same for Space Engineers (SE) , No Man’s Sky, Planet Explorers, etc. It is fairly easy to get re-started in those games. Both from the point of re-starting from a death and respawn, and for totally starting over.

    In developing the Multiplayer side, there were TONS of bugs and generally low performance. There were never enough Admins on the servers to keep players moving when they lost items to bugs or were stranded. The idea was that you could drop a player at any point on the map with zero inventory and the skilled player could survive and recover. I’m proud that on EGS servers, I never called an Admin fort help recovering from bugs or glitches. I could always find a way out. It became a fun challenge.

    “Blueprints”- or the concept of building a base one time, saving it as a blueprint and then spawning the base into a new game is key in EGS and SE. You simply gather all the resources and deposit into a “Factory”. After a time, you can spawn, or place the base at any location. Those are block-style building games and I don’t know if that would work in our game. The Steam Workshop adds an incredible dynamic tho this.

    Great thread!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.