Introduction to GalCiv III AI Talk

Published on Saturday, June 6, 2015 By Brad Wardell In GalCiv III AI Talk


I've created a new sub-forum here dedicated to talking about GalCiv III AI.  Because of our forum system, active posts here will float up to the top so you can see this post from the main forum too.

A big welcome to GalCiv III fans or future AI game developers!

## AI Background ##

GalCiv III is the first of the GalCiv games where I didn't write the initial AI for.  This has turned out to be a good thing, something that we will all benefit from for years.  But in this section, we'll talk about what this means.

Unlike the previous GalCiv AI's, this one is data driven. That means most of its intelligence is derived from XML files in the game directory.  The team implemented the AI as a huge library of APIs that use this data and make very simple decisions with it.  Because the game is 64-bit and because each AI player gets its own thread, there is a huge amount of built in potential to do some amazing stuff.

In late March of 2015, I finished up my main work on Sorcerer King and began to look at the AI for GalCiv III.  The primary strengths in the AI are what I just described.  However, it has some weaknesses too which revolve mostly around not being very good at PLAYING the game.  

To use the Chess metaphor, the GalCiv III AI at the 0.80 level (March 2015) knew how to play the game. It just didn't know how to play it well yet.  That's where I came in.  My pre-release work consisted on making the AI more skilled in playing actual humans.  

If I were to rate the GalCiv AIs over the years, and this rating changes a bit based on how I"m feeling that day I'd rate them as follows where 1 is brain dead and 10 is the absolute best AI a game can have.

GalCiv OS/2: 8

GalCiv I for Windows: 7

GalCiv II: Dread Lords: 6

GalCiv II: Dark Avatar: 8

GalCiv II: Twilight 7

GalCiv III: 1.0: 6


## AI Expectations ##

Anyone who has had to deal with me on forums knows that I have very limited patience for arm-chair AI designers. I'm old and cranky.  If you're participating in these discussions, here are a few ground rules you need to understand:

1. Nearly all players play at either beginner or easy.  And by nearly all, I mean 90%.  This has always been the case and will always be the case.  So feedback or suggestions that involve affecting those players negatively or spending a vastly disproportional sum of money and time on some AI idea just isn't helpful 

2. Unless you've programmed AI, feedback suggesting new APIs isn't really helpful.  Every AI discussion always has people suggesting things like "The AI should be able to detect threats" or "The AI needs to build better fleets" or "The AI should reinforce planets that are endangered" as if these features weren't in the game before I showed up.  That's the most basic stuff.  The aI fails to do those things because something else happened and our job is to figure out what happened that kept it from doing those things.

3. Extreme exploits aren't going to be fixed. Most people who win the game are taking advantage of some level of exploit. That is fine and we can, on a case by case basis, determine which ones we should address.  I tend to fix exploits that are too tempting to ignore.  If the AI is making bad trades, for instance, that's something that should be fixed.  But if someone has figured out that they can kite some unit in tactical battle for 45 minutes doing 1 damage per turn until the monster is dead I"m not going to fix that kind of thing. Kite away, my friend.  

4. My near time objective is to get the GalCiv III AI up to a 7 and later an 8.  It is extremely unlikely I'll be able to get it to a 9 on my arbitrary scale because it's not commercially viable and I've never seen a game reach anywhere close to a 9 and only one commercial strategy game has reached an 8 besides Dark Avatar.  Most PC strategy games are less than a 6 and provide their challenge through actual cheating AI which is much cheaper and often more fun for players anyway.

5. Understand what cheating really is. If you get a handicap at bowling or golf you are not cheating.  If you get to walk up and kick down the pins you are.  People throw around the term "Cheating" so lazily now that it's having a negative impact on the incentive to actually make good AI.   The AI in GalCiv does't cheat with 1 exception: On the higher difficulties it doesn't have FOW (and even that is something I'm looking to get rid of).  Giving an AI a handicap (i.e. every credit it makes is matched by another 0.25 credits) is not cheating, it's a handicap.  If the community ever reached a consensus that giving the AI a handicap is cheating AND felt the AI was dumb then it would make more sense to just have the AI actually cheat (i.e. just give the AI whatever units, weapons, techs, etc. it needed based on the difficulty level, much easier to code).

## AI Weaknesses in 1.0 ##

The biggest problem I'm dealing with in the 0.80 to 1.03 AI of GalCiv III is that all its thinking is empire wide. I cannot control spending on a per planet basis. I do not have access the shipyard building a ship.  I am making decisions for an empire without any local knowledge. As a result, the bigger the map, the weaker the AI gets.  

The second biggest issue is related and has to do with the ships. The AI doesn't currently have access to the ships in a way that lets me work with them based on on their location.  I've alw2ays written the AIs in GalCiv as a gamer and less as a programmer. So, in my mind, I always thought of fleets as having a geographical duty. That isn't the case in GalCiv. As a reuslt, it has a lot tougher time coordinating ships into coherent local "Stuff.  The bigger the map, the worse it gets.  

Now, before someone says "How can you have crazy sized maps and an AI that can't 'handle' it" I'll bring you back to expectation #1. The AI handles it just fine for nearly all players. It's for people who are really good at strategy games that can overcome this and it's not an all or nothing thing (The AI, with enough handicaps, can overcome this weakness).

Nearly every weakness in the 1.0 AI boils down to a lack of local awareness (that is, letting planets, ships, shipyards, think locally instead of globally). The AI would do great as a federal politician...


## Rolling up our sleeves ##

I have a bunch of low hanging fruit that I intend to address in GalCiv 1.1, 1.2, and 1.3. Let's talk about those first:

1. Eliminate the AI's all seeing FOW vision.  This will actually make the AI substantially smarter on bigger maps.  This seems counter intuitive until you see the weaknesses I pointed out.  It's better for the AI to only "see" stuff that actually matters so that it's not sending ships across the map or building starbases where it has no business doing so.  

2. Making the AI more aware of ZOC.  Remember, the AI gets annoyed when units and starbases are in its ZOC.  The AI makes no distinction between meat and silicon.  As a result, the AI often ends up with war with each other because of this which reduces the AI's focused strength.

3. Pre-war build up.  This is something I'll be working with the Civ IV and Civ V AI developers on.  This is something they're good at that I haven't done as much on.  So I'll be implementing some of those systems (not source code of course, I'm just going to talk to them about it) into the AI.

4. Localized tactics.  This will be a major bit of work but we will start dividing up the galaxy into theaters and have the AI start thinking of its empire and strategically vital interests as theaters rather than the current system which defines 2 theaters: Theater of focus (where it is concentrating its forces) and everything else.


## How you can help ##

Helpful: Telling me dumb things you saw the AI do that made you able to beat it is helpful.  Very helpful in fact.  Any mistake that would allow you to win regardless of the handicap.

Not helpful: Things that could be addressed just as easily with a handicap.  The AI doesn't build up its planets well. This is on our list. But it's actually not that important since that can be addressed with handicaps. 

Really helpful: Saved LATE games with descriptions of what you are seeing.  Maybe the AI isn't defending its planets well. Maybe it's sending out crappy fleets. Maybe its fallen way behind militarily. Maybe its ships are crappy.  These are things that I'm interested in.


Thanks all and cheers!