Brad Wardell's views about technology, politics, religion, world affairs, and all sorts of politically incorrect topics.
This way, NO! THIS WAY!
Published on December 27, 2005 By Draginol In GalCiv Journals

One of my biggest disappointments in the GalCiv I AI was how it fought its wars militarily.

The computer players in GalCiv I were given a lot of kudos but that mainly was because they were so efficient in how they handled their resources and on-the-fly military decision making.

But when it came to the overall strategy of war, the AI was disappointing.  It wasn't supposed to be that way, it's just that the best laid plans can fall apart when things get complicated and there's not much CPU time involved. 

In GalCiv I, all the graphics were handled by the CPU.  This meant that the background threads in GalCiv which handled the AI could still effectively slow down animation and graphcis.  So I was always painfully aware that any time I wanted the AI to do a complex calculation that I might be making some animation stutter due to slowing things down.

In GalCiv II, it's all 3D and all hardware accelerated.  So my background threads for running the AI are honkey dorey. This has let me have the AI build much more complex strategies.

The GalCiv I military doctrine was code-named "Sector Domination".  That is, the AI would look at what sectors it needed to control, assemble forces, and then try to dominate that sector.  On small maps, it worked pretty well.  On larger maps, it fell apart due to the fact that it is CPU intensive to try to coordinate lots of units every turn.  So what happened is that the forces would come to the sector in dribs and drobs.  Or put another way, players would get a death train of piddly units.

The other big CPU issue was in how the AI would react AFTER it succeeded in a given turn.  For instance, a ship attacks a given ship and destroys it. The decision on which ship to attack was originally calculated in a thread during the player's turn.  But now it's destroyed that ship during the move phase.  That move phase is in the main thread.  We were very hesitant for the AI to use up a lot of CPU calculating where it should go next.  So the result was, the computer player ship would make ONE smart move and then a quick-non-optimal secondary move.  So when it destroyed that first ship, what it did after that for the rest of its turn was pretty basic.  It typically involved the ship looking to see if there was another ship in the sector and go towards it.  It was "good" enough for many players.

But the real goal would be something a lot more complex: Ship attacks planet and destroys defenses. It then does a full calculation of what it should do next AND sends a signal to ALL the other ships in the sector to do a full calculation of what they should do.  That way, if there were transports nearby, they could capitalize on the opportunities.

In GalCiv II, the AI also can make use of rallypoints -- the same kinds the human can use.  So it will, at higher difficulty levels, organize ships via rally points and build up impressive fleets and then intelligent figure out where to send those ships.  They'll tend to only go after ships or fleets that they think they can probably kill or at least make a significant dent (i.e. at higher levels, the AI won't send some fighter to attack a battle ship). 

The handling of transports has changed as well.  They and their escorts and supporting military ships will "stick around" in a given sector until it's been taken.  So even if the defenses on a planet are temporarily taken down, the various ships will hang around until every planet in the sector that belongs to an enemy has been conquered.  And if enemy ships start appearing, the transports will run away from them.

The intelligence levels players set the AI to will be key in all of this.  Because they're CPU intensive, the easier levels simply don't use them at all.  What I'd like to do in some future update after release is allow players to set AI intelligence AND Advantage Factor.  Right now the two are rolled into one.  If you play at "Intelligent" on a given player they're playing the same resources at maximum intelligence.  But I'd like to let people with lower end rigs to be able to "get a challenge" by having the AI play at say "Normal" where some of the stuff is still turned off but crank up the advantage factor (advantage factor being "here's free money, loser." for the AI) to get the challenge they want if they don't care if the AI is "cheating" or not.  But that's in the future.

Hopefully as new players make their way up from beginning to normal to tough they'll see the AI not just be harder to play against but see it play more intelligently.


Comments
on Dec 27, 2005
I can't wait for you to get this one ready for general release!
on Dec 27, 2005
Great articles. I am really glad to see the concern of using the CPU for AI instead of graphics. I am perfectly ok with the notion: if I want a smarter AI, I need a better CPU. So please keep that development up.
on Dec 27, 2005
So much for the "Throw an almost invunerable starbase in the middle of his area and let him beat his head on it" battle plan
on Dec 28, 2005
This sounds phenomenal! Now that I've read all (edit) four AI articles I can say I'm definitely impressed...

But one question I must ask; if I have a low end computer, will the high end AI slow it down but the computer will still process it as it should or will that make the high end intelligence impossible? My point is that I don't mind waiting a bit for a better challenge, as long as it comes in the end. It's a TB game after all, not a click fest.
on Dec 28, 2005

If you have a low end computer, you'll be waiting longer between turns.

Though in reality, it'll still be a lot less time than most strategy games.  We try to make the game so that you can practically wail on the turn button non-stop.

on Jan 06, 2006
Well...GalCiv I's AI strategy really isn't that bad. I've got a huge border war going on in the 8th scenario (the Torians take my planet, i get it back and so on)...it's a lot of fun and it reminds me of the Dominion Wars in Deep space nine...if i only had more Paladins