AI priorities

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
AIs use a priority system to figure out what to build. Say an AI wants to build a defensive unit. It compares all the units it can build, and the unit with the highest "defense" priority gets chosen. If you'd like to help refine the AI's decision-making, please change these to 1 in the options file:
UPDATE Civup SET Value = 1 WHERE Type = 'SHOW_AI_PRIORITY_UNITS';
UPDATE Civup SET Value = 1 WHERE Type = 'SHOW_AI_PRIORITY_BUILDINGS';
UPDATE Civup SET Value = 1 WHERE Type = 'SHOW_AI_PRIORITY_POLICIES';
UPDATE Civup SET Value = 1 WHERE Type = 'SHOW_AI_PRIORITY_TECHS';
You can then see AI priorities ingame like:
Archer
2 offense
3 defense
2 ranged

Horseman
4 offense
3 defense
4 mobile
  • The AI considers horsemen twice as powerful as archers for offense.
  • The two units are equal for defense.
  • Archers are useful for ranged warfare.
  • Horsemen are useful for mobile warfare.

The basic patterns I followed are:
  • Strategic and Siege units are valued higher than non-strategic units.
  • Each era is valued higher than the previous era.
  • Ranged units have higher priority for defense.
  • Strategic units have lower priority for defense. (pillagable resources)
Comparing values is all that matters. The numbers have no intrinsic meaning. Units could have 10 and 20 priority, or 1 and 2, and it would mean the same thing.

Each AI has the preferences listed below. These determine which type of priorities the AI focuses on. It then selects something from that category to build or research. For example, let's say Alexander is deciding what to build. We can see from the table he's twice as likely to get a Mobile unit (horse/tank) as a Ranged unit (archer). Let's say he decides on a Mobile unit. He now looks at the mobile units available in one of his cities. He can build Chariots or Companion Cavalary. The cavalry have a higher mobile priority, so he purchases a cavalry.


 

Attachments

  • AI priorities.PNG
    AI priorities.PNG
    45.7 KB · Views: 4,009
I released the beta as v138 with these numbers hidden. If you'd like to help refine the AI's decision-making, please change these to 1 in the options file:

SHOW_AI_UNIT_PRIORITIES
SHOW_AI_BUILDING_PRIORITIES
 
I went through the building priorities (finally - been meaning to for a while). These are my thoughts:

Buildings
  • Culture buildings (Monuments especially! The AI doesn't prioritize these enough.) - add tile_improvement, growth, production, and expansion
  • Military Experience buildings - add production (these buildings now have engi slots and production)
  • Defense Buildings - add small amount of production and growth (in case civ has relevant policies)
  • Water Mill - reduce growth, increase production
  • Harbor - add naval_tile_improvement
  • University - add unit_production to put it in line with other science buildings

Wonders
  • Wonders that grant a free building should have the same priorities as the free building. For example, the Great Lighthouse should have naval_growth, naval_tile_improvement, science, etc.
  • Could add culture on all wonders
  • Temple of Artemis - add growth
  • Stonehenge - add culture, growth, production
  • Pyramids - why is offense on here?
  • Hanging Gardens - add happiness, culture
  • Great Library - increase science?
  • National Epic - add culture
  • Chichen/Taj - add some culture, growth, science (GAs have changed so it should be represented I think)
  • Kremlin - add expansion
  • Cristo/Statue of Liberty - add great_people (is there a "specialists" tag? that would be more fitting)
  • Pentagon - add gold
 
Wow I didn't know about that priority system.

I bet that would take a while to change every unit and building.

My take would be to agree on the unit part, but on the buildings and wonders I see a lot of room for improvement.

My first question is does the AI adjust their priorities based on whether they're militaristic or peaceful or is it a flat rate for every civ?

Second is how high does the scale go 1-100 or something else?
 
My first question is does the AI adjust their priorities based on whether they're militaristic or peaceful or is it a flat rate for every civ?

Second is how high does the scale go 1-100 or something else?

1. Yes, it does. You can see how the AIs prioritize in the VEL_Flavors file in the Leaders folder.

Priorities should also change depending on if the AI is on the defensive or offensive, need growth or production, etc. You can see the AI's city strategy flavors in the VEC_AI file in the Cities folder.

2. I don't see anything above 100, so I assume that's it.
 
I've added most of these suggestions for v151. I also did an across-the-board adjustment of global AI priorities (vem/leaders/VEL_Flavors.xml)

Buildings
  • Culture buildings (Monuments especially! The AI doesn't prioritize these enough.) - add tile_improvement, growth, production, and expansion.
  • Military Experience buildings - add production (these buildings now have engi slots and production)
  • Defense Buildings - add small amount of production and growth (in case civ has relevant policies)
  • Water Mill - reduce growth, increase production
  • Harbor - add naval_tile_improvement
  • University - add unit_production to put it in line with other science buildings
    It's odd that the Library and Public School have military_training... that's normally reserved for structures like the Barracks. I'll remove it.

Wonders
  • Wonders that grant a free building should have the same priorities as the free building. For example, the Great Lighthouse should have naval_growth, naval_tile_improvement, science, etc.
  • Could add culture on all wonders
    This would make AIs build fewer culture buildings, and militaristic leaders build more wonders, two things we probably don't want.
  • Temple of Artemis - add growth
    It already has growth.
  • Stonehenge - add culture, growth, production
    This has culture, and adding growth/production would make it very hard for humans to get. Stonehenge is generally under-appreciated so I want to keep it accessible.
  • Pyramids - why is offense on here?
    It's the 3rd best early wonder for conquerors (behind Statue of Zeus and Temple of Artemis).
  • Hanging Gardens - add happiness, culture
  • Great Library - increase science?
  • National Epic - add culture
  • Chichen/Taj - add some culture, growth, science (GAs have changed so it should be represented I think)
  • Kremlin - add expansion
    This has expansion.
  • Cristo/Statue of Liberty - add great_people (is there a "specialists" tag? that would be more fitting)
    The game groups specialists and great people together.
  • Pentagon - add gold
    This gives all units march, not a gold bonus.
 
It's odd that the Library and Public School have military_training... that's normally reserved for structures like the Barracks. I'll remove it.

Research is needed to get better military units, maybe for aggressive civs its needed to prioritize library to get "there" faster.....:scan:
 
The AI is back to not expanding. On my continent as of t100, with plenty of room to expand, Rome has two cities, and China and Songhai one.
 
I didn't look at the units priorities - what's on the settler?

(I'm afc atm.)
 
I think that non-expansion is a major reason why the AI is looking so badly and I'm getting these great score leads by the Middle Ages on Emperor...I'm not that good!!! :D
 
I haven't been able to come close to beating King in 6 - 8 months. I started a King game a couple of days ago after playing 4 or 5 prince games, (for my ego), and I am so far in the lead it is rediculous.

Using 150.2... The AI did expand, but not nearly as much as they used to. Not as quickly.
 
I also did an across-the-board adjustment of global AI priorities (vem/leaders/VEL_Flavors.xml)

As I mentioned in my bug report thread for v151, I think expansion flavors were set too low in this version. I think science should also probably be raised and culture could be too low for civs that excel in cultural games as well (namely Darius, Rammy, Gandhi, Kame and Ramesses).

It's odd that the Library and Public School have military_training... that's normally reserved for structures like the Barracks. I'll remove it.

I think it should remain, for the reason Royco stated - militaristic AIs already do poorly in science, it makes sense for them to give some priority to science (just like any civ).

  • Temple of Artemis - add growth
    It already has growth.
I misread my notes, I meant to say raise the growth flavor here.
  • Pentagon - add gold
    This gives all units march, not a gold bonus.
Oops, the tooltip doesn't list the march bonus with the Priorities option turned on - I was going on memory, thinking it still gave the upgrade cost reduction.
 
I've been a long time follower of these forums, however only as a lurker (thanks for all that hard work Thal! I consider Civ5 almost unplayable without your mods.)

But I can also confirm that the AI has been faaaar less expansionist than in previous builds. Even civs like America sit on one city for far too long. I also find that AI civs seem more likely to attack me to try and take over my cities than previously, but are also far less successful at even making a dent in my empire. I've also noticed a few more AI settlers in barbarian camps than previously -- maybe they aren't being protected well enough?

Another possibly related (but likely unrelated) bug I noticed is that some combination of the calendar dates, turn count and/or rate of technological progress seem out of whack in Marathon paced games. This seemed very well aligned in previous builds, so I'm wondering if maybe the settings of another game pace are being applied by accident?

Thanks again for all the hard work!
 
Ver 151:

I don't claim to be anything but a average player. What I find lately is ether I have improved a ton or the AI has regressed a ton on king level. I pull out to 100 point plus leads now pretty easy. I play on Marathon not sure if that has anything to do with it. One of the things I find a lot easier for me then it use to be is building wonders. Hope this helps.
 
As far as I can tell, the flavor settings from the VEL_Flavors file in the Leaders folder under the VEM folder are what the problem is.

Thal appears to have set up a priority system similar to the one I just put together for my own purposes, using lower numbers and organizing the flavor priorities for peaceful and aggressive archetypes. The peaceful emphasize building Wonders, City Defense and aggressive emphasize military and expansion.

The problem, however, is that the expansion is prioritized at the same level as the others with the 2, 4, and 8 settings. Aggressive civs are prioritized in expansion at 8 with other flavors, with the peaceful settings at 4.

The idea of that is sound but the practicality of it results in aggressive civs building their militaries before expanding and the peaceful civs wanting to "fill out" their cities before considering expanding.

I went through and put all the aggressive civs at 9 for expansion flavor and peaceful at 8 so that expanding would be a priority either emphasized or shared with top priorities. This resulted in Suleiman getting his second city by turn 50 and by 62 two others expanded so I can reasonably claim that it works.
 
That's very interesting.

Would that make tall civs expand as much as wide ones?

These settings aside, something else seems off, though. In my v151 game, England had a single size-3 city on t100. They weren't filling anything out!
 
Top Bottom