Like any design problem, the “best” approach for an AI algorithm depends on what you’re trying to optimize for and the constraints of the problem. So, let’s get some guardrails up by defining the game more formally and listing goals and natural computer advantages. We are going to need all the advantages we can get.
This is meant to be a boring distillation of the game mechanics, not a “pitch” for the game! Implementation of algorithms will be very dependent on the rules of the game, so this is here as a reference you can come back to.
The goal of Exospecies is to find and destroy all of your opponent’s supply units. How is described below.
Exospecies turns are complicated because each represents a period of time that actions occur in. Lots can change in this period of time: units can move into or out of range, go underground, explode and splatter poison, etc. Thinking about how things may play out over the time represented by a turn is key to winning.
Here’s how it works: Once the players have chosen their actions, the Exospecies engine calculates what happened. It does this by breaking down the turn into twenty points in time (“timeslices”) called “ticks”. It then plays out actions over this time period: units move, run into each other, attack, etc. What team gets to go first in any given timeslice alternates for fairness. This matters, for example, when two units are trying to move to the same square in one timeslice.
Some types of games have been extensively studied and formalized in the field of Game Theory. Classifying Exospecies using formal terms, when I could find one, will make it easier to evaluate algorithm applicability.
It is tempting to think of Exospecies as just a variant of chess when looking at AI algorithms since chess is a well understood domain for AI with a huge amount of research and solutions available. Unfortunately, there are some big differences:
In chess, the results of a move are deterministic: if you move a piece, it moves. There are several places in Exospecies where the result of an action is not:
In chess, each player can see all the state of the game. In Exospecies, there are several places where a player won’t know the entire state of the game:
If you make a tree with the starting state of a game at the root and each branch representing a possible move, once you’ve finished with all possibilities you’ll have a tree. The bigger the tree, the harder it is to analyze. Chess has a notoriously large game tree. But, in chess, a game piece has only one thing it can do: move. In Exospecies, “move” is one of 4-5 actions any piece can perform. In addition, these actions can be quite involved: modifying the game board, causing explosions, combining with other actions from other units, etc. This makes the tree of potential moves much larger than chess since:
The number of actions available in a turn is limited by energy, so that prunes off large chunks of the tree. However, considering that you can still do about 4 different actions, selected from a number of alternatives, to chess’ 1 piece/1 action means the potential tree is still substantially larger.
In chess, a single turn consists of one move and results in a new position for that piece and potentially removing an opponent’s piece. In Exospecies, the turn can involve many units moving for a period of time, interacting during that time, tiles on the map changing, units getting poisoned, etc. The cost of calculating the next state of the game is expensive and often noticeable by humans in the game (you’ve seen the roiling fireball when you end a turn, right?).
In chess, a unit move is only constrained by whether tiles are open. In Exospecies, this is also true, but it is also constrained by amount of global energy, which is constrained by what supply units you have and what other units are doing. Actions besides Move can have other dependency chains as well. This makes reasoning about the game more difficult, sometimes a player has to follow dependencies backward to set themselves up to do something in a few turns.
In chess, players take turns moving their pieces. In Exospecies, both players take a turn and the result of the turn is then calculated.
There are a few characteristics shared between chess and Exospecies:
Not surprisingly, many of the properties of Exospecies make it very hard for building an AI that plays well. I designed the game to be a rich and deep strategy game for humans, which unfortunately means it will be hard for computers to reason about.
At the outset, not knowing a lot about the solutions that are out there, I wanted to make sure I was clear about the characteristics I wanted in the AI. It’s unclear how many I’ll get, but if you don’t have goals…
The last point needs some explanation: many (most?) strategy games end up cheating in their AI algorithm because building a winning AI is so hard. It could be anything from knowing things that are supposed to be secret (e.g. the opponent’s base) or getting an advantage in odds (e.g. random damage is always high). Players naturally don’t like AIs that cheat because it feels like, well, cheating.
Knowing where the computer has natural advantages will help me build an AI that enhances them when possible. Here’s what I’ve got so far:
OK, I keep talking about cheating, but I really do want to avoid it. However, given how often it is employed by necessity, I feel compelled to think a bit about where the computer could cheat if I absolutely had to?
OK, now that I’ve got the problem framed up a bit, my next post will be starting a shallow survey of different approaches. I’ll map them to the points above and filter out a couple of experiments to try.
This is a post in a series on building a computer player for Exospecies. Next Post.
Exospecies was always meant to have a computer player (aspirationally called A.I.s in the game business)…eventually. I figured I’d launch with only multiplayer (i.e. human vs. human play) since writing a good computer player for a strategy game is notoriously hard. Really, beyond notoriously hard (witness Google’s Go AI). I don’t have PhD’s on my team and I don’t have one. I was going to need time to write a decent A.I. Plus: people are more interesting to play against, right? So my plan was, launch multiplayer, then build an A.I., then launch that. It gets the game in the market quicker, I get feedback from real humans playing (which will surely be more challenging than people playing computers), and then do the A.I. player when it is clear what strategies are being developed by humans. This plan also gave me the runway I’d need.
What I discovered (and was told by basically everyone in the industry, like “Wow, multiplayer only, huh? Gutsy.”) is multiplayer-only games are hard to succeed with. Some reasons:
Having a computer player gets rid of a bunch of roadblocks and fills lots of gaps.
What finally pushed me over the edge to slip Exospecies until it had an A.I. was my beta feedback coupled with early reviews. The feedback was essentially: “I want to play the computer to learn, and I want to play the computer when nobody else is around, and you really need a computer player. Really.” It was loud and clear, and it only took me running up to the final launch week and getting some blistering reviews to get it through my skull (more on that later in a postmortem).
While there is an enormous amount of information on the Internet and in books about A.I. techniques across the spectrum from pure research to practical use in games, there were plenty of places where I’ve been going down dark holes and having a real challenge figuring out either how algorithms work, how to implement them practically, or even how to understand the academic literature. I thought that writing up a blog might save someone else the anguish later and help me collect my thoughts. I thought it might also be entertaining to see how a naive developer gets slapped around by a really hard problem and then rises above it all in glory! (that’s how I’m hoping this ends).
Follow along as I learn and attempt to explain the amazing world of A.I. as applied to game development!