1. The Hand of Merlin
  2. News
  3. Dev blog 48 - AI AI AI AI AI

Dev blog 48 - AI AI AI AI AI

Hey folks!

The past two weeks I spent working on the AI with Mat. We weren’t very happy with how the AI made decisions for tactical movement. They didn’t look very smart by moving 1 tile over, or not attacking a unit they could clearly hit or moving away from units just to move back toward them.

Our game uses a utility AI approach. Every unit scores each tile they can possibly use their abilities on, and the best tile wins. Each tile is scored based on the configuration done for that specific ability.
Since most of our attack abilities were fine for the most part, we focused on remaking some of the movement considerations for it. We added a couple of new ones, offense and defense rating, which we calculate as “how many units can I hit, and in what way (full hit, hit behind cover, can't hit)”, and “how many units can hit me, and in what way”. Coupled with a small fix for AI where we allow it to consider the tile he’s standing on, and a lot of work done by Mat and me for a few whole days in screen share and talking and thinking about it, we now have AI that moves a bit smarter. We made sure they can think when far away from enemies in order to approach them, and close to enemies to flank them.



As I mentioned in blog post 26, our AI is data-driven. This means that once we made one consideration that we felt works well, we could save it to disk and reuse it in another place. We made 3 different tiers of resource files: brains, decision-makers, and considerations. A brain has a list of ability configurations - instructions for the unit with this brain about how to use a specific ability. Every ability config has a decision-maker, which is a list of considerations. Currently, we have 41 decision-makers using 59 considerations, and all of these would be available for modding once we release the editor post-launch. A single consideration can be reused in different behaviors, and different behaviors can be applied to different abilities. Creating these is also fairly straightforward.



Configuring a new AI unit can be done within a matter of minutes if you know what you need and all of the pieces are already available. For example, once Mat and I made the Ruffian bandit, we could create another melee bandit pretty much for free: just browse the existing presets to him, change the ability being used and we're done. Once we finished the bandits, I left Mat to his own devices and he created the AI for the rest of the abomination units, with the occasional bug fix on my end.



It's a bit hard recording and making GIFs for the AI behavior because I'd have to record an entire gameplay session to showcase how they move now. It's not easy just showing a single instance of "see, he moved to a really good position" because I have no idea when he'd do so in order to line up a screen good capture. Suffice it to say that in our internal playtests the AI did move better with less weird movements. I might coerce somebody on the team to record a play session in a few maps to showcase it, then upload it to Youtube or something, but seeing we're hella busy these days, I can't make a hard promise.
Thanks for watching! Join our Discord server so we can chat about the game, life, universe, and everything!
P.S. The title is a pun for "AI pain".

MarkoP

https://store.steampowered.com/app/600610/The_Hand_of_Merlin/