Author Topic: Our take on grid-based tactics AI: Overview  (Read 2570 times)

Archean Games

  • Posts: 16
  • Karma: 1
    • View Profile
    • Hearalds of the Order
    • Awards
Our take on grid-based tactics AI: Overview
« on: August 28, 2019, 04:35:47 PM »
Well, it's been a long time since I last wrote one of these and since we're approaching a big landmark in our games development( more on that later) I thought I'd write something that people actually find useful for a change. So in the next couple of weeks, I'll be going over our games AI- the general concepts that make it tick as well as how we adapted those concepts to fit our needs. In this first part, I provide a general overview of all the systems in place. I'll go over each of those systems in depth. Since no two games are the same, this won't be a step by step guide on how to achieve the same results as us. It's more of a showcase of general ideas and approaches when designing game AI. The ideas I discuss can be applied to most games, but I'll be focusing on how we used them in our turn-based tactics game Herald of The Order. As a quick disclaimer I am neither an AI expert, nor am I an expert programmer, so nothing I say here will have much academic backing. I'm just sharing the solutions our team found useful in the hope of at least giving you a good starting point for projects of your own.

Utility AI
The main concept behind our games AI is something called utility theory. In layman's terms, it's the idea that every action a unit can take in the game can be graded with a normalized factor between 0 and 1 and different multipliers can be added to these factors to incentives certain behaviours. If you want a more professional explanation, I highly recommend checking out the works of Dave Mark. He is the author of "Behavioral Mathematics for Game AI". And has several great talks on the subject of utility theory in game AI in the GDC Vault. In our game, a unit can move, use an ability or end its turn. Each of these actions has several considerations, that factor into them. The most important of them is the danger map.



Influence Maps
The main idea of the influence map is that every unit has a zone of influence around them. This influence can be given a numeric value which is positive for members of its team and negative for members of the opposite team. These values overlap giving each position on the map a favorability factor. Using this map your AI can know which positions it's safer to be in and use that knowledge in all of its decisions. You can find a far more in-depth look on the subject around the web, but here's one article I found particularly useful: http://gameschoolgems.blogspot.com/2009/12/influence-maps-i.html



Behaviours
Behaviours are what we used to tell our AI how to use the information it has. They took all the factors for a given decision and added multipliers to them depending on how we wanted the unit to act in a given situation. We have simple ones which simply use a list of preset values and more advanced ones which calculate factors of their own for when we want to add another layer of logic to the actions of a unit, such as patrolling around a certain position or moving towards the player. We also wanted the AI to be able to adjust its behaviour according to the player's actions and so we needed a blast from game programming past.



Behaviour Trees
Although they're considered outdated, and they are outdated when it comes to low-level decision making. Behaviour trees are still a useful tool for controlling the AI's overall strategy. In our case, the AI goes down a tree of conditions at the start of each turn. Some examples of these conditions are: "Am I being attacked?" or "Is there an enemy in range?". Depending on if a condition is met or not the tree branches off. A branch can either be another condition, in which case it keeps going further down the tree, or a behaviour, in which case it knows how it has to act during this turn.



The bumbling to come
That does it for the mile-high view. In the next couple of weeks, I'll take a more in-depth look at all the different parts discussed above. As I mentioned, in the beginning, we're reaching an important milestone in our games development. The first chapter of our game(6 story missions) is almost done. We'll be releasing it for free by the end of September. We hope that this will help us generate a large enough following to justify the work needed to finish the rest of our game. If not we'll just have to leave it as a passion project sacrificed at the altar of real life.

If you'd like to know how we got here, check out our first blog, summarizing our journey so far. if you would like to see this game finished consider signing up to our mailing list, to let us know you're interested in our work. You can play the current version of our DEMO to tie you over until the new one is finished. And consider filling out this survey to let us know what you thought. As always if you want to see more from us visit our website or our social media pages: Twitter, Facebook, Instagram.

Visit our website to try our free demo: http://heraldsoftheorder.com/

Feel free to contact us at:
Gmail: archeangames@gmail.com
Twitter: https://twitter.com/ArcheanGames
Instagram: https://www.instagram.com/archeangames/
Facebook: https://www.facebook.com/ArcheanGames

Jubal

  • Megadux
    Executive Officer
  • Posts: 29096
  • Karma: 121
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Our take on grid-based tactics AI: Overview
« Reply #1 on: August 28, 2019, 11:35:06 PM »
That's a really neat and useful overview, thanks :) And useful links, too! I may have to get bits of this to shove in front of my students in October or November...

Why are decision trees considered outdated - just because modern AIs tend to have fancier learning systems involved, or?
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

Archean Games

  • Posts: 16
  • Karma: 1
    • View Profile
    • Hearalds of the Order
    • Awards
Re: Our take on grid-based tactics AI: Overview
« Reply #2 on: August 29, 2019, 06:58:22 AM »
It's probably because they can get too big to manage when it comes to more complicated behaviours. If you're using them for moment to moment decision making you can easily end up with thousands of branches. That makes them both heavy on the memory but also a bit slow for comfort. It's not that much of an issue for turn-based games, but it's pretty much unfeasible for real-time games where it has to be traversed every frame.
Most programmers also have this quirk where they forsake everything they know as ancient ju-ju magick the second something new and shiny comes along.
Visit our website to try our free demo: http://heraldsoftheorder.com/

Feel free to contact us at:
Gmail: archeangames@gmail.com
Twitter: https://twitter.com/ArcheanGames
Instagram: https://www.instagram.com/archeangames/
Facebook: https://www.facebook.com/ArcheanGames

Jubal

  • Megadux
    Executive Officer
  • Posts: 29096
  • Karma: 121
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Our take on grid-based tactics AI: Overview
« Reply #3 on: September 03, 2019, 03:27:39 PM »
Ah, that makes a lot of sense :)

Also why I don't feel like I'm a proper programmer - I will keep using the same tech for ages after it's gone out of date as long as it still basically works!
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

dubsartur

  • Posts: 74
  • Karma: 0
    • View Profile
    • Awards
Re: Our take on grid-based tactics AI: Overview
« Reply #4 on: September 05, 2019, 09:19:39 AM »
I think that is more sign of an experienced programmer: you don't believe the hype, and you understand opportunity costs.  Its the same with tabletop gamers: after a few years you learn that the rules don't really matter and stop chasing house rules or slight variants of the same system.

Jubal

  • Megadux
    Executive Officer
  • Posts: 29096
  • Karma: 121
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Our take on grid-based tactics AI: Overview
« Reply #5 on: September 12, 2019, 11:55:42 PM »
Mm, maybe, though I am a massive one for making lots of additional rules to include extra things I like the idea of in tabletop games. I will rarely buy system changes and variants, but I certainly invent my own plenty.
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...