Combat AI

Airships
2014-03-18 21:07
Combat AI was the final major addition to the game I wanted to do before the first release. Until now, computer ships just kind of hung in the sky. This made them trivial to defeat: just fly around the back!


So I needed to have at least a basic tactical AI in place to stop these exploits. Most of combat in the game is about positioning, so the AI is based on evaluating positions. It calculates a quality metric for each reachable position in the fight, and moves there if it's better than its current position.

This quality metric is mostly composed of three sub-metrics:

  • Can I hit enemies?
  • Can fewer enemies hit me?
  • Can I get there without accidentally ramming anyone?

There's also some other minor metrics for breaking ties, but these are the main ones. These three sub-metrics are expressed as a single number, which I then visualized on screen for debugging:

Here, each dot represents the desirability of moving to that position for the ship on the right. Pink is good, red is OK, black is bad. Note that both ships are equipped with grenades, which can be thrown far downwards but only a short way across or up. The metrics figure out the best place to go: above the enemy, where the ship can attack, but not be attacked. And the worst place to go is below the enemy, where the opposite is the case.

And indeed this metric-based AI works pretty well: the computer now puts up a good fight in most circumstances. There's certainly room for refinement, but given that there's going to be complicating factors (like non-flat terrain) in the future, this is not the time to get lost in AI programming.

Anyway, the early release version: when will it be ready?

I've distributed a release candidate to a few testers to make sure there are no egregious problems, and I'm currently getting purchasing options and press stuff into place. Failing any setbacks, the game will be out this week.

You'll be able to buy it from itch.io and the Humble Store, for $5 (which is introductory and will go up to $10 pretty rapidly). And to be clear: the game is not finished. This early release version will not be polished, balanced or bug-free. Nor does it contain all the content and features I want to add. But it will let you play around with airships and do fights against the computer, and each other, and, well, me.

So if all goes well, the next post here is going to be the release announcement. I'm pretty excited.