AI suggestions thread

The Great Apple

Big Cheese
Joined
Mar 24, 2002
Messages
3,361
Location
Oxford, England
I posted a thread up on the Stratagy and Tips forum about the current AI and ways to improve it.

Not very many responses so far, although one of them points out quite a few minor flaws with the current AI which have quite far-reaching overall effects.

MrCynical said:
Well in no particular order a few specific problems I think the AI has:

1)Failure to recognise it's a bad move to found a city that is not on the coast, but has several sea tiles in its radius.

2)Even allowing for chopping being toned down in 1.61 the AI still keeps far too many forests.

3)All AIs refuse outright to trade techs only they own, even when this is detrimental to them (e.g. when they could trade it to two other civs for a tech from each).

4)AIs leave far too many units simply sitting in cities while relatively small numbers of enemy troops are in their land. This is particularly bad with navies, where the AI will leave a dozen ships sitting in a city while a couple of mine they could easily destroy pillage their improvements. Similarly the AI does not remove ships or great people from cities in imminent danger of being captured.

5)After the initial attack the AI tends to just send units into enemy territory as they are built rather than building up a powerful force, making it much easier to wipe them out since they can be picked off one at a time.

6)AI builds far too many workshops, especially given they rarely run State Property.

7)General poor usage of Great People, particularly in the early stages where the AI tends to use them for golden ages. They would be far better used as super specialists, academies, for discovering techs etc at that stage.

8)AI fails to recognise that coastal cities which are icebound do not have access to the ocean, and will then build ships which can never leave the city.

There are also a few specific leaders which play badly as part of their personality. Tokuwaga for instance invariably cripples himself due to his isolationist approach and objection to open borders.
Personally, I think 1), 2), 6), and 8) should be fairly easy fixes, with 7) only being slightly tougher. Anybody want to have a go?

I also disagree with 9) myself - I think the AI's should have their personalities, and it adds quite a bit to the game.
 
I think the AI can be improvend by far without actually changing it. There are just a lot of small changes where each one would bring great improvement.

Example: Victory Conditions
I have not yet found code that tells AI to archive a victory condition. But it should be relative simple to do so. The Ai has to decide which one or two Victory conditions it wants to archive (relative easy), and as result of this decision i believe there would be realtive small changes needed:
- For culture 4 cities should get a flag that lets them prefer culture producing buildings, and increase their defense. Furthermore spare commerce should be convertet to culture with the slider at one point.
- At space race it is already competeteive so there we would not need to do much.
- For Conquest and Domination the affinity to make peace when the war goes well, has to be decreased, the AI_MILITARY weight must be a bit increased and the war threshold must be reduced.
- Diplomatic hmm thats maybe more difficult, but some minor changes in the Diplomatic AI should do the trick.

All of those are rather small changes but i'am quite sure that when well done they will do the trick. Especially as not every AI has to really archive one Victory condition, its enough to exert pressure on the player when only one or two of the many AIs in each Game make a good rush towards the Victory.

Promotions: i'm working on this as there are some strange things... for example a Archer on a hill inside a city won't promote Gurillia.

Now to comment the post above:
1) Might be silly but sometimes not (keyword: coastal bombardement)
2) Is dependend on the Values each improvement gets assigned. I might revise that one.

4) & 5) Seems quite important on me. on the other hand, the ai often suicides units that sit in a city against a huge stack of doom. I think there have to be done several adjustmenst in this area.

6) Could not veryfy that up to date, but might be corrected when i revise the improvements.
 
Agree with victory conditions and promotions - needs to be sorted.

I hadn't considered coastal bombardment, however surely the benifits of all those extra improvements you can get by the sea outweighs that? Hmmm.

The unit AI seems to me to be one of the more complicated parts of the AI, as well as being one of the most critical, and time-intesnsive. It's also sometimes quite hard to define what is "better" with the it.

I've been trying to put together a ruudimentry AI testing rig with limited success. I've managed to get the AI to play itself, with logging of the relative scores and powers. Next step is to see if I can get the game to restart after each test run - slightly more tricky!. The method I'm using to separate the AIs is also very crude, leaving the functions of the first half of the AI's alone whle changing the second half's functions.
 
The Great Apple said:
I've been trying to put together a ruudimentry AI testing rig with limited success. I've managed to get the AI to play itself, with logging of the relative scores and powers. Next step is to see if I can get the game to restart after each test run - slightly more tricky!. The method I'm using to separate the AIs is also very crude, leaving the functions of the first half of the AI's alone whle changing the second half's functions.

I am working on a system for pluggable AI's, so you will be able to override whatever functions you want and choose for each player which AI you want to use. How are you determining which logic to use? Are you saying you are doing "if (playerID < (numPlayers / 2))" or something?

Daniel
 
dsplaisted said:
I am working on a system for pluggable AI's, so you will be able to override whatever functions you want and choose for each player which AI you want to use. How are you determining which logic to use? Are you saying you are doing "if (playerID < (numPlayers / 2))" or something?

Daniel
Pretty much. Actually I'm using "if (playerID < ((numPlayers + 1) / 2))" with the human taking up the zero slot, but this may be just because that's the way I've implemented it.
 
Do you use mirror maps and kind of mirrored leaders to test your AIs? That might be the best choice as you minimize Map and Leaderheadeffects, but generate a realistic surrounding.
 
The Great Apple said:
Pretty much. Actually I'm using "if (playerID < ((numPlayers + 1) / 2))" with the human taking up the zero slot, but this may be just because that's the way I've implemented it.

I had the idea that the barbarians / animals took up the zero slot, but I don't think I actually saw it in the code, so that might not be right.

Anyway, I wish I had more time to work on Civ 4 :) Hopefully I'll have some part of my AI framework out within a week.

Daniel
 
Chalid said:
Do you use mirror maps and kind of mirrored leaders to test your AIs? That might be the best choice as you minimize Map and Leaderheadeffects, but generate a realistic surrounding.
I was going to try and crack the auto-restarting before I did this - I might just leave it to dsplaisted, as I'm not going to be able to do much work at all in the 9 week period starting Saturday (no compiler/Civ access)
 
The Great Apple said:
I was going to try and crack the auto-restarting before I did this - I might just leave it to dsplaisted, as I'm not going to be able to do much work at all in the 9 week period starting Saturday (no compiler/Civ access)

:eek: :eek: Ouch! Nine weeks! What's going on? I'm going to Brazil for two weeks in about a week, and I thought that was bad :)

Daniel
 
dsplaisted said:
:eek: :eek: Ouch! Nine weeks! What's going on? I'm going to Brazil for two weeks in about a week, and I thought that was bad :)

Daniel
I'm off back to university. I can't take my PC with me - it's far to big and bulky to transport - and besides, I won't really have much spare time anyway.
 
About the AI framework:

What would be ideal is if it were possible to run, say, 100 full game tests, where the AIs would play against each other on a well balanced (maybe mirrored) map, with random Civs, the results being recorded in a file without any user interaction required. This would give alot better indication of whether the new AI was better or worse in direct comparison to the old.

Of course, we'd be designing AI's to beat AI's, which might all collapse in a horrible mess as soon as an unpredictable human comes along, so human testing would have to be a neccesity... but it would at least give a good indication.
 
How is this coming along? As you all know, I've been prying into (more accurately, asking all of you to pry into) AI behaviors and was wondering if the goal at this point is to (a) optimize AI for vanilla or (b) optimize it to be "smart" under different mod conditions.

Obviously AI is the "final layer" of any other mod that adds more game functionality. If we enable civics to have more effects, the AI needs to account for those effects.

I've now learned that the AI is very delicately balanced and presumes a certain heirarchy of programming. For example, improvements are built based on "natural" values, and civic selections made on the basis of what improvements exist. This makes the AI blind to civic-adjusted improvement values, but also prevents it from digging itself into a hole where the more improvements it has, the more it likes the civic, and the more improvements it builds, etc... All of this is to say, sometimes making the AI only halfway smarter would actually be worse than leaving it stupid.

OK, well none of this was actually work, just idle chatter...
 
The AI is one of the things I'll start work on when I get back from uni. I'm not sure anybody else is doing anything on it at the moment.
 
Top Bottom