DevDiary 14 - Combat AI
Ave and happy new year! Although the Logic Artists office has been closed between Christmas and the new year, several members of the team have enjoyed hanging out on our Discord server to chat with all of you who are eagerly awaiting our fast approaching release date. We’ve also been monitoring the Steam forum to see what you guys thought of the demo, and the reception has been heartwarming. It’s truly wonderful to see how much you loved what we showed you of the game, and if possible, we’re now even more hyped about releasing Expeditions: Rome to the world on the 20th of January (this month!) so you can all get to experience it for yourselves.
Today’s dev diary follows up on our diary from just before Christmas, which laid out how we go about designing a good combat encounter. This week we’re going to talk about how the AI has been designed.
Every game is a unique challenge when it comes to AI, and turn-based tactics offer a particularly exciting type of challenge. On the plus side, enemies don’t have to make split-second decisions because of the nature of a turn-based combat system, which means the AI can make more involved or complex calculations. On the other hand, the player has unlimited time to consider their actions and attempt to predict what the AI will do on its turn, so the AI must be quite clever and somewhat predictable without being fully deterministic.
The most important rule when designing AI for games is that the enemies shouldn’t play optimally all the time, but rather they should behave in a way that creates fun gameplay. It’s very easy for us to make the AI never make any mistakes – never step on your caltrops, never walk into your fire, never shoot your shield with their archers, never provoke attack of opportunity, never let themselves be flanked, etc. That won’t make for a fun game though: if you surround an archer with melee enemies, the smart play for the enemy might be to simply skip that archer’s turn, but that will just seem like a glitch. Having that enemy archer try to shoot you, only to get spectacularly skewered from three different sides is much more satisfying.
To this end we have a “mistake probability” value baked into our AI, which is tied to our “AI Difficulty” slider in the options. On higher difficulties, AI will be much less likely to make mistakes, which can feel unsatisfying as certain tactics or skills become more about denying options to the AI rather than provoking and exploiting its mistakes, but does make the game significantly more challenging.
The AI Difficulty setting also has more subtle effects, such as determining how good the AI is at maneuvering past your front line to reach your healer or your archer, or how often they’ll choose to focus their attacks on one specific unit on your team rather than spread out their damage. On the maximum setting, all bets are off as the AI does its level best to kill you, and we even give it a few extra advantages on this level such as extra movement for its melee units so they can maneuver more freely, or a small bump to enemy resistance stats to make flanking more important.
Movement in general is the foundation of good AI in a turn-based game – especially one that takes place on a grid. If the AI can’t reach you, they won’t be able to use their clever tactics. To this end, we have fixed a few of the big problems with the AI in Expeditions: Viking. First off, if you create a bottleneck by blocking off a choke point on the map, the AI would naturally attempt to find a different path which could potentially send it all the way around the level to get you. Now, this only happens if the AI can tell that it’ll be able to reach its target within a few turns. Otherwise it’ll find cover near the chokepoint and wait its turn, or even withdraw its own unit blocking the way, so another unit with higher damage potential can reach its target.
Once the AI is where it wants to be, the question is what it should do. Our combat designer has carefully designed which skills each enemy unit has, in order to create maximum tactical variation over the course of the game as you encounter different cultures and the complexity of the game ramps up. Some enemies have skills that are not even available to the player, which makes them much more interesting to fight. Every single ability that the AI has access to is associated with its own AI tactic that defines when, where, and how that ability should be unleashed. On top of this, there are general tactics available to the AI that help it coordinate between its multiple units, to ensure that the units move in the right sequence and get out of each other’s way.
To help you understand what the AI is up to, we’ve added a lot of combat one-liners. Most are related to specific events, such as morale failure, group movement, or flanking maneuvers. Some communicate the state of the AI, such as “defensive strategy” one-liners where enemy leaders order their subordinates to seek cover and stay put, forcing you to advance upon their position if that’s what the mission calls for. Some one-liners are even specific to a particular skill, such as when enemy heavy infantry uses Hunker Down to make themselves impervious to attacks from the front, or when enemy archers use Interrupt to nock an arrow and shoot the first of your units that enters their field of view. Not only does this help you understand the AI’s behavior, but it also adds a lot of personality and intensity to combat.
We’re very proud of how much the AI in Expeditions: Rome has improved compared to Viking. Our AI programmer has been hard at working over the holiday, polishing and improving the AI based on your demo feedback, but since the demo is limited to the prologue of the game, where the AI has access to very few tools in order to ease you into the gameplay, you’ve only seen a small fraction of what the AI can do once the training wheels are off. We can barely wait for you to get your hands on the full game and see for yourselves.
There you have it! Short but sweet. Please join our DevStream on Twitch this Wednesday, January 5th on http://twitch.tv/thqnordic at 1:00 PM Eastern / 6:00 PM GMTfor more discussion about the AI in Expeditions: Rome and how it was designed. Senior Producer Brad Logston will be joined by Combat Designer Hans Emil Hoppe Rauer, we’ll show off some more gameplay, and we’ll answer any questions you might have.
Until then, Valete!