Over the last few months on AiGameDev.com, I’ve written numerous in depth reviews of the artificial intelligence in AAA game. There’s certainly a lot to learn from such titles, but looking at things from the opposite side of the games industry is equally helpful.
This article focuses on an independent game called GalCon, a galactic colonization game that takes a few minutes to play. The game is pretty addictive; try the demo! This review starts with a short introduction to the gameplay and how the AI framework is implemented, then describes what the main challenges are.
Screenshot 1: Single player GalCon against the default AI bot.
The game can be picked up in a few minutes, but as the saying goes, takes a lifetime to master. The rules are as follows:
The planets in your control produce ships depending on how big they are. You start with one big planet..
You can send your ships to attack neutral planets, guarded by a constant number of ships.
In battle, ships are lost one-to-one; you can take over a planet once the number of opposing ships reach zero.
Your enemy also controls ships, takes over neutral planets, and can attack you even.
The goal of the game, obviously, is to destroy the enemy force within the galaxy. It’s not necessary to control all the neutral planets, however.
The AI is implemented as a Bot class which uses a simple and elegant scripting API written in Python. A new bot can be implemented in one file only, using the following boilerplate code:
import galcon class MyBot(galcon.Bot): def init(self): """Setup the bot AI.""" def loop(self): """Called every frame."""
Within the main update function, you can use a fleet command to order your ships from one planet to another. Planets and all the information you need is available from the base Bot class also.
This approach is rather typical of current games. It gives the implementor the important information from the game, and exposes the necessary actions, exposed in a dynamic programming language that can be reloaded at runtime. The scripting languages imposes very few constraints on the way you structure the AI, so there’s a lot of freedom to experiment with new approaches.
Screenshot 2: Three way symmetrical game (plugin) among three AI bots.
The gameplay is deceptively simple, but the little details that make the game fun also make it extremely hard to build AI. Specifically:
The ships have a speed limit, so it takes time for any attack or defense to arrive.
Individual ships in the same fleet arrive at different times, and get caught behind planets.
You don’t know how many ships the enemy has stationed in each planet. (Update: Theoretically, the AI can cheat obviously.)
What’s particularly challenging is to find a balance between conquering neutral planets (which take a known & constant number of ships) and taking over enemy planets (with an unknown number of ships, but constantly producing). It’s also necessary to take into account the current ship inventory with future production.
How Would You Solve This?
This kind of game is ideal for practicing the design and implementation of game AI. So how would you approach the problem of developing AI for this game?
What kind of information would you gather about the current galaxy, and how would you implement this?
How would you use this information, and how would you make trade-offs between the different options?