29.3.2019 - Jussi Kemppainen
AI setup & skills
We truly saved the best for last! For the longest time, our enemies were only able to hit and block, but not much else. This resulted in the game having a distinct hit-block-hit loop that was really easy to spot and take advantage of. It made 1-on-1 combat uninteresting. All our efforts were spent on making the usability shine and content for the levels. The AI was always next in queue.
But oh boy now the AI is on the center stage!
During this week we have introduced some new base skills and random variety for the AI. I have been able to build all sorts of actions on top of these simple building blocks. Actions like murderous kicks, jump attacks, retreating, dodging and much more!
Even the simple addition of taking 2 steps away from the player character in the heat of the battle breaks up the combat in ways I could never imagine!
My new favorite actions for the AI are the jump attack and a power kick the End Boss is able to perform.
The poor bastard’s jump failed.
Fish-monster jump attack.
Too much jumping? is this update too jump-heavy?
By adding a handful of skills for the enemies and introducing random decision making, we have made the combat of the game hard as nails and so much deeper than what it used to be.
Now, the next step is to bring the difficulty level to a more bearable level.
Insane difficulty level – check!
AI upgrade from technical perspective
So, what was done?
Jussi nicely put together the “what and how” of the AI upgrade from a gameplay perspective. I thought that I could elaborate a bit from a more technical perspective for those who are interested in under the hood changes.
Here are some of the most major changes summarized.
Lots of tweaking on movement evaluations, especially flanking behavior by adding a version of it for ranged enemies. In addition, there were many cases that enemies only had an approach for a single combat engagement, but now most of them have alternating behavior depending on multiple factors. All of this adds variety to the combat and also reduces the situations where enemies would become sort of passive observers circling around stationary characters.
Combination attacks: a combination of different kinds of movement and attack. As the game is based on heartbeats, where characters (including enemies) can give commands only on specific intervals, it sometimes leads into situations where enemy is very near their attack range by the end of a heartbeat but still have to move for one heartbeat to be able to hit. This can lead to combat that does not seem fluid (enemies getting too close or staying out of reach). It as well really hinders the enemy’s decision-making. Bringing in skills such as rush&hit or hit&evade provides much more fluent flow for enemies and makes them far more interesting. I’d say that these kind of skills are the major reason why the gameplay got a serious level-up with the AI upgrade.
Randomization, but in a deterministic way. Adding some sort of randomness to give behavior patterns some variety, and to break the so called behavior pattern deadlocks, is something we’ve been thinking about for a while. Now that we started to have more AI skills to bring that variety into, we decided to include randomness. In a sense, it is not true randomness (is there ever such?), but instead our randomness is tightly tied to a seed that is formed by the initial position of the object, heartbeat number where we are at, and then a call based unique identifier. This provides us with randomness that gives us constant results if we rewind and replay, which is the level of determinism that we need. The way we mostly use the randomness, is to provide random weighting adjustment for evaluation values of skills available for AI. In addition some skills have more detailed randomization in their decision making. One example is that our melee combat aiming system can select a random quality of prediction. This allows enemies to sometimes hit in situations where they would usually miss, adding an extra bit of excitement and pattern breaking to combat behavior.
Ranged aiming also got major improvement. Earlier there has been some bugs and missing precision calculations from enemy ranged attack predictions which now got fixed. Bit similar treatment was received by the enemies using a grenade and their trajectory predictions.
There are of course tons more improvements to the AI, but those are mostly tweaks and not as big on the scope as the aforementioned things.
Emergent AI behavior makes fun gameplay: The enemy just fell the tree and is crushing the Blacksmith under it
What is still to be done?
There are lots of plans for AI improvements that we are likely to work on during the next month. Let’s have a look for a few of the most likely ones.
First of all, there is likely to be more AI skills. Current skill structure allows us to quite easily add variety to the attacks without major code changes, so if something a bit different is needed we can usually get it in quite quickly.
AI decision making considering props will get a major update. Currently the AI will break environmental props, such as barrels or trees only in situation in which its route is blocked or it does not have something better to do. This already leads to some really fun situations, such as enemies felling a tree on top of characters or blowing up some explosives nearby them and causing massive destruction. However, to not have such randomness in the events, there are plans to make better evaluation for individual props and get the AIs to use the environment in much more smart way.
AI perception and out of combat behavior still needs an upgrade as well. We currently support things as luring the AI by causing distractions with spells or items. However, it is still a very bare-bones version and we’d like to have major update on that part.