Battle AI Rework


Hello, everyone! Version 0.3.21 is now available on itch.io, and version 0.3.22 is available for higher tier supporters of the game on Patreon. Today we'll be discussing the battle scene AI rework that comes with v0.3.22.

Old Battle AI

It might be a pertinent question to ask: why did the battle AI require a rework? The previous version followed an algorithm to identify the task with the highest priority at the current moment of the battle, then randomly selected a target and an action that fulfilled a set of very specific criteria. While it was robust enough to offer a challenge, especially to newer players, it lacked a lot of nuance, to the point that many characters in the game do not learn some actions not because they shouldn't be able to use them, but because the old algorithm would consider it equally appropriate for Maaterasu to use "Embers" as "Kick", as long as it identified that it had to deal damage. It was an artificial avenue to prevent the AI from taking bad decisions.

The new AI

The new version, on the other hand, is far more capable of getting a holistic view.


The first step is going over general information about what's going on in the battle, getting a feel of the "momentum" of the battle, using questions from the old algorithm such as: "Am I about to lose?", "Is any enemy about to be defeated?", "Can anyone be pinned right now?". This information is used at later steps.


Next, the AI creates a list of all possible action-target combinations possible for them to select in the current turn, along with an approximated success chance, and applies a base weight for all of them. Actions that are technically possible, but aren't desirable, such as attacking an ally with embers, will be discarded.

The weight of these actions is adjusted depending on the actor's and target's current stats, depending on the action's specific tables. For example:

Freeze feet will gain more weight with the actor's intelligence (80), the most important stat of the action. The target's will (-20) has a negative influence modifier, because it will allow them to resist the action's effects, while their agility (10) has a positive influence modifier, because the associated altered state targets that stat. This means that there is more utility in using this action to attack Claw than Padmiri, since the former tends to have a higher agility.

Keep in mind that this system takes into account the current, effective stats, not the base ones. This allows NPCs to take better contextual decisions. For instance, if you were against a NPC with perfectly rounded base stats, but you nuked their physique, agility and resilience through debuffs, they would immediately switch to use magical attacks against you.


Next, each action is checked for each of their relevant strategic tags, allowing NPCs to understand the context in which it's better to use which kind of action. Nashillbyir will now be less inclined to use "Staff Swipe" if she has full control in comparison to kick, since the former has the "recoverControl" tag and the latter doesn't; Valtan might want to use "Tease" on you if you're unfortunate enough to get more than one turn of lost control before pouncing on you, since the "sexOffensive" tag prepares characters to chain sex modifier combos at the appropriate time; and now all characters will understand that Padmiri is weak to embers. You might want to keep a watering can close to her from now on. You can take a look at all currently implemented strategic tags in the changelog, link at the top of this post.

Once all action-target combinations have been analyzed, those with a weight that doesn't make the cut get purged, and those closest to the highest weight get an even higher one. Finally, out of the remaining combinations, one is randomly selected, with those with higher weight having more chances to get chosen. This allows NPCs to prioritize the most useful actions without becoming utterly predictable, and still be capable of making light mistakes from time to time.

Let's take a look at a NPC weighting their options:


Here, Maaterasu can choose whether to attack Nashillbyir or Valtan, taking note of the fact that Nash has lost almost all control. Since taking an opponent down has extra utility, "damageControl" combinations that target Nash receive extra weight.


Meanwhile, since Nashillbyir is almost out of control, most of her actions have a very low chance of success. In this scenario, an action that would otherwise be considered mediocre such as "Taunt" becomes far more attractive, since it isn't dependent on anyone's control to be successful; while staff swipe has a good weight as well despite its low success chance due to the extra utility of recovering some control.


After a couple turns, Nashillbyir has gotten pushed down and pinned by Maaterasu. On the AI logs from her previous turn, we can notice how she considered both "Frontal Pounce P2P" and the neutral "Frontal Pounce". While the latter has much lower potential for damage, the former would allow Nashillbyir to deal damage back through physical stats, while the possibility of doing the same for Ate wasn't as attractive. This means that she has correctly chosen the option that allows her to inflict "Sparking Rubbing" on Nash with impunity!

Going forwards

The new AI will, naturally, still be subject to new modifications, as I find situations that weren't properly contemplated and new action functionality becomes available. In a future update, all Candidates will get access to all base moves at the start of the game. Feel free to share your feedback!

Files

Unholy Arts v0.3.21 Free.zip 140 MB
Jun 22, 2023

Get Unholy Arts

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.