The Big Question - How Does The AI Choose Which Units To Build?

Tom2050 very interesting results and quite allot of testing. Ozzy I also have noticed that the AI builds different mixtures depending upon the civilization. I wonder how much the abilities and aggression level affects builds.

I have also noticed the different mixtures of different civs... the thing that must be causing this is the culture group a civ is in. I will do some testing to see if this is true or not. As far as I know about the aggression levels in the editor, it will cause them to declare war more often (and even that may not be completely correct), but I may rerun a few of these tests at aggression level set to 5 or 1 to see if there is any noticable change (of course, there is likely to be some change from random picks).
 
Think about the sequences of units available at any given time in a vanilla game: that's the range of choice the AI is equipped to deal with, so it doesn't have to decide which is the best attacker, the best defender, etc.

Not only that, but almost every single unit in the basic game can be upgraded... which can be seen as simply allowing the player to upgrade older units, but I think it was done equally to facilitate for the AI's shortcomings. It is an easier way to include many units while allowing the AI to 'appear' smart.

When Civ 3 first came out, the majority of people said the AI was very smart... because the basic game gives this perception. When, in reality, it is just the way the basic game is set up, to create the look of a smart AI. The AI is actually quite horrible, and most units don't even do what they are supposed to do very good (artillery). :rolleyes: Ha!

Not only that, air units didn't even work in the initial release! LoL
 
(FWIW, in my experience the AI doesn't build many Longbowmen.)

Depending upon the Civ you play as you will see them being built fairly heavily and of course other factors come into play like later units that require resources (horsemen).
 
Depending upon the Civ you play as you will see them being built fairly heavily and of course other factors come into play like later units that require resources (horsemen).

Are you possibly thinking of Archers? I ask because i) the AI more commonly builds these (in my experience) and ii) unlike Longbowmen, they do indeed come before Horsemen in the tech tree.
 
I wonder if the AI would build more Artillery if it had the Stealth Attack ability? This shouldn't change anything gameplay wise (they still can't physically attack), but it could push the AI into building more...
 
TLC? I thought you had completly disappeared. Welcome back! :goodjob:

Heavens! - Ditto :) It's almost like a reunion - I actually found Sween32 (!) on-line last night and sent him greetings.

Best,

Oz
 
I'm going back and re-reading some of the other tests that were done, but in reference to build often flags in the editor, I think it would somewhat safe to assume that:
- there are 15 build often flags (100/15=6.67)
- at most, basic game has only 4 flags checkmarked, and reports say checking more than 4 (or even 3) may have strange effects on the AI
- it would be probable that each box checked adds at least a 7% chance of a unit being built, although it may be higher.

I agree with some of the other views that have been expressed, in that each unit has it's 'points' tallyed up in some (probably arcane) fashion, and then depending on how many points each unit has during the game compared to others increases or decreases the 'chance' of it being built (along with the screwy random factor, or perhaps the range, that is added in, to give variety to the AI's build).

I noticed some different build numbers with Germany and Russia that I have been testing, but then I realized they are from the same culture group, so it must have been due to just a 'range' of percentage chance the AI is allowed to build a unit.

I am going to try a few tests, each with a unit flagged 'offense' and 'defense', and 1 test would have 'build offense' often and another 'build defense' often. Simple, and should show a big enough difference.
 
How much weight does the AI put on various 'Flags'???

So far, with all other things being equal... these are my results on flags...
'All tests done with both units tagged for 'offense and defense'
Most tests done with 700 builds
Test Unit: 5/5/1 with ability specified
Base Unit: 5/5/1 with no abilities


Unit - # built (out of 700) - % built

Stealth:
Stealth Unit - 663 - 95%
Base Unit - 37 - 5%

Enslave:
Enslave Unit - 596 - 85%
Base Unit - 104 - 15%

All Terrain As Roads:
ATAR Unit - 238 - 71%
Base Unit - 98 - 29%

Speed: The faster the unit the more likely the AI will build it.
Speed Unit (M=2) - 453 - 65%
Base Unit - 247 - 35%

Radar:
Radar Unit - 419 - 60%
Base Unit - 281 - 40%

Zone of Control:
ZOC Unit - 418 - 60%
Base Unit - 282 - 40%

Hidden Nationality:
HN Unit - 397 - 57%
Base Unit - 303 - 43%

Starts Golden Age:
Golden Age Unit - 387 - 55%
Base Unit - 313 - 45%

Unit can upgrade:
Upgradable Unit - 384 - 55%
Base Unit - 316 - 45%

Blitz:
Blitz Unit - 378 - 54%
Base Unit - 322 - 46%

Pillage:
Pillage Unit - 373 - 53%
Base Unit - 327 - 47%

Detect Invisible:
Detect Invisible Unit - 367 - 52%
Base Unit - 333 - 48%

Invisible:
Invisible Unit - 329 - 51%
Base Unit - 315 - 49%

I thought Golden Age and Hidden Nationality would have scored higher than they did. Also, Invisible and Detect Invisible flags do not appear to have any impact on AI building priorities.
 
The Build Often Test
The tests are done with 2 units, a 5.5.1 unit flagged as offense, and a 5.5.1 unit flagged as defense

Test 1:
No Build Often Flags ticked in the editor
Offense Unit - 357 - 51%
Defense Unit - 343 - 49%

Test 2:
Build Offensive Land Units Often ticked in editor
Offense Unit - 362 - 52%
Defense Unit - 338 - 48%

Test 3:
Build Defensive Land Units Often ticked in editor
Offense Unit - 346 - 49%
Defense Unit - 354 - 51%


The strange thing here is that on Test 1, Germany and Russia built different numbers of each unit, but on Test 2 and 3, Germany and Russia built exactly the same number of each unit! Coincidence? I dont think so, it must be forced in the programming to have the AI create as many offensive or defense units as is 'allowed'.

This what not the stellar change of numbers I was expecting, and is so low of a change, it almost makes the build often seem somewhat worthless, but if anyone has any ideas on how to further test this, I would be willing to try it.
 
TLC? I thought you had completly disappeared. Welcome back! :goodjob:

Thanks. :) For various reasons I sharply cut down on my forum participitation last year, but I still check in here occasionally.
 
Build Often Test 2

The tests are done with 2 units, a 6.4.1 unit flagged as offense, and a 4.6.1 unit flagged as defense

Test 1:
No Build Often Flags ticked in the editor
Offense Unit - 352 - 50%
Defense Unit - 348 - 50%

Test 2:
Build Offensive Land Units Often ticked in editor
Offense Unit - 365 - 52%
Defense Unit - 335 - 48%

Test 3:
Build Defensive Land Units Often ticked in editor
Offense Unit - 358 - 51%
Defense Unit - 342 - 49%

From the previous test, I figured that it may have been the fact that each unit had the 5 for both offense and defense... but this shows absolutely no change in the percentage of units built by any significant amount to determine anything, the differences are most likely just the 'variation' factor kicking in.

From the looks of it, the 'build often' flag might only cause units to be built more often at a rate of perhaps 1%.
 
The Build Often Test
The strange thing here is that on Test 1, Germany and Russia built different numbers of each unit, but on Test 2 and 3, Germany and Russia built exactly the same number of each unit! Coincidence? I dont think so, it must be forced in the programming to have the AI create as many offensive or defense units as is 'allowed'.

I found that the AI builds Defensive:Offensive weapons at APPROXIMATELY 60%/40% without "build" flags checked.
 
Seriously, though. I am basing this on a test Ozymandias did with regards to a 3.2.1 2hp defender being chosen over a 6.4.1 1 hp defender (the 3.2.1 is the better defender and attacker, statistically). So the AI is aware of the importance of hp (nearly as important as AF/DF values)... I am going to create units that solely based on their AF/DF values appear inferior, but are in fact superior to other units.

Just to bring up this again, with the 3.2.1 2 HP being chosen over the 6.4.1 1 HP unit...

Defensively, the 6.4.1 1 HP unit does have the better chance statistically on terrain that gives a 10% bonus, against units with more Hit Points (because the more Hit Points the offensive unit has, the defense factor comes more into play, although by an incredibly small margin). On any terrain that gives higher defensive values the 3.2.1 2 HP unit wins (because the HP dramatically increases the chance).

Offensively, the 3.2.1 2 HP unit wins more often unless the defender has a very high defense, in which the 6.4.1 1 HP will have the better chance.

This would show that the AI likely compares these values against other units that it can currently build, in this case it would compare statistics of winning of these 2 units (on defense and offense the 3.2.1 would win against the 6.4.1). The human player would likely hands down pick the 6.4.1 1 HP unit over the 3.2.1 (I probably would) :cool:. Because if each unit has more hit points, the 6.4.1 becomes the stronger. The AI probably does not compare it's units to units other civs can build.
 
Cost Factor
Both units tested are flagged both offense and defense.

1st Test:
I am testing 2 exact same units, the only difference being the shield cost of the 2.

Base Unit (5.5.1) - cost 10 shields - 302 - 43%
Base Unit (5.5.1) - cost 15 shields - 398 - 57%

CONCLUSION: The AI will more often build more expensive units, when all else is the same.

2nd Test:
I am testing 1 Base Unit at 15 shields Vs. a Better Unit at 10 shields

Better Unit (6.6.1) - cost 10 shields - 488 - 70%
Base Unit (5.5.1) - cost 15 shields - 212 - 30%

CONCLUSION: This may have seemed like a stupid test! But I guess it shows that the AI will look at stats over the cost of a unit. Although the increased cost of the Base Unit probably made the AI produce more of them than it normally would have, so I decided to test this theory.

3rd Test:
I am testing 1 Base Unit at 10 shields Vs. a Better Unit at 10 shields

Better Unit (6.6.1) - cost 10 shields - 517 - 74%
Base Unit (5.5.1) - cost 10 shields - 183 - 26%

CONCLUSION: Dropping the cost of the worse unit made the AI produce LESS of them! So as a general rule of thumb, higher cost will make the AI produce that unit more often.

4th Test:
I am testing 1 Base Unit at 10 shields Vs. a Better Unit at 15 shields.

Better Unit (6.6.1) - cost 15 shields - 525 - 75%
Base Unit (5.5.1) - cost 10 shields - 175 - 25%

CONCLUSION: Again, the AI will build a better unit more often when it's cost is higher.

5th Test:
I am testing 1 Base Unit at 10 shields Vs. a Better Unit at 15 shields + Requiring Horses.

Better Unit (6.6.1) - cost 15 shields + Horses - 530 - 76%
Base Unit (5.5.1) - cost 10 shields - 170 - 24%

CONCLUSION: A unit requiring a strategic resource does not appear to make the AI build more of these units.



Overall conclusions: The higher the cost of a unit, the more often the AI will build that unit, although the main thing the AI looks at when considering what to build is a unit's stats. Strategic Resources do not appear to effect how often the AI builds a unit.
 
Strategic Resources
Both units tested are flagged both offense and defense.

Test 1
I am testing 1 Base Unit Vs. a Base Unit Requiring Horses.

Base Unit (5.5.1) - requires Horses - 384 - 55%
Base Unit (5.5.1) - requires nothing - 316 - 45%

CONCLUSION: A unit requiring a strategic resource appears to have a very small impact on AI build choice (5% at most with all else being equal... in a normal game, the difference would not be noticable).

Test 2
I am testing 1 Base Unit Vs. a Base Unit Requiring Horses, Coal, and Iron.

Base Unit (5.5.1) - requires Horses, Coal, Iron - 377 - 54%
Base Unit (5.5.1) - requires nothing - 323 - 46%

CONCLUSION: A unit requiring more strategic resources has no additional impact than 1 strategic resource.
 
Just a note, in the editor I have added the defense flag to some units during tests (out of offense, defense, random), to have them act as city garrisons, so I get more accurate results in my tests. I have noticed that sometimes the AI will send these units out, and they will cross paths with the other enemy AI, but they will never attack any unit! They just 'roam' around (of course it probably would eventually, I did not follow it around for long).

Ozy, I am compiling all the 'known' info together, if I send it to you, perhaps you could add the info to the first post so it can be easily viewed. Or, if you wish, I can update 1 of my posts with everything that is known, and you could add a link to that post to the first page... however, doesn't make a difference to me.

Tom
 
I found that the AI builds Defensive:Offensive weapons at APPROXIMATELY 60%/40% without "build" flags checked.

I have seen it more of a 50/50 thing, a pure equilibrium... when I first started testing, I had no defenders in any of the AI's cities, so they always built defenders first, and it mucked the results all up... since I placed defenders in the cities (2 in each, 3 in capitol), it seems to build at more a regular rate throughout the whole test. And since has been at a 50%/50% rates usually with a 1-2% variation. I know this was discussed earlier, and because of this, it seems like the 'layout' of the map or how close AI cities are to each other may also have an impact on what a city produces. But I know (I think) you placed defenders in the AI cities to get correct results, so this would show that proxity of a city to another city (or may be some other factor :crazyeye:) may have an impact on build priorities.
 
My current tests are aimed at finding how much 'weight' the AI places on each attack and defense value for a unit. I may do tests starting with a 1.1.1 unit and compare this base unit to a 2.1.1 and a 1.2.1 unit, etc... to try to see if there is some type of pattern that the AI goes by. If we can discern this pattern, it would be extremely helpful in understanding how they build. Of course, if it's a simple matter of comparing 'win percentages' of 1 unit vs another (as can be seen in the Combat Calculator), then it may go by that, and not place a 'weight' on the A/D values.

But since the AI will still build inferior units, it has to place some kind of 'weight' on the values regardless.
 
Top Bottom