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

So, the AI had a unit with an attack of 6, a unit with a defense of 4, both with +1 hp and they still built several 1-1-1 warriors!! Maybe 'detect inviso' can be used to motivate the AI?

Yes, it is strange indeed. From the tests I have ran, I have come to the conclusion, that there IS ALWAYS a chance that the AI will build any unit available, if given long enough to do so. So if you have a 900-900-2 unit and a 1-1-1 warrior, the AI may eventually build the warrior but it would likely take thousands of thousands of turns. (although there is likely the possibility that the likelihood could hit 0% if the algorithm rounds down).

My guess of how the AI build algorithm is setup is that each value that can be selected in the editor is assigned a value (of how valuable the dev's determined that value is), then the algorithm comes up with the percentage chance that any available unit will be built (probably with a +/- to a degree, to make it not too predictable).

This way, if you ran the same test again, it would likely be very similar, but probably the build numbers would be a little different by 1 or 2.

If a 'build unit calculator' could ever be developed, or figured out, this would be absolutely INVALUABLE to modders. Many things of great interest have been discovered though! And your tests show the AI puts a slight favor on detect invisible. Running the same tests with warrior not having detect invisible (to see how much it drops/if any) would give more insight as well.

Tom
 
Okay I did two tests. Using Tom's template test. Thanks so much for that Tom!

TEST 1 (20 Turns)

Spear: Att 5 / Def 5 / Mov 1 ~ +1 HP ~ Stealth Attack

Archer: Att 4 / Def 4 / Mov 1 ~ Bom 5 / Rng 1 / RoF 1 ~ +1 HP ~ Enslave

Horse: Att 7 / Def 4 / Mov 2 ~ Nothing extra


Results after 20 turns:

Rome:
Spear 156 (87%)
Archer 13 (7%)
Horse 11 (6%)

Egypt:
Spear 160 (89%)
Archer 9 (5%)
Horse 11 (6%)



TEST 2 (20 Turns)

Spear: Att 4 / Def 4 / Mov 1 ~ +1 HP

Archer: Att 3 / Def 3 / Mov 1 ~ Bom 4 / Rng 1 / RoF 1 ~ Stealth Attack, Enslave, Detect invisible

Horse: Att 8 / Def 4 / Mov 2 ~ Nothing extra


Results after 20 turns:

Rome:
Spear 16 (9%)
Archer 128 (71%)
Horse 36 (20%)

Egypt:
Spear 10 (6%)
Archer 130 (72%)
Horse 40 (22%)


Goal for both tests was to have the AI produce lots of spear, nearly as many archers, small numbers of horse.

Test one: Don't really understand this one. I can see why it favoured the spear unit as is was roughly the same as the archer but higher att and def. However, I would have expected the archer to be built at least twice as much as the horse as it had the extra HP and an AI prized flag.

Test 2: Interesting result, because it would seem the AI heavily favoured the worst unit (archer) becuase of the 3 flags I gave it. The archer was a worse unit than both the spear and the horse unit, as the AI has been proven not to take bombard into account.

In my next test I'll aim to balance the Spear and Archer units to roughly 40% each while keeping the horse unit at 20%. Perhaps taking one of the flags away from the archer and giving it to the spear unit.

Let me know what you think. I may be missing somthing here. Still it seems like a positive sign, to me, that inferior land units can be prioritised by the AI given the right combination of flags.

One last thing. Do you think 20 Turns is too few for an accurate result?
 
Gentlemen :) ,

I would direct your attention to THESE THREE POSTS in this thread.

Also, you might want to substitute another Civ for Egypt, as there appears to be some Jabberwocking (see Nick's sig ;) ) with the builds for that Civ.

Best,

Oz
 
Defense, Detect Invisible, Stealth Attack, More Moves, Hit Points and ability to Upgrade are strong Factors for the AI to build a Unit.

There are Random Factors involved that cannot be controlled. Still, the important thing is to know what settings to use that will tend to have the AI prefer to build one unit over another.
 
Defense, Detect Invisible, Stealth Attack, More Moves, Hit Points and ability to Upgrade are strong Factors for the AI to build a Unit.

There are Random Factors involved that cannot be controlled. Still, the important thing is to know what settings to use that will tend to have the AI prefer to build one unit over another.

Hey Amigo :) ,

I've not found that more MPs influences The Beast, although I'd be curious how it values multiple MPs with Blitz ability.

Yours,

Oz
 
Gentlemen :) ,

I would direct your attention to THESE THREE POSTS in this thread.

Also, you might want to substitute another Civ for Egypt, as there appears to be some Jabberwocking (see Nick's sig ;) ) with the builds for that Civ.

Best,

Oz

Read the posts. Interesting. From those tests, and from anicdotal evidence the AI seems to sometimes act more rationally than other times. Sometimes it does highly random things and other times it acts predictably. Perplexing.

Re Egypt. In my test their results were statistically very similar to Rome. But to be on the safe side I may not use them next time. It would be interesting to run the same test several times using different culture group civs each time to try and see if there is any pattern in the way culture groups behave.
 
Read the posts. Interesting. From those tests, and from anicdotal evidence the AI seems to sometimes act more rationally than other times. Sometimes it does highly random things and other times it acts predictably. Perplexing.

Re Egypt. In my test their results were statistically very similar to Rome. But to be on the safe side I may not use them next time. It would be interesting to run the same test several times using different culture group civs each time to try and see if there is any pattern in the way culture groups behave.

Also, to save us all some time, I don't believe that a Civ's Agression Level has any effect on its builds :(

-Oz
 
Concerning naval AI build (and maybe other), I wonder if anyone takes into account revealed AI map. Someone said AI wasn't producing naval ships until contact with some other civilization. Maybe it was not really because of contact, but because of the territory map/world map revealed which could make AI take different actions.

I don't know how many of your tests were with all map revealed, however I've noticed different AI behavior in relation to how much map I traded to it.

So maybe, getting map of an island with strategic resource makes AI to start building ships to get there. If so, making naval explorers to force AI to reveal sea/land could be the way to make it producing ships.

Not sure how it works with whole map revealed thou.
 
Concerning naval AI build (and maybe other), I wonder if anyone takes into account revealed AI map. Someone said AI wasn't producing naval ships until contact with some other civilization. Maybe it was not really because of contact, but because of the territory map/world map revealed which could make AI take different actions.

I don't know how many of your tests were with all map revealed, however I've noticed different AI behavior in relation to how much map I traded to it.

So maybe, getting map of an island with strategic resource makes AI to start building ships to get there. If so, making naval explorers to force AI to reveal sea/land could be the way to make it producing ships.

Not sure how it works with whole map revealed thou.

Interesting thoughts. Because my tests were so basic, I played without fog o' war.

What you say makes intuitive sense - I wonder if anyone who's done a mod with the situation/theory you describe might further enlighten us ... (hint, hint :coffee: )

Best,

Oz
 
Ozmandias, I have a question I hope you can answer regarding AI build choices for a mod. I have read through the entire thread but want a clear understanding of what I think to have been proven.

Take two units: (no special resource requirements for both units)

Infantry: 5/5/1, 2 hp 100 shields cost - listed as offensive/defensive
Cavalry: 3/2/2, 1 hp 100 shields cost - listed as offensive, can blitz

I assume that the AI will build (percentage wise) more infantry than the cavalry. Is this correct?
 
Ozmandias, I have a question I hope you can answer regarding AI build choices for a mod. I have read through the entire thread but want a clear understanding of what I think to have been proven.

Take two units: (no special resource requirements for both units)

Infantry: 5/5/1, 2 hp 100 shields cost - listed as offensive/defensive
Cavalry: 3/2/2, 1 hp 100 shields cost - listed as offensive, can blitz

I assume that the AI will build (percentage wise) more infantry than the cavalry. Is this correct?

That should indeed be the case, especially as (1) the AI (because of HP) is calculating the "5/5/1" as a "10/10/1" and (2) MP don't seem to figure into the equation.

One last point: I never did get around to testing flags, but even if the AI treated Blitz as a straight multiplier (which I doubt) it would still build the Infantry ...

... OK, a second last point ( :crazyeye: ) - the AI will also do its own evaluation of what's a Defensive and what's an Offensive unit - a 2/5/1 unit tagged "Offense" will generally be chosen over a 2/2/1 tagged "Defense" for defensive purposes.

... And maybe one day I'll test those flags ... some of them have a dramatic (so far unquantified) impact; others not so much.

Best,

Oz
 
Ozmandias, I am forever in your debt for the swift reply! I hope that everyone appreciates the work and time you have devoted into testing this part of the game!
 
Also, note that the Civ3 Combat Calculator will give you a good indication of which unit the AI will be more inclined to build (if units have no special flags).

In the instance above you gave for offense; against a unit with Defense 3, hitpoints 4, speed 1:
Brucha said:
Infantry: 5/5/1, 2 hp 100 shields cost - listed as offensive/defensive
Has a 86.259% chance to win the battle.

Brucha said:
Cavalry: 3/2/2, 1 hp 100 shields cost - listed as offensive, can blitz
Has a 63.672% chance to win. From tests, Blitz gives a small increase in chance to build.

Percentages are with both units being Regulars. So it is safe to say Infantry will be built more often here.

If you give the Cavalry 1 more hitpoint, the Cavalry win percentage goes up to 76.172%, which will make the AI build more of them for offense, but how many would have to be tested in game.

I believe the AI looks at it's chances of winning in game, much the same way as the Combat Calculator sees it. That is why the AI will never attack certain units if it deems it has pretty much no chance of winning (which seems to be if the chance is under 5-10%).

Tom
 
I've been having Internet difficulties recently, so can't even judge if this is still a good link:

http://www.zachriel.com/BattleCivulation.asp

Zachriel's versatile combat approximator (it doesn't give hard odds, but will actually carry through on the combat. It's good especially if you don't have the Civ3 Combat Calculator.

Also, re: Tom2050's comments on strength (and apologies if it's already in thei thread somewhere) the overall AI military evaluation algorithm might prove insightful, and which Ithink (curse ye Internet problems!) can be found HERE.

Best,

Oz
 
Back
Top Bottom