Programming good enemy AI is a monumentally difficult task. There’s so many different factors to account for. What is the appropriate level of aggression? How aware, or unaware of the player should baddies act? What is the ideal level of challenge for the experience that our game is trying to deliver? It’s a lot. In fact, it almost feels like too much, which might explain why so many games have incredibly stupid enemies.

Now, I don’t have a silver bullet for making good enemy AI. The answer to what constitutes good enemy AI isn’t one size fits all. The most correct answer is: it depends. There are so many factors that influence whether or not a game’s enemies actually succeed, and do a good job. That isn’t something I’m really interested in examining today.

Instead, I wanted to focus on a game called Shardpunk: Verminfall, and its baddies which I believe fall squarely in the good enemy AI camp. They don’t do anything revolutionary to accomplish this, but I would like to see similar systems implemented in other turn-based tactics games. That’s doubly true if they also want to provide an oppressive experience where the player is constantly on the backfoot.

Taking aim at a rat grunt.

But first, what is Shardpunk: Verminfall? As was previously alluded to, it’s a turn-based tactics game where players control a squad of mercenaries trying to survive a rat-themed apocalypse. I hate making comparisons like this, but picture the tactical gameplay of XCOM in a Warhammer: End Times – Vermintide suit. Every mission sees you guiding your scrappy squad of survivors through a leg of their journey while they’re beset from all sides by a never ending torrent of mutant rat men. It is very fun if you’re into the idea of fighting against an unyielding force, and constantly making adjustments to your plans as new unforeseen wrinkles present themselves.

However, anyone that has played an XCOM styled tactics title might be questioning how difficult Shardpunk truly is because of overwatch. This mechanic lets the player choose to save some of their action points from a turn so their mercenaries can reactively shoot the enemy during their turn. It’s an incredibly strong tool, and can define a player’s whole strategy while playing this style of game. That’s because some enemy AI will prioritize trying to kill the player over their own survival. The result is a totally one-sided bloodbath where the player can thoughtlessly mow down a completely braindead opponent.

Sharpunk was actually at risk of running into this very same issue with overwatch, where it would prove to be too powerful. Most of the enemy units prioritize killing over self preservation. I mean, thematically it makes some degree of sense. You’re fighting a horde of rat men that are characterized as acting like eusocial insects. They’re less concerned with the individual, and more with the result. Everyone is expendable, so long as the humans are wiped out. 

However, Shardpunk manages to sidestep the issue of overwatch being entirely overpowered by giving its enemies an order of operations. Yes, like BEDMAS in algebra. Each baddy is assigned an order for when they’re allowed to move, and this greatly reduces the power of using reactive firing from overwatch. This is because the less valuable enemies always move first, so the player’s squad will likely be out of overwatch actions by the time the more powerful enemy units move. It’s a small tweak, but it both keeps the power of overwatch in check, while also creating the illusion that your foe is smarter than they are.

Taking down several rat grunts with a single grenade.

For simplicity sake, I’m going to create a scenario using 3 of Shardpunk’s 11 different enemy types: Grunts, Shotgunners, and Rat Ogres. I don’t actually know if there are in-game names for them, but here’s a brief description of each so that we’re all on the same page.

Grunts are the first enemy type you encounter. They have no armor, 2 hit points health, and carry a knife. They have an average level of movement, and will always run at the closest foe so they can do a melee attack. Typically, Grunts are deployed in groups of 3 to 5.

Shotgunners are rat men equipped with a shotgun. They also have no armor, but have 5 hit points which makes them significantly tankier than the Grunts. They’re most effective at a close range which allows their shotgun to hit more accurately, while also dealing more damage. They can take pot shots from far away, but Shotgunners want to close the gap, so they can land a high damage critical hit.

Rat Ogres are massive armored rat men that carry around a bulky machine gun. They have 2 pieces of armor which reduces incoming damage, and an incredibly chunky 10 hit points. They’re able to effectively attack from the mid-range, but can use their bulk to force their way into point-blank range and shred through the player’s mercenaries.

Restoring some of your limited hit points.

Now, which of these units do you think moves first? If you guessed anything other than the Grunts, then I’m sorry, but you’re wrong. This unit is designed to be expendable, and so they always move first. They do relatively low amounts of damage, and always spawn in groups. By running in first, they can do something more useful than damage – Grunts can completely waste all of your overwatch actions. They’re be so many of them that it’s unlikely you’ll be able to gun them all down. Even if you do, there’s a good chance you won’t have anything left in the chamber for the far more dangerous Rat Ogres, or Shotgunners.

After this, the Rat Ogres will move. Their armor, and natural bulk gives them a lot of options for getting into position. They can very easily eat a couple shots if it means forcing the player into an unfavourable situation. Plus, if there are still Grunts in play then they won’t even have to eat any overwatch shots, and can freely move around the battlefield to exert a ton of pressure.

Finally, our Shotgunners move last. They don’t have the bulk to soak up overwatch shots, so they need to move when they’re the least likely to instantly die. They’ll likely burn the majority of their actions on movement, but with enough support from both their fodder, and bulky allies, Shotgunners will eventually get into position. It should go without saying, but we really don’t want our squad to get ripped to pieces by shotgun slugs.

Hunkering down while trying to determine which enemy to focus first.

Given this setup, we’ll likely want to spend our action on either chipping the Rat Ogre down, or impeding the advance of the Shotgunner. The fodder Grunts might reach us, but we can likely take a trade if it means we’re able to gun down the far more dangerous units on the enemy side. The key here is that the player has to recognize this, and position their units accordingly. It’s not good enough to simply wait for the enemy to walk into the line of fire – if we do that then we’ll end up killing a bunch of weak fodder while the stronger enemies can reach us completely unimpeded.

It likely shows, but I really love how Shardpunk: Verminfall uses an order of operations to move its enemies. On the surface it seems so simple, but it allows each of the baddies to function in their defined role. The Grunts are expendable fodder that run in first to clear the way for more powerful Rat Ogres, and Shotgunners to lay down the pain. The player can’t simply rely on powerful reactive suppression fire – they need to critically evaluate all of the knowns, and make a concerted effort to eliminate key targets. To my mind, that makes the enemy AI in Shardpunk quite good, even if they’re not overly complex in design.