Draginol Draginol

AI audit for 1.1

AI audit for 1.1

Areas to improve

Over good Friday I spent a few hours playing video games. Galactic Civilizations II actually.  With 1.1 nearly done, I wanted to make sure the rest of my AI tweaks started to get in.

Moreover, I wanted to try a game where the AI is at its most vulnerable: A game where planets are rare.  The fewer planets there are, the tougher it is for the computer players. That's one of the reasons why metaverse scoring rewards those who play with more planets available.

In this test game, each AI only gets 2 planets each just like me.  The question is how effective does each player use its planets and use starbases.

For reference, here is my planet:

Here is the Terran Alliance:

Very similar to my setup except they have more factories.

Here are the Drengin:

More emphasis on making money.

Here are the Drath:

Fairly balanced set up with more emphasis on money than us and lower approval from a higher tax rate.

Above are the Yor (a few turns later).  Reasonably good setup. They have pumped up their taxes some and have a pretty balanced planet.

So this is the galaxy. All players are set to "intelligent" ("difficulty = tough") which is the highest intelligence they go before they start getting bonuses and such.

The Stardock symbols are my worlds.  I'm going to take out the Yor (purple) first.

Let's take a look at the ships that the Yor are building:

The Yor are slightly ahead of me in miniaturization. I know that because their max capacity is 35 while mine is 32 (10% difference).  On their ship they've put Impulse Drive plus they've gotten to Mark IV lasers.  But as you can see, they're optimizing their space better (This is something I've worked on this weekend -- as any developer can tell you, it's tricky to have it "Smartly" optimize the use of a container without using an O^2 algorithm which I can't use since the AI has to design its ships almost instantly (or else the game would be unplayable at larger galaxy sizes).

My "F2-StarCat":

My rail gun Mark IV isn't as advanced as the laser Mark IV (uses more space).  But the net effect is that at this stage, the AI and myself have the same ships except theirs are faster.

One of the bigger changes I've done, which I'm not sure how "good" it is is that the AI players (all of them) are now more aware of the threat of sneak attacks. Top human players will tend to make a deadly lightning strike and essentially win the war in one turn. I.e. Blitzkrieg in space. This is a hard strategy to fight against because what players do is make their ships fast enough that they can be placed outside the AI's sensitivity zone.  So I've made it so that the AI now keeps more ships at home than it used to.

This is going to be a real problem with the Yor because...

It's now leaving 4 defenders in orbit (unlike the old days where it would just have 1).  So it's going to be some work.

I move into place. The Yor know what I'm going to do but it's too late.

Within a game year, the Yor are dead. Next up, the Iconians. Let's see what they're up to..

The good news from their point of view is that htey've built up some starbases.  They've actually got a pretty decent economy going.

Plus...

They built a military starbase that gives their ships +1 on attack that covers my entire civilization (except for one planet).  The Iconians have one key advantage, their home planet is a class 15 planet, their secondary planet is only a class 3 but that initial planet is very helpful.

The Iconians have been very busy too while I was taking care of the Yor.  Their class 15 world is doing very well.

Lots of money thanks to a higher population and higher tax rate and they've made full use of their special tiles. They are also upgrading one of their embassies into a farm.  When I see people on the forums say the "the AI" (each player has its own AI actually) doesn't use its planets well, I don't know what to say because I'm not seeing it.  Statistically, the AI will make mistakes for sure but it's certainly not the norm.  To me, this is a pretty spiffy planet setup.

But I'm going to see about taking them out anyway. But I'm going to have to be very surgical about it. So I build a special type of planetary invasion ship:

I almost feel bad, the Iconians like me.

But I can make new friends. The problem here is that I don't have a lot of forces and I have to take out that starbase that is giving them an edge. I can't beat the fleet on new Iconian otherwise.

My military build up is getting some kudos though.

That's right humans, suck up. You'll get your turn right after Poland, er I mean Iconia.  The Iconians are already at war with the Drengin. So I need to make sure I take out the Iconians first.

The war begins..

This is going to be a close battle.  The Iconians have a decent fleet protecting their world.

Ut oh. My spear head is wiped out. But I did take out their military starbase. I send in my reserves.

My second wave succeeds.

And that paves the way for my invasion. New Iconia is mine.

Being the evil bastard that I am, I offer them peace for a bunch of techs. Then I'll attack them again.

Incidentally, the game does allow you to double cross like that. But it decreases your likeability with other races since it's kind of scummy. ;)

With new Iconia mine, their minor colony is ready to defect. It might be cheaper to just let them be assimilated by my culture and move towards my next..victim.  The Drengin are at war with everyone else. They make a perfect target.

I have the Drengin beat in every way. This will be easy.

At this point, one might ask "Why don't the other guys do something about what I'm doing?"  The answer is, it's all in pattern recognition.  Now, this game is a pretty unique setup. Many of the people I see howl that the AI should be "Smarter" are likely playing on maps like I am where we all get 1 or 2 planets total with little ability to make use of the computer's natural advantage which is optimizing numbers. As soon as I took out the Yor, the balance shifted to me.  To thwart a strategy like this, players (including computer players) should get flagged when they go on wars of conquest. Then other players are more likely to go to war with them. 

Since I wrote the AI, I also know its secrets. I know, for instance that I have to keep the Drath happy because they do recognize wars of conquest and will pay others to unite in wars against those that do it.  But I've been keeping on their good side.  What will need to be done in the future is to expand on this pattern recognition.  But like I said, we're talking about a very specific map setup.

Of course, I haven't won yet. ;)

This is the Drengin Empire. Not too impressive. Surrounded by enemies, the only smart thing they've done this game is put their economy starbase behind their worlds out of reach.

Their planet is cranking out money. About the same as I am at this point. Note that they chose not to make use of the influence bonus tiles. That's not a bug. They simply decided that galactic achievements were more valuable. I would have to agree.

Their capital planet is defended by a fleet of 4 mark II defenders. They are essentially as good as my ships but no better.

So what are they doing wrong?

The Drengin have Singularity Mark IV.  Their ships are pathetic compared to what they could be building. Their latest ships known as mark III's all have singularity drivers but upgrading their ships in orbit would have been a good idea. The question is, why didn't they? Answer, same reason many humans don't, money. But I stop the debugger, make some adjustments here.

Since I know they're ahead of me technologically, I need to move quickly.

The Drath seem to be upset about the Korx.

Meh. The Korx are nothing to worry about. I'll get to them soon enough. I'll give the Drath some goodies though to help.

I also design some new ships with my latest/greatest stuff.

Like the poor Iconians, the Drengin are on friendly terms with me.  They have no idea I'm about to wipe them out.

The difference between 1.1 and 1.0X is really very apparent here.  I'm attacking a Drengin world and rather than encountering one pitiful defender in my sneak attack it's actually got a pretty decent little force here. It's still going to lose but it's a huge improvement.  I lose my capital ship in the process which is a bit painful.

One new change in v1.1 is that ships are named after who created them. So you can now tell when someone is supplying your enemies with ships.

The "Korx Frigate" is owned by the Drengin. The Korx gave it to the Drengin to fight me. But it's too late for the Drengin. Soon they're gone too.

Let's see, who's next?  Ah the snobby Altarians.

The Drath aren't having a good time. In fact, they're gone.

But they have given me what's left of their empire.  The Korx were too tough for them. Well I'll get to the Korx soon.

So here's where we're at:

I've got the bottom left corner. The Korx have the obttom right corner. The Altarians have two worlds just above me.

But the Altarians have been busy.

Look closely at this sceenshot.  The Altarians have 4 starbases ringing Altaria. Two military, two economy. The military ones are pumping up their ships quite a bit and will need to be removed.  But realistically, the Altarians aren't much of a threat.

Like the Drengin, they have a decent home defense but they're just too weak.

Rats. They escaped.

Okay, now I think I will deal with the Korx.  They aren't too threatening yet and I don't want to give them time to become a threat.

The Korx are currently involved in a war with the Torians.  I'm going to use that time to build up and study them.

Their home world is decently used. It's not as profitable as my home world is but it it's doing pretty well. But the Korx are worn down by the battle with the Torians. They are both ripe.

 

One of the things I'm noticing is that the AI isn't re-designing its ships often enough. This was put in for performance reasons but I think we can do it a better way (which I'm now implementing, recompiling, etc.).  It won't help the AI players this game, but it will help them in the future if they can make use of their new technologies more quickly.

I also design up a new ship for the Korx with a heavy emphasis on defending against missiles.

The Korx are offended.  But the question is, why aren't they doing more about this? They're set to intelligent. Though I do have the intelligences randomized.

Aha! The randomized intelligences save me.

Internally, they have to have at least a rating of 80 to do something about it. So I'm off the hook. The randomize intelligence feature adds or subtracts a few points from the AI randomly to give it more variety.

The Torians are losing but they won't have to worry about the Korx in a minute.

The Korx are defending their planets better than usual. Part of the reason is that all of the AI players will station attack ships in orbit now if it detects even the slighest threat. It makes doing these sneak attacks harder.

NOOOOOOOOOOOOOOOOO.

"Why shouldn't I always just pick the evil choice?" This is why (one reason). I just lost three key worlds to these guys because my people revolted because of my evil ways.

I'll deal with that soon enough...

The Korx war is a bit of a challenge...

And ultimately they are defeated.

The rest is just epilogue.  I ally with the humans and the Torians and have them wipe out the Thalan for me.

So what lessons can be learned here?

  • The easiest way to defeat the AI is on rare habitable planets. The fewer planets that are available to exploit, the tougher the AI has it because it can't make use of its computing advantage.
  • The AI players need to update its ship designs more often (done now).
  • The AI players need to be more sensitive to military conquest strategies. I just marched right through and took them over. Of course, this was a very specific setup - rare planets, small galaxy so I could get away with this.  But still, any player marching through like this should get flagged and other civilizations should do the same.  In World War II, Germany nearly won.  Had they not back-stabbed the Soviet Union, things might have gone very differently.  In this game, there was no Britain equivalent.  Everyone just waited their turn to be attacked.  I'll have to put some thought on how to do that.

Not too many flaws though, it's just hard for anyone, even people in the real world, to deal with a focused aggressor. I think we can do something about that. Whether that'll make it into 1.1 or into 1.2 remains to be seen. 

128,782 views 40 replies
Reply #26 Top
For that matter it might not even be AI code that is causing the build glitch. Granted I don't know how the classes are compartmentalized but it could simply be whatever controls the planet screen is reporting the wrong graphic for display. And in my current game I've seen it do the *upgrade yellow tile with wrong building* however this time not with a star port but with an embassy. Funny thing was after I took over the planet with culture I couldn't delete the embassy but I could upgrade the tile it was on with a soil enhancement. The screen even shows the embassy graphic with the little upgrade arrow. And the build queue says *Upgrading Embassy* So it's not necessarily the AI code.

Or it could be the bane of all programmers: Something is walking off the end of an array and causing havoc
Reply #27 Top
If I could reproduce it, I'd fix it. But I've yet to see it. And it's important to remember a lot of people have been waiting a long time and the issue is essentially cosmetic, the AI isn't benefitting from it at all.


As has been mentioned, I've seen it mostly while playing longer games with many planets. It seems that more planets means more chances for the AI to screw up, and thus probably why I end up seeing it. If this is really the case, I can understand why you guys are not finding it, afterall, we can't realistically expect you to play long dragged out games for balance testing (but I suppose that's why the AI doesn't play all that well at these settings as well).

As for being a cosmetic issue I'm not so sure about that. I mean, I completely agree that the AI isn't benefiting for this at all, but I would think that it is a terrible waste to be building a certain building and then upgrading to soil improvement or building multiple starports for no reason when he could be building something more useful (assuming he can still build ships from those planets unlike us). Which I believe, would mean that the AI is actually suffering because of this bug, perhaps a lot more than we are.


The AI already tries to do all these things. There is no easy pComputerPlayer->PlayBetter() function unfortunately.


I meant no disrespect for what I stated, I was simply recording what I've been seeing in my games and try to come up with a reasonable explaination for what is happening. If you guys can't sit around balancing the longer games, I thought I'd write up on how it would normally go (for me). Obviously I can't offer any conclusive suggestion on how to improve the AI because I just don't know how it is writen, hence why my suggestions are filled with "perhaps", "maybe", and "probably".

With that said, I still think that the AI needs to take more consideration about the galaxy setup (especially the number of available habitable planets) into mind when implementing it's early colonization efforts (no point in building colony ships at all in a tiny map with 10 star systems and 10 players). Perhaps focus a little more in infrastructure development and a little less in trying to get more money to buy ships on larger abundant maps. They just don't seem to have been able to adapt to the new population growth changes and tend to fall behind really quickly (on a fair playing field at least). They also need some stricter rules on facility placement. I mean, I can think of a set of rules that would not involve writing out scripts for the AI, something like:

1. If morale is below 40% ( no population growth), build morale buildings and remove all farm construction
- if not enough tiles (no morale building being constructed), and population is not maxed, upgrade a farm into one
- if not enough tiles, and population is maxed, rule bypassed (it shouldn't drop much lower anyways)

2. No morale building needed at 100% morale,
- unqueue all morale building to be constructed
- upgrading is okay, but upgrade one of them to something else (this will make sure you will never have too many)

3. Place farm and morale building at the same time, and only when population is near maxed (90%).
- if not enough tiles for both, place economic building instead
- (this is a base building requirement, sometimes it's not enough, but when that happens, it is fixed by #1)


With just these three rules in place, the AI can build normally, but will never run into the 6 farm but no morale building problem (#3 solves this), or the 5-6 morale building for no reason problem (#2 solves this), nor will it have too many farms (#1 solves this). This isn't really a script, more like a building guide line to prevent it from doing wacky economic things. The higher in the list, the more important the item, and thus, overriding the lower ones. I'm sure you could add all kinds of things to the list, like "All planets starts out building one factory" (The starport is usually bought outright), "Planets with PQ higher than 5, build 2 factories", and "Always upgrade factories next (as soon as current item finishes)". These would serve to help the construction efforts on these planets. Again, I'm not sure if something like this is being done (although these points regarding farms/morale obviously aren't), but from what I've seen it seems the AI relies on arbitrary "useful" values, and decides to build buildings based upon a number. While this is a simple approach (and probably best for modders), it will inevitable leads to those times when the AI build a really questional planet that just makes you shake your head wondering what it was thinking.
Reply #28 Top

I would like to add that there is a simple solution to most of the AI usage of planet tiles. The AI should focus on factories before building anything else on a planet. I don’t mean a mass of factories. I mean 1 or 2 to start, then begin adding other infrastructure.

It does already.

Reply #29 Top

No offense taken.

What I am saying however is that nearly everything mentioned here I agree with heartily. The problem is the difficulty in turning a strategy into code.

A couple people have said "Why does the AI research guns, beams, and missiles?"  The answer is, they shouldn't be. They have a weapon focus that they are supposed to be biased towards. The only reason they'd divert from this is if they believed their weapon was no longer effective because of counter-measures.

Similarly, the AI does focus on factories early on to get its economy going. But it's not scripted to do it. It's biased to do it though. 

It's biased not to build super projects and such on crummy planets.  It is supposed to escort ships.

General strategies for effective playing aren't hard to come up with. I know them. I've read other strategies too.  But turning those strategies into code that works well on all the different game options is very hard.

Someone observed "Why did the AI build a technology capital on a planet with only 1 research lab?"  Because the AI only had 2 planets and the other one was crummy and it was a smart thing to do in that instance.  It wouldn't be smart to do if they'd had 20 planets but that's a different story.

Nearly every strategy that people do mention works great - for their play style.  But I have to code something that doesn't just work on huge galaxies with tight clusters and rare planets. It also has to work on a tiny duel map with only 2 players.  It also has to work on a medium map with lots of planets.

Some people argue the AI should focus more on speed on its ships. And that's fine to a certain degree but then what about range? It's a lot more complicated for the AI to simply build constructors and put them out there for extending their range.  And then there's the question of when it should research warp drive over say research centers.  We all have different ideas.

Eventually my plan is to make scripts an option for modders.  That is, there will be an AI.XML file and each personality will have a "Use Script" option in which they can input things like what buildings they build and in what order, what techs they should research and tons of other things.  But scripts are bad news in general because, like Pac-Man, once you figure out the pattern, it's easier to defeat.

The GalCiv II AI does quasi-learning in a given game. It figures out what things were good and what things were bad and does more of the things that it thought were good. The question is always whether it can adapt in time to deal with a human strategy.

1. If morale is below 40% ( no population growth), build morale buildings and remove all farm construction
- if not enough tiles (no morale building being constructed), and population is not maxed, upgrade a farm into one
- if not enough tiles, and population is maxed, rule bypassed (it shouldn't drop much lower anyways)

2. No morale building needed at 100% morale,
- unqueue all morale building to be constructed
- upgrading is okay, but upgrade one of them to something else (this will make sure you will never have too many)

Like I said. It does these now -- in a general sort of way.  It is biased to do: if morale is lower than 50% actually it will try to build a morale based building. If it can't find one, it will attempt to upgrade a farm into one. If it can't do that, it will look for embassies or it will try lowering its taxes slightly to see if it helps.  But there's a lot more to it than you may realize.

Like I said, there is no easy pColony->DoSmartStuff().  There are a lot of things involved in deciding what to build based on countless factors. 

There are a lot of things that affect morale and what it should build.  What if the AI controls two morale resources? Should it tear down a farm then? What if its tax rate is at 74%? Maybe it shoudl lower the taxes?  Maybe it should research extreme entertainment and other morale improving technologies first before tearing down a building.  Perhaps it's designated that planet as a planet that it will be removing people for invasions and isn't as concerned?

 

Much of my work this weekend has been put into trying to deal with some of that.  But like I said, obvious things like how to build up planets and such are things that it's supposed to do but it's not easy to take an obvious strategy and turn it into code. 

Reply #30 Top
I emailed you a saved game and screen shot of the *upgrading an embassy with soil enhancement* bug. Hope that helps
Reply #31 Top
I think the one thing that would increase the AIs competitiveness more than anything else, especially on big maps, would be to make it use sneak attack or "Blitzkreig" attacks like human players do. Too often they declair war and then take weeks or months (on a gigantic map) to attack, giving the player time to prepare. It's a huge disadvantage to the AI to fight wars like this.
Reply #32 Top
Eventually my plan is to make scripts an option for modders. That is, there will be an AI.XML file and each personality will have a "Use Script" option in which they can input things like what buildings they build and in what order, what techs they should research and tons of other things. But scripts are bad news in general because, like Pac-Man, once you figure out the pattern, it's easier to defeat.

Would it be possible to have multiple scripts for different races, so they can be dependent on game setup and victory conditions? Also could there be an option to randomize between scripts so it's not predicatable? Could you also switch from script to AI decision making so you could just have a game opening script?

Is there a way to watch a game play without being involved so you can just observe and evaluate how well it works against the AI, and other scripts?
Reply #33 Top
A couple people have said "Why does the AI research guns, beams, and missiles?" The answer is, they shouldn't be. They have a weapon focus that they are supposed to be biased towards. The only reason they'd divert from this is if they believed their weapon was no longer effective because of counter-measures.

Well, I hope they aren't thinking that a lone +1 Defense will counteract their attack. Unless they are sticking with small and tiny hull. In which case, it may be very hard to put 2 low level weapon with some range and some engine
Reply #34 Top

Well, I hope they aren't thinking that a lone +1 Defense will counteract their attack. Unless they are sticking with small and tiny hull. In which case, it may be very hard to put 2 low level weapon with some range and some engine

Not at all.  It looks at all the ships that it is aware of and does some quickie battle sims with them, looks at their logistics, etc. and ONLY if the alternative techs it could likely get within a short amount of time is definitively better would it switch.

Reply #35 Top
I get the multiple starport bug all the time. There's nothing more frustrating then taking over a world and then saying there's no starport when you see two of them on the planet screen. Also, to those who are complaining about the AI researching all 3 weapon types. In all of the beta 4 games I've played so far the AI races always research mass drivers exclusively pretty much. I actually think it's better for the AI to research all 3 or at least two, because all I ever have to do is put a bunch of armor on my ships and that takes care of the AIs ships' effectiveness (especially since I always research defense more early then I do weapons). The AI never seems to start trying other weapon types even when the only defense I'm putting on my ships is armor, all they do is keep researching mass drivers and then I keep researching armor. I don't think the weapon teching is that big of deal, but the multiple starports bug is annoying.
Reply #36 Top
Reading this gives me recollection of a couple of things from my games.

1: Multiple weapons paths. I understand the reasoning behind following one branch. But I also like to have some options in reserve. I don't want to have to choose between one 4 attack weapon and two 1 attack weapons. As cheap as the early techs are, it's not a big deal to cover the bases, then specialize from there.

Same thing for defensive components. "Basics" are a 2 defence for each catagory. Same with weapons and a 2 attack rating. I will also design small hull ships that cover most of the areas. I then decide what custom ship design I will use for assualt.

2. The AI does not necessarily research all branches. Usually if an AI was all three areas of tech, is because I trade those early levels with them. I want them to have varied options to choose from. And the AI trades those as well. It's how I cover my bases as well. Maybe the AI could take a diplomatic viewpoint of "we have no use for those technologies at this time". I know they are suppose to be more limited on weapons trading from their list (although I have seen the opposite to be true, esp with the Drath and mass drive tech). But also more limited on what they might accept in trade. The more tech you have researched, the more expensive the next tech gets. Flooding the AI with every early tech you can grab makes it much harder for them to obtain the focused techs the are programmed to get.

3. The AI is paranoid. It seems to want to counter my garrison ships (early cheapies), and because those represent almost every branch in the tree, It does a poor job at it. With some early agression (triggering the pattern recognition?) it starts to try and counter something that will never happen. I might leave Armor absent from the garrisons, so they build a lot of mass driver ships. However the actual attack ships waiting in the queue are armor heavy. If the higher percentage of garrison ships have beam weapons, the invasion ships will not use those. As the AI will be shield heavy.

The tech flooding and ruse garrisons were not something I put together and then tried. Eye is not dat schmart. But nonetheless, it appears to completly dumbfound the AI.

Perhaps the AI instead of looking at ALL the ships on the map to decide what it should build/design, have it look at ships used in combat, namely attack ships (couldn't this be tracked game long in a single file?). it should also stick to it's primary weapon/defense choice for defenders as it will give it the best coverage (imo), and it's interceptors focusing on a different area. (you have to get past my mass driver interceptors with shields to get to my defenders that have beams and point defence with armor, for example).
Reply #37 Top
I would like to add that there is a simple solution to most of the AI usage of planet tiles. The AI should focus on factories before building anything else on a planet. I don’t mean a mass of factories. I mean 1 or 2 to start, then begin adding other infrastructure.


Eh, that's only one decent way to do planet tiles, especially early in the game. Another is to set industry & military both to 0%, and buy a labratory or two before buying a factory. Buy a colony ship or a constructor as well, as appropriate. Doing this lets you get a big, quick, leg up on research, usually getting a tech every turn the first 5 turns or so, and only then turning up industry, after a factory or two has also been built.
Reply #38 Top
... wow. I'll admit I've never tried that, but frankly I don't think 5 turns at the beginning makes much of a difference because you can make up all those tech really quickly. Most of the starting game I'm focusing around 80% into military. I have to wonder though, just what difficulty and galaxy setting are you playing at, because wasteing money buying labs and on research you're sure to get out colonized (unless of course, there is nothing to be colonized).
Reply #39 Top
Nice one FrogBoy, no idea how in the world you manage to posts all this information on this website, WC, and all the many others you visit daily. You must type 120-200 wpm or get hardly no sleep!
Reply #40 Top

You must type 120-200 wpm or get hardly no sleep

Heh. Actually I do type 120wpm.