AiGameDev.com
Welcome to your new online hub for Game AI!

“The Paris Game AI Conference will sell out shortly. Already beyond our threshold.” – Alex

membership

The registration for the Premium Membership Area is now open again!
Find out more!

sponsors

categories


subscribe

Search


related articles

Sponsors

SpirOps

Pathengine

Solve This: An AI Bot to Colonize the Galaxy in 5 Minutes

Alex J. Champandard

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.

Galactic Colonization Single Player

Screenshot 1: Single player GalCon against the default AI bot.

GalCon Gameplay

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:

  1. The planets in your control produce ships depending on how big they are. You start with one big planet..

  2. You can send your ships to attack neutral planets, guarded by a constant number of ships.

  3. In battle, ships are lost one-to-one; you can take over a planet once the number of opposing ships reach zero.

  4. 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 Framework

You can see the framework in action in the demo, but you’ll need to register the full version to be able to run your own mods.

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

	

NOT LOGGED IN
Bookmark and Share

Comments

Comment on this article. | Show full forum thread.


avatar by Andrew 19.November 2007
Neat find, I'll have to try it out. No doubt unless there is a heavy bias towards one kind of strategy, that the AI might have to take best guesses due to the lack of knowledge - not a bad thing, just hard to model.

Can you also pit AI vs. AI? I loved tracking (for a while) Age of Empires 2 AI contests which was very easy to setup AI vs. AI on randomly generated maps (with contests being "best out of...X" ones to remove the element of chance you'd start up in a poor position).

I'd need to get into Python to work with it though, but I should check this out, soounds cool (Although I need to get to bed right this second).

avatar by Serge 20.November 2007
Looks like classical Linear Programming optimization problem.

avatar by Serge 20.November 2007
Well, not purely optimization - it's Linear Programming game

avatar by Jare 20.November 2007
Hehe, I think I remember this game was presented in the "Swarm" contest. Very impressive! Given the small amount of planets, it should be feasible to approach it as a board game. Take a few fuzzy logic techniques, use brackets for estimations of unknown values (# of ships in enemy planets) and search possible moves using best / worst / average values. Once the basics are done, add in some tactics for scouting, harassing and baiting, and some personality factors to weigh the value / confidence of best, average and worst case scenarios.

Easier said than done, but good AI is never easy, is it?

avatar by alexjc 20.November 2007
Serge,

I think you're side-stepping a lot of important details by just using linear optimization. Could you give us more details of how you'd approach this?

Jare,

Sounds like a very sensible approach to add scripted behaviors on top of fuzzy estimations. How would you take into account ships in flight, and potential arrival times?


Andrew,

The game seems quite balanced, and there are lots of options that open up in real-time... so not that many biases. :-) But after playing it for a while, I'm inclined to believe the default bot implementation cheats to produce ships faster than you.

You can watch bots play together on random maps with a nice plugin called Symmetry. And, yes, it's a great way to start programming! (Read through and make minor changes to existing bots first.)

Alex

avatar by Zeroth 20.November 2007
There are two types of minmax trees in AI, short range minmax, and winning minmax. The former is for the next few moves to determine the best local optimum, and the latter is a minmax tree until a win is produced.

I'd be interested to see how the two would compare in this type of game. For most situations local optimums are also global optimums, and it reduces the processing power needed.

The way I'd program this is to keep track of all the planets, and the longer the enemy has a planet, the more weight it would gain(since, logically, more production)

It also appears that the bots may be able to keep track of enemy movements? If so, that could be factored in as well.

Then, an aggressive approach would be to essentially "zerg rush", a sneaky approach would use planets as bait, and then attack the suddenly weakened planets of the enemy(as an example), and the cautious approach would be to stockpile and move slowly only when victory is certain, or neccessary.

avatar by Andrew 20.November 2007
The default bot cheats? The swine! First thing to remove when editing it is the code after "CheatWithSuperShipProduction()" :)

Since it seems quite balanced I'll take a gander when I have a chance, it's bookmarked now.

In the future an AI site (well, this one, since I can't find really any other *active* Game AI sites!) should have a small contest for some game like this to pit AI vs. AI, especially if the game itself is any good and can be programmed easily (I'm not sure this game is any good yet ;) ).

avatar by alexjc 20.November 2007
Andrew,

A contest is a good idea. I've run them before but don't have the time right now in the build up to GDC :-)

Phil, Galcon's creator, is interested in having one for his game, but it'd be nice to have one that's generally open for anyone to join in.

If anyone is interested in helping set this up, [URL=http://aigamedev.com/author#contact]email me[/URL]!

Zeroth,

Great ideas. The only thing I'm not sure about is how well minimax would perform in such a real-time problem... It's traditionally turn-based, but it could work I guess.

Alex

avatar by ferrisoxide 20.November 2007
And.. the best thing is the game comes with the python source.. so if you don't like the AI you could always hack out your own.. :)

avatar by ferrisoxide 20.November 2007
Ergh.. which was the point of the article.. jeez.. early in the morning and I've already made a tool of myself.. ;P

avatar by Jare 21.November 2007
"How would you take into account ships in flight, and potential arrival times?"

When evaluating a move, also estimate how long it would take to be complete, and extrapolate the movements of ships in flight, but only generate moves of the AIs when my move is complete. After that, I would subdivide that period based on the smallest time that AIs would take to complete their current moves. Once that is in place, I'd consider more frequent subdivisions, and probably take ships in flight into account when evaluating the board score.

In essence, try to treat it as a turn-based game where the time of each turn is variable.

avatar by Zeroth 21.November 2007
Jare Thats exactly what I would have done on further analysis. But school gets in the way. :/

Alexjc Basically, I'd use the method that Jare describes, however, you'd likely need to use a partial exploration/analysis algorithm. Because having the AI recalculate the minimax tree every other frame or whatever is still too expensive. What I've found works is working towards local optimums in my solutions, since 99% of the time, they work, when global optimums would take too much time.

It is after all an NP-complete problem here. ;)