GalCiv DEV Journal: You're in for an AI treat

Published on Wednesday, December 20, 2017 By Brad Wardell In GalCiv III Dev Journals


Just in time for Christmas we released version 2.71 which is almost strictly about AI tweaks based on player feedback and saved games.  Now, someone might ask "Why do you need save games to make the AI do [obvious thing]?".  The answer is that with so many different ways of playing the game (both in terms of game setup and in-game strategies) it turns out people play the game very differently from one another.  It's one of the reasons why you have most people who think the AI is really good and some people who think the AI is a total push-over.  It's not that the latter group are cheating or even exploiting, they have simply discovered a strategy that is unbeatable.

But as much as version 2.71 improves the AI, I'd like to give you a sneak preview of 2.8...


Game AI understood

Over the years, I've written a lot of different types of AI and I've generally tended to make what can broadly be called instanced adaptive AI.  That is, the AI performs a series of tests on itself on the background to see how it is doing and makes a series of adjustments based on how it does on that test.  This worked really well in GalCiv II for the most part

When Stardock made Galactic Civilizations III, I wasn't really involved in its design and the team chose to go with "modding" as its focus.  That is, let the player have a bunch of XML files to modify how the AI works.  The problem I have with that system is that it only really works if you get an AI modder who is performing the adaptation for you. 

When I returned to GalCiv III for the Crusade expansion, I began working with this system to make it more adaptive.  When I joined, there were 8 key areas that the "moddable AI" wasn't really suited for:

  1. Exploring space that adapts to the size of the map
  2. Picking technologies to research
  3. Putting together a fleet based on the state of the galaxy.
  4. Designing its ships
  5. Choosing what ships to build based on the state of the galaxy
  6. Knowing how much escort a transport needs
  7. Building up its planets based on the state of the game
  8. Building up its planets in the right order based on the state of the game.

Not all 8 are equally important but all 8 need to be addressed, imo, before GalCiv III can claim the AI crown from GalCiv II: Dark Avatar.

Version 2.5 of the game was the first version to start to tackle this:

2.5:  Putting together a fleet based on the state of the galaxy.

2.6: Building up its planets based on the state of the game

2.71: Exploring space that adapts to the size of the map

Those 3 items make a huge difference to the way the game plays.  Being able to right-size its fleet size is crucial.  You don't want an endless stream of tiny fleets uselessly attacking you and it does no good if the AI waits forever to send out some mega fleet.  It was version 2.5 that really addressed this and based on what I've read on forums and Reddit I think was the key AI feature that helped word-of-mouth on the game.

Today's update, 2.71 is pretty crucial for those crazies that play on really large maps.  The moddable AI had very fixed ways of exploring the galaxy and as we've increased the map size over time, the AI had very limited abilities to adapt.  Contrary to what people who lose the game would have you believe, the AI can't "see" the planets.  It has to explore them.  It has its own FOW just like you (and that's one reason the AI uses so much memory -- every tile has to hold the FOW state for up to 255 players and there's a ludicrous number of tiles on the largest map size.

Version 2.8

At 2.5, the AI satisfied most people.  At 2.71, we are definitely in "diminishing" returns.  But 2.8 is something I'm really excited about.  Here's a sneak preview screenshot:


So this is from a game I was playing last night.  That's 3 enemy fleets with with transports.  On normal difficulty.  Things didn't go well for me after that.  Which isn't to say my work is done.  While 2.8 addresses the moddable AI fleet governor (yea, there's an XML file you can mess with that says what must be in an AI fleet that no one has ever touched) to have that fleet adapt based on the player's needs, it doesn't deal with the moddable ship design template which affects the quality of those fleets (so you end up with meh enemy ships).  HIgher difficulty levels can fix that and frankly, 17 "meh" ships will still wipe out most players. 

The other thing about that screenshot is that each of those fleets is traveling at 7 moves per turn. This is due to the AI adapting its research path based on the state of the galaxy.

Next up is having the ORDER in which the AI builds improvements be based on its needs rather than based on modding.  At this point, you probably wonder, what happens to the modding? The answer, nothing good.  Moddable AIs are a bad idea imo.  A good AI should work in a way that is well beyond our understanding.  Not because it's "smart" but because it should be very complex. 

My job, as the AI guy, is to simply come up with tests the AI uses to measure itself and adapt to it.  That's how I've been doing it since the OS/2 days.  The more data I have access to, the better tests I can perform and the AI makes adjustments based on that.

I don't do this for you guys, I do it for me. Because an adaptive AI will surprise you.   Last night when those 3 fleets showed up, I woke my poor wife up when I yelled "Oh shit!" because I was totally not expecting that.  Until the adaptive transport fleet AI was made, the AI had never put together a fleet group like this. 

After the adaptive improvement construction is handled, next up is the AI ship building being adaptive.  That's going to take some time.

My Fuel

As some of you know, what motivates me is you guys.  That's why I harp on the Steam reviews so much.  If people don't like the game, I don't really want to work on it. If you haven't already reviewed the game, I encourage you to do so.

There is a small chance that I might get an opt in of my first pass of 2.8 before Christmas.  But people are starting to go on vacation so no promises.  In the meantime you can hang out with us on Discord.