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

Ozymandias

In Terra Fantasia
Supporter
Joined
Nov 5, 2001
Messages
10,878
Location
The lone and level sands
I think the answer to this question might very well be The Holy Grail for mod makers. AFAIK no one has figured it out, nor has Infogrames or anyone else published it.

So I think we should find out -- and I'd like help devising a simple mod/scenario to ascertain this.

I'm thinking very simple -- two AI players + 1 human, start with three cities each, equal resources per city, capped growth, no settlers or workers, and an easy era to work with -- say, some fictional pre-gunpowder time and place with each player able to build the same types of infantry, cavalry, artillery (although I'm happy to let this last one go for Round One).

The available types should have close variations in values -- e.g., three cavalry, one "heavy" with a movement of two, one "light" with a movement of three, one horse archer (bombard 1(0) or 0(1) )

... And of course there are all the lovely factors to take into account --

ZOC
Blitz
Extra Hit Points
Hidden Nationality
Invisible
"Defensive" vs. "Offensive" AI preferences.
Etc.

The measure of success for "Round One" would be to have the the AI appear evenly likely to build any of three of the same types of units (offensive/cavalry; defensive/infantry; etc.)

-- Thoughts, observations, ridicule, volunteers to work up some sort of criteria testing "matrix", etc.?

Yours Pondering The Eternal Mysteries Of Civ,

Oz
 
In the editor there a some flags called "build often", in there you can set offence, defence and alot of other things. This have an effect on the AI build choice. The cost of the unit also has something to do with thier choice. The AI does´nt look at the stats, they just look at the cost of a unit. So they would prefer a 1.1.1 to a 2.1.1 if the 1.1.1 was more expensive.
 
Originally posted by Yoda Power
In the editor there a some flags called "build often", in there you can set offence, defence and alot of other things. This have an effect on the AI build choice. The cost of the unit also has something to do with thier choice. The AI does´nt look at the stats, they just look at the cost of a unit. So they would prefer a 1.1.1 to a 2.1.1 if the 1.1.1 was more expensive.

Hi Yoda,

Thanks for the info on cost-preference; I had only noticed higher AF preference -- but of course these were also more expensive.

Insofar as the "Build Often" etc. flags go -- Yes, of course; stated another way, my point is to see if the AI, presented with, say, three different offensive cavalry types (and, thanks to you, I can and must add "of the same cost" :) ) can be made -- through whatever machinations -- to produce them equally.

You also raise another good point: many of us have undoubtedly uncovered (or, in my case re: AF) think we've uncovered various truths about this issue -- I would be VERY pleased if everyone felt free to post their "anecdotal" observations -- the tough part of what I'm suggesting is the methodology, the plan to isolate and step through different factors. Knowing, up front, that certain items can be eliminated or must be included would be very helpful!

Thanks Again,

Oz
 
What the AI builds is based alot on cost, as well as on what special traits a unit has. We're still working on balancing what the AI builds with ACW, and I should be able to post here soon alot of things which are influencing what the AI builds. We're performing alot of rigid testing.

The AI I know tends to lean toward Cavalry type units, as well as defensive units.
 
Originally posted by Procifica
What the AI builds is based alot on cost, as well as on what special traits a unit has. We're still working on balancing what the AI builds with ACW, and I should be able to post here soon alot of things which are influencing what the AI builds. We've performing alot of rigid testing.

The AI I know tends to lean toward Cavalry type units, as well as defensive units.

I'm glad you folks are doing "rigid testing" :goodjob: -- & I just downloaded ACW!

Some random questions --

Q1: Would you mind expounding a bit on how you're going about testing?

Q2a: Does the AI lean toward cavalry units and defensive units irrespective of whether any of the Civ's "Build" flags are checked?

Q2b: As there isn't a "cavalry" type unit attribute in the editor, are you simply defining cavalry as faster-moving units? Do they have blitz/ZOC etc.?

Q3: Any hidden nationality / invisible units in play?

Many Thanks,

Oz
 
Early Cavalry units in ACW have the ZoC flag marked, and have movement of 2. These units seem favored somewhat by the AI despite their lower attack/defense values and significantly higher cost.

Testing is being done in several ways. One way is observing what the AI is throwing at you offensively, and what its using defensively, while another is using espionage and finding out exactly what its building in each of its cities. More information can be found in various posts in the ACW thread.

There are some invisible units in ACW, though production of these hasn't been reported that high (they're limited to certain cities in the Confederacy only, except for the Raider/Union Rider which are later in the tech tree).

With regard to the Civ build flags, we've tried forcing the AI to build naval units but with no success so far. Right now that flag is checked, along with offensive/defensive units, and artillery units (also not being built by the AI).

Balancing out what the AI builds isn't easy though, that's for sure. I know there is a bit of randomness to it.

Also, the AI seems to favor greatly, any units which have extra HP on them, unless the cost is significantly higher. What I've been doing for ACW is adding a X cost multiplier for any special flags added to a unit, and these seem to be having some success (example, movement of 2 is 1.25 * base cost).


The latest test version is probably more in tune with what we want the AI to be building, but its still in testing. :) Ideally, we want the AI to build about a 10:1 ratio of infantry to cavalry as the Union, and about 6:1 as the Confederacy.
 
By the way, stats do seem to play somewhat of a role, as much more Cavalry was built when the attack/defense values were closer to regular Infantry.
 
The AI will always build a defender in an empty city (if able to).

Apparently it goes for the cheapest available defender in this circumstance - the Greek AI prefer to build a Hoplite over a Rifleman at the start of Future Era Start scenario.

Irrelevantly, but interestingly, the AI disbands any starting Scouts at the begining of a scenario with Map Explored checked.

Anecdotally, it sure seems to me that the AI is aiming for a given ratio between offensive and defensive units, altho perhaps that ratio is dependent on some factors like being at war/peace, Aggression Level, etc. In any case, the AI tends to overemphasize defensive units.

Edit: Spelling
 
:) See: within 8 posts we've already gleaned the following working hypotheses:

1. All flags being equal, the AI will build a higher cost unit.

2. "Build Often / Never" flags are problematic -- BTW this seems especially true, every time I've played, re: artillery and naval units -- I just don't think the AI is particularly well programmed for these, although of course there are always some amusing and/or astonishing surprises ...

3. The AI seems to greatly favor any units which have extra HPs, unless the cost is significantly higher (question to Procifica - are you using the same 1.25 multiplier, for the time being, for all flags? -- ZOC, Blitz, Invisible, etc.?)

4. Again from ACW, we learn that "Early Cavalry units" -- i.e., faster units (move=2) with ZOC are somewhat favored despite their having lower attack/defense values and significantly higher cost than infantry units. (From a methodology POV, this makes me think that first arriving at how the AI values the combination of speed + ZOC together would be easier and more immediuately available to modders; Step Two would be to tease apart their relative weightings.)

5. If able to, the AI will always build a defender in an empty city, apparently choosing the cheapest available defender -- this is VERY good news when contemplating "Territorial / Reserve / Landwehr / Whatever" units in a mod!

6. The AI disbands any starting Scouts at the begining of a scenario with Map Explored checked -- Question: will the AI build any "Explore" units at all with that flag checked??

7. All things being equal (... whatever that means at the moment ;) ) the AI will give some preference towards building defensive units.

Not bad! :D -- And there will be much more to follow, I hope and trust!

Best Regards To All,

Oz
 
Originally posted by Yoda Power
The AI does´nt look at the stats, they just look at the cost of a unit. So they would prefer a 1.1.1 to a 2.1.1 if the 1.1.1 was more expensive.
I'm not sure this is true. When I was testing added units, All of them were 1.1.1, and I forgot to give a cost to some of them (they had a cost of 0).
Those cheaper units were the ones favored by the AI and by my governors.
 
Originally posted by Spiffor

I'm not sure this is true. When I was testing added units, All of them were 1.1.1, and I forgot to give a cost to some of them (they had a cost of 0).
Those cheaper units were the ones favored by the AI and by my governors.

If I'm understanding this correctly -- you're saying that, given units with equal attributes, the AI will build the cheaper of the two? -- If so, for once, at least, I'm unsurprised! :)

Thanks,

Oz
 
in my experience with customized scenarios, the AI doesn't always built the best available offensive units, they seem to prefer the cheaper but less powerfull off.units

example:
unit A: stats 8/4/2
unit B: stats 5/4/2 (but cheaper)
result: the AI never builts A, the scenario was swarming with unit B
 
BTW, did anyone figure out how the AI choose what to build in Civ2? Presumably, the exact same procedure isn't used in Civ III - would work with a different set of ability flags, etc - but not unlikely something similar.
 
That complexifies things, of course. To be rigorous about something like this, one'd have to test each variable (cost, stats, abilities, dependences) separately.

But in any case, the AI's priorities are apparently not that good; clearly your unit A is better for a land offensive. Hm, but what AI strategies did the things have?
 
Unit A should be more expensive or Unit B should be cheaper. In this instance, the equal defense makes Unit A more attractive.
 
Does someone know if the resources needed for a particular unit play a role? Would the Ai prefer eg. a unit that needs one resource only over another unit that needs two or three?
 
the AI strategies differ from civ to civ, so that's probably not a factor. I control the seas & oceans with a massive fleet, so their's no need for the amfibious ability.

Unit B was available to them a few techs earlier. But with Unit A available, they still haven't switched the production.

I activated the explore button with the AI strategies on Unit B. Allthough at this stage in the game, there's nothing left to explore. Is it possible that this makes units very attractive for AI? Has anyone experienced similar consequences? Maybe that's the key to which units the AI prefers to built...
(unit A: offensive,defensive)
(unit B: offensive, defensive, explore)

Maybe stats aren't that important to the AI, maybe it's just how much strategies you have activated in the unit editor.
 
Top Bottom