The BIG Q Continued - AI Flag Choices For Building Units

Ozymandias

In Terra Fantasia
Supporter
Joined
Nov 5, 2001
Messages
10,876
Location
The lone and level sands
So it's been a few years :mischief: I'm finally having a look at choices the AI prefers in flags while building units.

10 variants immediately suggested themselves, but an 11th gnawed at me.

I used a standard unit - 5/5/2, no extra hitpoints, no ZOC (as I wanted to test that flag as well). All units have AI Strategy of BOTH Offense & Defense, and cost 10 each.

The original 10 are/were:

1. No Flag (control vanilla 5/5/2)
2. All Terrain As Roads
3. Amphibious
4. Invisible
5. ZOC
6. Starts Golden Age
7. Hidden Nationality
8. Detect Invisible
9. Paradrop
10. Enslave
... And that gnawing #11, setting a unit to "Build Fort" - that one Terraform flag only, as in Roman Legions.

4 Civs, from the top: Rome, Egypt, Greece Babylon. All Aggression = 3, all build preferences and bonuses eliminated. Governor set to produce for Player (Babylon). Each Civ has 5 cities, and I ran 2 rounds of 10 turns of building.

ON TURN ONE, IN BOTH ROUNDS, EVERY CITY IN EVERY CIV CHOSE TO BUILD #11 - "Build Fort".

In Round One:
  • Rome built a total of 13 "+Fort" ; 33 Invisible ; 1 ATR ; 1 ZOC ; 1 Detect Invisible ; 1 Para
  • Egypt built: 16 "+ Fort" ; 23 Invisible ; 4 ATR ; 7 Para
  • Greece: 14 "+ Fort" ; 26 Invisible ; 3 ATR ; 3 ZOC ; 2 Detect Invisible ; 2 Hidden Nationality
  • Babylon: 5 "+ Fort" ; 45 Invisible (NB: this is a typical AI set of choices for the Governor for the Player

I truncated Round 2 to 5 turns of builds; I did this because the build pattern was nearly identical, with the exception that more "Detect Invisible" were built (between 1-6; the 6 was the Greeks, who otherwise only built ATR and "+ Fort").

I think next round I'll cut ATR and "+ Fort" (and add in Radar, which I just realized I forgot :blush: )

Conclusion: "+ Fort" is possibly a way to get the AI to build "lesser" defensive units. ATR I recognize as problematic as some Civers seem to have a considerable bias against this feature, yet it might be a way to nudge the AI into building recon units.

Best To All,

Oz

PS - The original thread can be found HERE.

-Oz
 
Just to be clear, even if the unit has the "Build Fort" option, if it does not also have the Strategy "Terraform," the AI won't use the unit to actually build forts... correct?
 
Oz, I think there is another important flag missing in your tests that seems to have a big influence in the AI decision what land-units to build: Stealth attack with targets.

In CCM tests it seems, the AI likes that option.
 
Just to be clear, even if the unit has the "Build Fort" option, if it does not also have the Strategy "Terraform," the AI won't use the unit to actually build forts... correct?
Almost sure you're right. Almost. Sometiems it freaks out, like actually behaving intelligently.
 
The "Build Fort" flag is (I'm 99% certain) a coding kludge used to accommodate the Legions in the Rome Conquest - it works (although the AI rarely seems to use the ability) as a "standalone" flag, an exception to the normal Terraforming rules (and, no, you won't find that documented anywhere).

@Civinator - good point. On the next run, I'll drop "Build Fort" and ATM and sub in Stealth. If Stealth proves anywhere near as relevant a choice as BF & ATM I'll start again. Any clues if relative DF strength plays any part in Stealth? (i.e., I'll be pitting 5/5/2s vs. other 5/5/2s.)


Best To All,
 
Huh, in my experience (particularly with my Tweaked Out mod), the AI tends to put preference for Hidden Nationality land units over all others... I found myself fighting off a constant stream of HN Mercenary units even in the modern age, when those units were obsolete and heavily out-classed by every single unit I had....

Ditto with the Sengoku scenario.

One contributing factor may be the fact that in my scenario, Mercenaries could "press-gang" (enslave) captured enemies as workers and they had the "Treat All Terrain as Roads" selected (They might have had the stealth attack option, but I'm not sure)...

Likewise, the Sengoku Scenario's Ninjas were ATR with Stealth Attack and Invisible....
 
Cool thread idea. Since you have determined that Invisible is the most sought after for these settings, perhaps do a whole series of tests, removing each top performer one by one until there is a list of most to least sought after.

Another setting could be to remove Civ build preferences for a "preferenceless" nation.

ON TURN ONE, IN BOTH ROUNDS, EVERY CITY IN EVERY CIV CHOSE TO BUILD #11 - "Build Fort".
Did you start each civ out with a worker or not? They may have thought that this is a worker unit plus...
5/5/2, no extra hitpoints, no ZOC (as I wanted to test that flag as well). All units have AI Strategy of BOTH Offense & Defense, and cost 10 each.
...is a very generous cost for a unit with those stats, plus the AI may have thought it included worker skills. Perhaps if it were 1.1.1, 10 shields?
 
In the unmodified War in the Pacific scenario, the AI as Japanese only built combat engineer units, as they were the strongest units available and only slightly more expensive than the infantry. When I dropped than back to a much more reasonable and historical value, the Japaneses began to build a range of units, concentrating on infantry, tanks, and artillery in what I felt were about equal proportions. An island being subjected to steady air attacks was building AA units. When I began to build up my navy, the Japanese AI began to build its up as well in Japan. There are times when I get the feeling that the AI is mirroring my strategy.

The problem with your tests are that they are being conducted in isolation from external influences. You are finding out what the AI will build when it is not interacting with a human player, and when the only variable is the "flag" added to the unit. All units have the same combat value, and the same price. That does not correlate at all with what occurs in the game, as least in the early eras. There you have a wide range of unique units. With the early units, I would expect the AI to build that civilization's unique unit at the highest rate, as that generally is the strongest unit. As a human player, I build the strongest possible unit. I would also expect the AI build based on location. If it is in a coastal city, there are islands nearby that I am settling and also have an invasion fleet building, the AI is likely to be building naval units and defenders.

In the later eras, the units available to all the civilizations are essentially identical in value: infantry are the same for all civilizations, except for the German Panzer, tanks are all the same, the artillery unit is the same for all civilizations, as is the mechanized infantry unit. The same holds true for Marines and paratroops. Unless you are going to create unique units for each civilization for the later ages you are going to have every AI civilization building essentially the same units in an ideal situation with no coastal cities to worry about nor any wars putting outside pressure on the AI. Also, unless you create civilization-specific units, you are going to be using those exact same units. Is that what you want to do? I have not even brought up the issue of air units or air defense units if added to the mix. Are you going to test those as well? What about cruise missiles and nukes?

How about you run a test of an AI coastal city, Modern Age with all techs researched, at war with another continent. Does it build Marines for its land units or something else? What ships does it build, and how many? What aircraft are being built, and are air defense units being produced?

Or better yet, study what is being built by the various civilizations in the War in the Pacific scenario. What does each city of each combatant build in the first say 10 turns, and does it correspond at all with what the civilization should be building? There the AI also has improvements that can be built, along with military units, and Wonders as well. You have 6 different civilizations, with 4 different government types, a lot of cities for each nation, and the pressures of a war on the building process.

I would submit that might have more validity about what units the AI will produce than the artificial tests you are doing.

By the way, when I run Axis and Allies in my historical gaming classes, typically, the only unit that the German player builds initially is tanks, since that is the best unit for attack available and is also what he needs to attack Russia. There are house rules now available that try to force the human player to build a range of units, similar to what is trying to be done in some of the Civ3 mods. The house rules are not that widely used, because people resist being forced to build less that the optimum unit. The question of unit builds in not restricted to computer games, and is just as difficult to deal with.
 
Do you realize the impossible variables there are to get any concrete data on how the AI decides what to build by playing a normal game. Without source code, it is impossible to determine how AI makes it build decisions that way. There are patterns that can be seen, but it is alot of guessing.

The only thing that can be done so the guesswork is taken out, is determine what flags the AI likes better, with all other factors exactly the same. This information allows modders to be able to tweak units to make AI build them more or less (such as adding enslave ability to a unit with NONE checked in the enslave box). It has been found that the AI will still think the unit has the enslave ability, even though in game it cannot enslave, but builds them more often.

I can say that from previous build tests, it is almost for certain that whatever algorithms the AI goes through to decide what to build... it probably assigns points for each flag/value/setting, and determines a final value for the unit, which then it will build them in a certain percentage.

We also found that every single unit does have a chance to be built, no matter how weak it is... but sometimes the chance may be so low, you will never see the AI build it. Regardless, a GREAT amount of things have been found from doing this, and modders have that information to be able to get better results from the AI.

I agree, there is much that is unknown, but it is time consuming and difficult to do tests without a standard base to work off of.

Tom
 
I agree with Timerover. The tests are interesting, but we don't really know if the AI is using only the flags / costs / ADM to decide what to build, or if it is smart enough to take the strategic situation into consideration. Although I have some doubts...

Will it create a stronger navy if it's alone on a continent? Does it try to match the strength of the neighbours? Would it create more unit with "ignore forst cost" if there are a lot of forest nearby?

Does it start building more offensive units if it is at war?

I'm afraid we can never know unless we can have a look at the source code...
 
Thank you, Steph. The tests remind me of what I encountered in a project I did for a US government agency, trying to determine why what I call the "cookie cutter" bomb damage assessment tables used by the US Air Force were not working in Afghanistan. The Air Force, in its testing of bomb damage effects eliminated every variable except one, the distance from the bomb explosion to the target. The testing was done on flat, open terrain with no protection to the possible target, and much was done using computer simulation. The bombs were also static detonated, and not dropped. That testing proved to have little, if any, correlation to what actually was occurring. They eliminated all of the variables that actually occur in war, and were stunned when the results they and their computers predicted were not achieved. I explained to the government agency's satisfaction as to why the results did not coincide. The US Air Force officers involved at the time really did not like me much at all. To the best of my knowledge, the USAF is still using the BDA tables that I pretty much demolished.
 
So you are saying these tests have provided no useful information at all? Would you like me to make a list of all the helpful information these have provided for modders that was previously unknown? (I really would prefer not too though, It's a big thread to go through :))

Better yet, do the test you described by pretty much playing a normal game, and see what facts you can provide us all... It seems like it would be very hard to tell how AI values its units.

Using the information found through this type of testing, I have been able to get the AI to build (without autoproduction) a wide variety of units in Global WW2 scenario that all have significantly different stats. Without knowing this stuff, it would not have been known how to accomplish such a thing with certainty.

I agree with Timerover. The tests are interesting, but we don't really know if the AI is using only the flags / costs / ADM to decide what to build, or if it is smart enough to take the strategic situation into consideration. Although I have some doubts...

It has already been found that almost every option on the unit page effects the build choice in a certain way, including flags, cost, ADM, hitpoints, etc. The point is to know what the AI values most and what the AI values little. Oz has found that AI builds Offense/Defense in a (55/45% ratio; is that right?), which was also found it may change depending on civ, wartime. AI builds certain units when it has no defenders (cheapest defender unit), the list goes on and on.

It is also highly likely that the AI does not take strategy into consideration. I have used Combat Calculator to make an assessment of who the AI will attack. Naval transports will often head towards coastal city in which it has highest win chance. AI will bypass heavily fortified cities and head towards weaker ones (happens all the time). You see it as AI will attack a city, and when your unit becomes veteran, it then does not attack the city with that particular unit.
-Only conclusion is, the AI knows the percentage chance of it to win/lose... and knows this for all of your cities, and will OFTEN, but not always, head towards the closest one in which it has highest chance to win.
AI is also very likely to attack units that are in their territory, before attacking anything else.


Tom
 
I'm not saying the information from the test are not useful.

The tests are interesting

Just that without the source code, it's very difficult to know of the weight of the flags vs the situation to know what the AI is actually doing.
 
All this got me thinking... one way to make the AI place a greater amount of defending units in it's cities (besides the few it usually keeps there), may be this way...

The military police limit makes a content citizen out of each unhappy citizen. Having less luxuries in a scenario, and less improvements that create happy citizens will most likely make the AI keep defenders in it's cities to keep them from going in disorder, or having to make entertainers.

So if the MP limit is 10, for larger cities the AI may keep that many in there if the luxuries aren't available. From Rocoteh's WW2 Global, this was sometimes the case, and often Germany for instance would have many defenders in each city (although I can't remember what the MP limit was).

This would be good to make it more difficult to take enemy cities from the AI.

Tom
 
Gentlemen,

The point of these tests is not meant to be exhaustive (sorry, but I have plans for the next century or so) but illustrative:

Just as in the first thread,
  • it's limited to land units.
  • Just as in the first thread, it does show all things being equal the AI's preferences, which I presume will help some modder, somewhere :rolleyes:

Anyway - in this next round, I eliminated the "+ Fort" ; "Invisible" ; "Detect Invisible". I also left in the "Regular" basic control unit - the "unadorned" 5/5/2 - as the unit resulting from Enslavement; I was surprised when 2 were actually built.

Hikaro - your sense of the "Hidden Nationality" flag seems correct: this time, on the first turn, every city built one (although of course your results are diluted by multiple-flagged units).

Tallies over 5 turns of builds (25 units/Civ total):

ROME: 7 ATR ; 1 ZOC ; 17 Hidden Nationality
EGYPT: 6 ATR ; 2 ZOC ; 17 Hidden Nationality
GREECE: 2 "Regular" ; 4 ATR ; 18 Hidden Nationality ; 1 Para
BABYLON: 5 Hidden Nationality; 20 ATR (once again, a typical Player / Governor build.

Conclusion: Hidden Nationality Rules, followed at some distance by ATR.

Synopsis to date: AI preferences: (1) Invisible (2) "+ Fort" (3) Hidden Nationality (4) ATR. ATM, I don't regard the 2 Regulars and 1 Para as statistically significant.

@MeteorPunch - all variables are set to "control" (please re-read my first post). Also, no Settlers or Workers.

@Most Others: Nobody's forcing you to read this; no testing can be complete; and I would suggest that th preponderanc of "+ Fort" units alone might be the key to having the AI choose reasonably between 2 different defenders. Likewise, if you want to guarantee Recon units being built, these tests certainly suggest that ATR is a very effective way to go.

Have Fun,

Oz
 
Very interesting results... just to ask, are you placing at least 3 defenders in the cities prior to testing? When I did tests back in the day, initially I did not do this, and the results were somewhat skewed because the AI built the first unit on the list to fill the defenders before it actually started deciding what to build (I guess because all defenders cost the same, it picked the first one looking only at cost).

Tom
 
Very interesting results... just to ask, are you placing at least 3 defenders in the cities prior to testing? When I did tests back in the day, initially I did not do this, and the results were somewhat skewed because the AI built the first unit on the list to fill the defenders before it actually started deciding what to build (I guess because all defenders cost the same, it picked the first one looking only at cost).

Tom

Nope re: 3 defenders. I'm always curious what the AI builds first in a new city. From this little exercise, I now suspect that the first unit (a "+ Fort") will probably be built even if a stronger defender of the same cost is available. And none of the first builds were the first item on the list (that was the control 5/5/2). I consider this important if a balance of strength could be found such that the very first unit is the "+ Fort", then other defenders thereafter.

My preference is generally to produce as many unit lines as reasonable while using auto-production as little as possible - so 2 defensive lines right off the bat works for me!

Best,

Oz
 
On your next test give one of the units an operational range of 30, but don't check the airdrop flag. Giving a range of 5 or 10 won't do it, but a high number like 30 will be attractive to the AI, without them being able to drop them from an airport.
Also, give one unit the Detect Invisible ability.
 
Top Bottom