Brad Wardell's views about technology, politics, religion, world affairs, and all sorts of politically incorrect topics.
4 days of coding results in a more intelligent opponent
Published on April 18, 2006 By Draginol In GalCiv Journals

Do as I say...not as I do...

I preach, regularly, that you shouldn't rewrite code. Instead, you should try to learn how it works and fix it or extend it. But sometimes, in rare cases, I find the need to rewrite something. Often it's something I did myself.  I've done a lot of rewriting this weekend. A lot.

Friday, Saturday, Sunday and today I pretty much did nothing but work on the AI.  No, it's not work. It's for fun. I mean let's be real, I'm working on a video game.  Any modders out there? You know what I mean.  If you had the source code to your favorite game, you'd probably make changes too.  And that's what I've done.

The list of changes is too long to list tonight.  The big ones I've done that players will likely notice:

  • AI (all players) Tries to do better at researching.
  • AI (all players) focuses much better on their chosen weapons tech.  Essentially, it was factoring in the cost of a technology too much in deciding what it would build. So later on it would think "Sure, I'm focusing on mass drivers but that quantum driver will take me 20 weeks to get while I can get Stinger missiles in only 3 weeks. Let's go for that.  Uh-uh. Not anymore. It's more intelligent now about deciding when to research what.
  • AI (all players) is much better at doing something about threats.  Players know the AI can identify threats but it wasn't doing enough about them. Now, you move those ships into that sneak attack, you'll see the AI pull in ships from nearby into orbit or attack you (and then announce).
  • AI (all players and not just the Drath) have the capability of paying others off to go to war with others and now it will tell you if they've been paid off (before they'd just go to war and you might not know why).
  • AI (all players) is aware of conquerors and will take steps to try to thwart them by acting together.

A lot of the weekend has been testing this, tweaking things, getting the pacing down pat. You don't want any of this to happen too often or not often enough. You also have to do work on the diplomacy screen AI (which I am not as involved in but have started getting involved in more) to make sure that this all flows well.

I need living space...

In my last game I was testing out the issue that hard core strategists have observed -- you can roll up the AI players if you can fight them individually and in isolation. Play on a large galaxy, tight clusters, rare everything and then pick off each player in a single surprise attack. Regardless of difficulty level, this is the "easiest" way.  The computing advantages of an artificial player are at their weakest.

The problem in battling this strategy is that it requires that players go against their own short-term self interest.  If I'm attacking the Altarians, why should the Arceans really care? I mean, they might toss the Altarians some ships and they might take you out IF they are more powerful. But what if they're not? What if you have the military edge? Tough luck basically.

In the real world, this happens regularly unless you have defined alliances.  In GalCiv II, alliances are not something you get easily. You have to get close relations and have alliances and even then it's not 100%.  

So what we want is for players to act against their short-term interests in exchange for their long term interests. Any AI developers lurking know the difficulty in putting together such a long term strategy. 

After all, nation states rarely work towards their long term best interests.  In World War II, Germany took Austria and no one made noises.  Then Germany took part of Czechoslovakia and the world did nothing.  Then they took the rest of it and the world did nothing.  Only after Germany conquered Poland did Britain, its dominions, and France declare war and no much happened except at sea.  Then Germany conquered France and still nothing happened. If anything, other countries joined up with Germany (Italy declared war at that point).  Then Italy invaded Albania and Greece and then Germany got involved there too. Country after country invaded and even though the writing was on the wall, countries didn't band together.  Even the United States stayed out of it until it was directly attacked and even then waited until Germany declared war on the United States.  In the end, what did Germany in wasn't that countries collectively got together (other than Britain and the Dominions who were true heroes of World War II) and said "enough".  It was mostly that Germany underestimated the Soviet Union and combined with Britain, the US, and the dominions, were able to take them out.

As we approach a strategy game, the challenge is how to get computer players to be more like Britain and less like say Belgium (or less like the Soviet Union which aided Germany until it was their turn).  In GalCiv 1.0X, the AI at best acts like the United States -- "Oh, you're being wiped out by the Drengin? Here's some free ships." Clearly that's not enough when you're dealing with a well oiled military machine rampaging across the galaxy.  In 1.1, some (and I won't say which) of the players are now set up to be like Britain where they will organize forces to fight aggression. BTW, I don't want to offend my German friends with any of this.  I'm looking at this purely from a strategic perspective. Regardless of ones feelings about World War II, Germany, up until they attacked the Soviet Union, had an excellent military strategy.

This may not work

Before I go forward with the test game, I want to stress that I have no way of knowing whether this is going to work.  I'm playing the game and recording what happens. So don't get too excited, this whole thing may amount to nothing.  It may take more work to make it band together. There's a lot of variables in places.

What I can guarantee you is that it will be tougher for me to win. It will spend its money better. Research better.  Use its forces better.  4 days of pure AI development is more than some strategy games get total. So we're not talking tweaking around the edges here.

In the beginning...

Each player gets one star, 2 planets. I will attack the Korx first who are the light gray. Then I will take out the Yor. Then the Drengin. And continue until they're all dead. That's my strategy. It worked flawlessly last time.

As one can expect, I always win this setup. But I can't beat the AI on suicidal unless I play in a galaxy where I'm isolated enough to make use of economic and production tricks (the new suicidal is much tougher).  Lower intelligence levels won't be affected much by what has changed except that you are much more likely to get help from other players.

Let's see if they've improved...

I'm the brown line at the top. Since the AI is based on adaption and not scripting, it has to "learn" what is best for it. But as an experienced player, my game play is somewhat scripted. I have a build order. I crank up my initial research to get a jump and you can see the results above in research.

I also know that Trade is very valuable to computer players since well, it's trade.

So I quickly fill in my techs that I don't have in other areas.

Very early I will have planetary invasion. If I'm lucky, I'll have invasion ships before the first victim, the Korx, even have defenders. Speaking of Korx, what are they up to? Are they building well?

vs.

This is the Korx home planet.  Not too bad a setup. Not as good as my home planet though. I got a better home world than they do and I'm out producing them in every way. But it's not really their fault. I just got a better planet and am spending more. The Korx have their abilities wrapped up in their production so if they do live long enough they could be a problem.

Planetary Invasion Tech? Check. Enhanced Transport designed? Check.  Building: 11 weeks.

And off we go..

The Korx home world is mine.  It's going to take me a bit of time to get out of debt though. I will be helpless for a few turns.

One down. 8 more to go. It's still 2225 and I've already got a huge advantage. I was able to take Korx using Informational Warfare so I didn't damage anything (though I did go into debt because of it).

The other players respond to my new power appropriately as I trade them techs for money to get out of debt.

Soon, I am able to get out of debt by selling tech.  So should I conquer the Yor or the Dnreing? The Drengin are slightly closer. But they've already conquered a minor race themselves so the Yor are a bit easier.

But before I do that, I'm going to set up trade routes with my other neighbors so that they like me. I need each one to think they're my buddy until it's their turn.

But first the Yor.  I design a fighter specifically with them in mind.  They, like the Drengin, are focusing on missiles. So this is a two-fer.

At 6 attack and 2 defense against Yor missiles, it should be quite lethal. And I have twice as many planets to produce it from. It's called the F2-Yor Doom. "Yor Doom" Get it? Oh, I'm so clever..

Anyway..

The Drengin aren't impressed with my military might.  This could be an issue. I'm going to ignore them for now. My military build up should make them look for weaker targets.

While we build up, let's take a look at what the different civilizations are researching as we begin 2227 (two game years in):

  • Drengin: Master Trade.
  • Altarians: Enhanced Logistics
  • Arceans: Plasma Weapons
  • Torians: Medium Scale Building
  • Yor: Harpoon
  • Drath: Warp Drive
  • Thalan: Stinger IV
  • Iconians: Impulse Drive Mark III

So quite a variety there.

The Torians are now ones to worry for though, they managed to unearth a Ranger. And are wreaking havoc on the Drengin. That will keep them busy while I eliminate the Yor and can then take on the Drengin right after now properly softened up.

My fleets approach while the Drengin take apart the Torians. The Yor will soon be history.

 The Yor respond to my build up by moving ships to be very close to mine and beefing up their defenses.

And then attacking! But their ships are no match.  Iconia (the Yor home world) is mine.

I guess that Ranger you found wasn't enough eh? The Torians are going down. I do some lend lease with them since I need the money and the Drengin are my next target anyway.

The Drengin, however, are monitoring the situation. Their scout ship sits silently giving the Drengin the FOW viewage they need of what's going on. What will they do? Their fleets are nearly done with the Torian Confederation.

The Yor, meanwhile surrender what's left but turn it over to the neutral Thalan. There's a lot involved in who an AI surrenders to. It's not particularly random. In this case, I attacked the Yor, I was the aggressor. So the Yor simply handed their forces over to a neutral. This is akin to US forces occupying Iceland in World War II to take over for the British.

Two down. The Drengin are next. But it coudl be tough. They have absorbed the Torians and a minor race. They're as powerful as I am.

This is the galaxy at this point.  I'm the bround. The Drengin are the red. The Yor, Torians, and Korx are already dead.

Oh don't worry, we'll take care of the Drengin. You don't worry yourself. Whoahahah! WHOHAAH! (cough cough). I also go around and make sure the war machine is fed with tech trades. It's gotten a lot tougher since the AI is greedier with its hard currency and won't generally trade weapons techs unless it's really desperate.

But every little bit helps.

And I've got a new Frigate class ship designed just for the Drengin.  To deal with the Drengin, I have a new transport type as well.

With 5,000 legions on it, it represents a major investment of manpower for the Dominion. I only need to take out the various homeworlds that the Drengin currently occupy. The rest I can take at my leisure.

Pretty straight forward.  Now, I can already tell you that it's been a lot harder than previously. The AI is building better ships because it's building a better economy. And it's focusing better so I have to build up a lot more. If I can take out the Drengin, that will help a lot.

I send in my forces. I also send a secondary force to what was once the Torian home world. The Drengin have forces up there too.

The Drengin recognize what I'm doing and declare war. I'm not ready yet.

The Drengin are well prepared for me too. Their ships are defended against my weapon type just as mine is against theirs. But they have more ships.  But I do manage to take their home world. The attack on Toria, however is thwarted. The Drengin won't be going down in a single volley.

Nooo. 5,000 legions!  I also discover that the Drengin were also at war with the Altarians and had conquered some of their territory. Now the full force of the Drengin is on me. But I take our their resource starbases.

I send my reserves to defend Haven, my home world.

Here they come..

Harpoon III ships with Warp Drive and Duranthium armor. There is, however, the question of why aren't they using Photonic Torpedoes which they have. So it's not perfect yet.

Ouch time. I don't even destroy a single ship. I send all my fleets after them and wear them down to only 3 ships.  But it's 3 more than I have.  Haven is undefended.

From across the Dominion, I scrape up 6 ships to make into a last ditch defense. If I can cripple the Drengin fleet here, then the war will be mine because I now have a definitive industrial advantage.

Valheru station is open to attack! It helps power all the Dominion core worlds. And it's soon gone.

But my last ditch fleet is there to meet them and it's quite a battle.

I lose two ships but in the end, the Drengin fleet is crippled. But so am I.

Right about then the Arceans, who are last on the list to be wiped out, send me some ships to help!

It'll take 10 weeks for them to arrive.

The Drengin have the upper hand still in the short term.  I need to take out more of their resource starbases and get my economy back in gear.

The Drengin have 43 points in planets.  I have 46 points. But the Drengin have geared up more towards economy for a long haul strategy. My economy is not as well developed.  The one money making planet I do have is the Drengin home world but with only 140 million people on it, it's not making much money-- yet.

The Drengin knows (I can say with confidence) that I have the long term advantage if I rescale up.  So they send in their reserves to make sure that doesn't happen.  The Drengin have better logistics and their ships are better.

The Drengin attack both my main fleet and my Arcean gift fleet.  Both are destroyed. It's time to ask for peace.

I have been given a reprieve.  Clearly, it's tougher this time.

I have to give away much of the store but I have peace in our time.  Now it's time to build a new line of ships.

If I can just crank these out before the Drengin regroup.

I was once a giant, and now I have the weakest military. I have a good economy and my industry is coming back. I need to upgrade my factories.

Over the next year I do. Until the Drengin declare war on me.

This time, I'm a bit better set up.

But I still lose. The Drengin wipe out my starbases. They take Haven. There is nothing I can offer.

Kona is retaken.

Haven 2 is taken.

I max my resources and logistics to build the Liberation fleet.

Once more..

I'm not dead yet.

The Drengin now know of this fleet and begin to move forces in. I need to make up for my losses so I grab a few mor harbringers and put them together. I need to get Haven back.

Meanwhile, the Drath have had a revolution...

Welcome to the party!

Haven is liberated. Now for Haven 2.  Haven 2 is retaken.  The Drengin have figured out the source of my ships -- Iconia.  They have sent ships to "deal" with it.

The Drengin, having been militarily dominant, have focused on lots of other interesting techs such as huge hulls.  My fleet is no match. 

So what does a Drengin Dreadnought have on it?

That comes out to being a movement speed of 12! 33 attack and 21 defense. It's a monster.

Against this ship and its escort is the Liberation fleet. My best ships.  I am victorious. Luckily there was only 1 of it.  The liberation fleet also takes out the Drengin expeditionary force that has been holding down my other sector. The path is now open to retake Kona.  However, the Drengin take out Iconia while I busy elsewhere.

The Drengin now have their own mega fleet. A fleet of those Dreadnoughts. They're looking for my liberation fleet. I do my best to keep them out of their sensor range so I can keep them alive.

Here it is, the liberation fleet vs. the Drengin monster fleet.  They found me and got first shot.

Each side has 34 logistical points into this.  It's a slugging match. This is the kind of battle that the combat viewer was designed for.  I'm watching it as I type this.

I'm going to lose.

I'm going to lose badly.

Not even a single ship.  The Drengin are just too well defended now against my mass drivers. My ships can't penetrate them. I mean they're freaking Dreadnoughts after all.

But I've given them enough of a bloody nose and been at war long enough that I can talk the Drengin into peace.

I have to give up my winnings to get peace.

I'm back roughly to where I started. I have Haven back and I still have the Yor and Korx home worlds.

With upgrades to planets, I have 46 points in planets. The Drengin now have 53.  My research is ahead of theirs right now. My industry is on par with theirs.

Anyway, as you can see, things have gotten tougher. I haven't even gotten to where the players will band together to try to prevent me from conquering everyone.

That's all for tonight..

 

"
Comments (Page 2)
3 Pages1 2 3 
on Apr 18, 2006
Just a small update here -- all nice. I still notice, however, that the tactical AI still is often at fault when it comes to starbases -- I still see the AI sending fleet after inadequate fleet to suicide itself on my starbases.
Starbase defense is simply too cheap, and the AI cannot take mine out, it seems, no matter what it does.
on Apr 18, 2006
Hi!
So should I conquer the Yor or the Dnreing? The Drengin are slightly closer. But they've already conquered a minor race themselves so the Yor are a bit easier.

That's why I turn off minors in my 1.1 beta games. They're just too big bonus to every civ that conquers them. And they'll stay off until they become MUCH harder to crack.
BR, Iztok
on Apr 18, 2006
Iztok -- I felt the same way about minors in GalCiv I. Eventually I had the difficulty turned up to Crippling or Masochistic and I was not having fun any more. I was so far behind all the time and I couldn't conquer any of the civs until I had taken my technology all the way up to Dreadnought. Then I turned minor civs back on. They gave me a shot right when I needed it! Some cheap techs (but not too many) to catch me up with the majors and some vulnerable planets that I could take with the military I could muster. The game would still be hard, but it would be a lot more fun. I would say push the difficulty level up to the point that you need the minors to win and then turn them back on.

Draginol -- Don't major changes like this tend to unbalance a tuned system and have unintended consequences? Even if the game was still just a spreadsheet tweaking this many values at once would probably screw something up. Kind of like Oblivion's Radiant AI, where giving the guards a minor tweak so they would go get something to eat led to the townsfolk looting the town while the guards wandered off to hunt deer in the forest. Should I be anticipating a release 1.12 or whatever that's a "fix to the fix"?

Wait a second. "4 days of pure AI development is more than some strategy games get total." What? What kind of games? Half-Life? Hearts? Civilization? Populous? No wonder all fighting games have enemies that just stand there while you snipe right next to them! Here I thought AI was spotty because AI was hard (same reason there are no robots). Is it just not attempted because it doesn't sell like graphics, or because it slows down the CPU?

-----

Brad plays a much more aggressive game than I do, or else he purposely takes on challenges before he's ready to make the walkthrough more interesting. I yearn for challenges where I lose fleets and starbases, yet I take every possible step to prevent that from happening.

I want this game more and more with every walkthrough.

Megavolt has a good suggestion -- it would be fun if there was a possibility for a computer player to "go aggro" and show up a transport on your doorstep far before any normal AI would try it.

After all, nation states rarely work towards their long term best interests. In World War II, Germany took Austria and no one made noises. Then Germany took part of Czechoslovakia and the world did nothing. Then they took the rest of it and the world did nothing.

The only history Americans know is World War II. Remember in World War I, where Austria tried to take one little bit of Serbia and the world did nothing... except for immediately declare pre-emptive war and activate alliances with each other until France, Germany, Britain, Russia, Austria, Turkey, and Italy were instantly engaged in total war. There's not really any lesson there for Galactic Civ, though, since in fantasyland total war is not regrettable, but fun! Well, I guess it does show that neither going to war nor preserving the peace are always in a nation-state's best interest, so it's forgivable if the computer gets it wrong sometimes.
on Apr 18, 2006
Brad - THe writier of the Ages of Man mega-mod for Civ CTP2 also adjusted his AI to counter a 'conquerer' strategy. You may want to take a look, the Apolyton site probably has contact info for him. Basically he modded in a 'aggressor' count that was something like

(the number of cities you have taken + (the number of wars you started x2) + (the number of civs you wiped out x5) - the number of turns that have passed WITHOUT ANY combat for the player in question/20)

this aggression count was used as both a modifier for non-ally relations as well as a trigger to start a new AI tree once it got high enough. Basically it was quite successful at playing nice as long as your border skirmishes were limited and you didnt start many wars. But once you had taken a civ or 2 it would trigger the rest of the world to begin uniting against you.

THis can be rationalized as fear-mongering is always prevalent in any media and in gal civ 2, despite something being out of the AIs 'radar' range they would hear of it though the news.

Mag
on Apr 18, 2006
Journal entry seems amazing even though your start settings (eg planets, map size) were pretty crappy imo.

I believe, based on previous Journals, that he specifically chose them to give the AI a hard time. If I remember correctly, the AI generally does best on Medium maps with lots of planets. By limiting the planets, extra pressure is placed on the AI, making it a better test of how well the AI is playing.
on Apr 18, 2006
Mmmmmmm ... I love the idea of AIs going to war because they recognize your philosophy of Manifest Destiny.

Q - Will such attacks only come from Military Campaigns, or Influence ones as well?

Q - Is it a sudden attack (i.e. We were soulmates and suddenly 'Britain' declares war on me the next turn), or is it a sudden degradation of relations. If the latter it could be easy to buy peace from them, or the degradation may simply make them a target before they become a threat.

Great read! I wish I could play Bright AND have a whole bunch of bonuses to help me. I would love to go toe to toe with the AI, but I need a helping hand to get there.

Dano
on Apr 18, 2006
*cries*
You are the most amazing developer I have ever read a blog of - and I've read many. You are singularly minded in your obsession of making the AI think about what's going on, observe things, react to them, even formulate plans. The end result is a game I CAN'T STOP PLAYING!

If ever I was to feel fraternal love for a person I don't know based on his online words, it'd be here.

I got my cousin, Paul, hooked on GC2. He's an XBOX Live efficiandado - plays competatively against people all of the time. Well he fell in love with the Ship Builder and then, when he sent his new flotillas near the Altarians, they attacked! This surprised him. Then their ally joined in. Now he's fighting for his life. It was MIDNIGHT before I got him out of my house!

I blame you! And your team! It's the first game in a long time that treats the player like royalty. A feast for the brain, while not being a strain on our adrenaline.
on Apr 18, 2006
Awesome write-up... When can we expect the next build with all the latest goodies?
on Apr 18, 2006
It'd be cool that if you're going to code in a WWII Britain-like AI behavior, maybe you could also code in:
* WWII Italy-like behavior: an ambitious but somewhat lesser power that sees the conqueror's scheme, but tries to jump on the bandwagon and take advantage of it rather than fight it.
* WWII Germany-like behavior: Aggressive major powers make an alliance of convenience, but will backstab each other at a moment's notice.
on Apr 18, 2006
Draginol - Are you going to finish this game? I'm really curious to see how/if you win it at this point. Also, I guess you're playing as a custom race (the Dominion?)? What are the starting racial abilities you pick?

on Apr 18, 2006
To: Draginol
From: The Kat Lord
Subj: Military Expansion into the Nth Quadrant

Q. Was the level on Suicidal?

Note to self: Always take out the Drengin first... end of notes.

Good luck with that one. I think your going to need it.

I do love reading your games. I guess as a further compliments I tried in Beta 4 your strategy from this exercise and won a match last night. Results posted to the metaverse.

W/R
Suralle Straykat
Kat Lord @ Large
on Apr 18, 2006
I believe they always test with the difficulty on tough, since that's the setting where you get maximum AI but no economic bonuses to computer players.
on Apr 18, 2006
Sounds good. Which patch, or beta pactch are these changes going to be implemented in?
on Apr 18, 2006
dupe, sorry
on Apr 18, 2006
I want this game more and more with every walkthrough.


same here...I am impressed
3 Pages1 2 3