|
The following was posted on our CTP-Creation forum by Tucson Luke Loh(a.k.a. Celestial Dawn) on June 14 1999
I think I've managed to figure out how the AIPs work. The AIPs certainly have a lot of information about the inner workings of the AI. Read and enjoy.
AIP COMMENTS (based on default.aip)
Default.aip is the first aip loaded at game start and contains a number of strings which are not found in the other personality aips. If repeated in the other aips, the new values take precedence over the default.
// The next line was used in Dark Reign to specify a likelihood that a spy
No clue.
PRIORITIES
These probably set the weighting for AI priorities. Most of the priorities default to the figures loaded at start from default.aip so I will only cover those which change in the other aips.
double build_buildings_priority = 20000000.0; except citywall.aip which sets this to 1998000.0
Actually, there are lots more - I just can't be bothered to go through the lot. This is my guess on how it works. The higher the number, the higher the priority assigned to it.
From default.aip, it seems that buildings and troops have equal priority, though if unit_focus.aip is loaded, then units take priority, if build_troops_off.aip is loaded, then buildings take precedence. Wonders are at 1997500.0 so they will always be 3rd. The AI also prioritises the ALP components on par with units and buildings, and interestingly, capitalisation also gets a 2000000.0 billing. Settle_priority is 1700000.0.
MODIFIERS
These modify the above priorities, depending on the situation. Just some of the more intresting ones:
// WANDER CONTROL
// FORCE MATCHING
// MAX BUILD TURNS
Doing this also lays one of my other major concerns to rest - the AI will not be stupid enough to build the X-Lab until it can do it within 50 turns, which is not so easy to do even under Technocracy. It is not impossible, however - a good sized AI city with lots of mines can do the job. Just not very quick. This also means that if the AI can't complete the X-Lab in 50 rounds it won't try, and will focus on building units and other improvements instead. Another worry put to rest.
// MAX GOALS PER CITY
Most of the following are self-explanatory, but the question here is ... what's the difference between the positive and the negative numbers? Take for example:
#define MAX_EXEC_REFORM_CITY_GOALS 0.5 (default) Set to 0 for Barbarian
// The Build Data
I'm not sure how these priorities interact with the earlier priorities above. I have a strong hunch that these are also modifiers and add directly to the priorities above.
Troops_Primary would then take precedence over Wonders by virtue of their big modifiers, added to the 2500 bonus they already have over Wonders above.
Then the first unit in Troops_Core is considered - and since the average Wonder has a priority modifier of 9,100, less the 2500 difference = 6600, any doubled bid of 3500 (not 4000) for the first Core unit called will take precedence over an Average Wonder. For improvements, because build_building_priority is 2000000.0, a doubled bid of 4000 is required to drown out buildings.
I wonder if this emphasis on troops is what is causing the AI to overswarm. What you might want to do is to leave the priorities alone, but to reduce the actual number of troops built per city. This would free up space for more improvements. Watch what you do though, you want to make sure that you do not cripple the AI's ability to make war. Check to see how all these interact with the War aips.
"Scout_Troops_Primary", 25000.0 default for all //Highest priority
"Land_Settler_Troops_Primary", 10500.0; masssettle_sandbag.aip (20500), survival_mode.aip (15000)
"Sea_Settler_Troops_Primary", 11000.0; default
"Land_Troops_Primary", 6000.0; default except for getarmy, survival_mode (7900.0)
"Sea_Troops_Primary", 5000.0; default except for naval, supernaval (6000.0)
"Settler_Troops_Core", 3500.0; default
"Diplomatic_Troops_Core", 4500.0; default except for getarmy (0.1), masssettle, masssettle_sandbag, survival_mode (900), naval, supernaval, scimany (2500.0) //I guess Peaceful personalities wait for other civilisations to contact them? No biggie, gives it more personality this way.
"Scout_Troops_Core", 2900.0; default except for getarmy (0.1), masssettle, masssettle_sandbag, survival_mode (900), naval, supernaval, scimany (2500.0) //Mmmm, other than initial exploration, Peaceful personalities also prefer to stick to their own turf. Cool.
"Spy_Troops_Core", 4500.0; default except for getarmy (0.1), masssettle, masssettle_sandbag, survival_mode (900), naval, supernaval, scimany (2500.0) //Ditto
"Defend_Troops_Core", 3500.0; default
"Lawyer_Troops_Core",5000.0; except for barbarian (1000.0) //Ah, no!!!!! Ok, I'm going to have to do something about this. It prioritises Lawyers!! ahead of units? omg - no wonder the AI is so )*&*)(! annoying.
The rest of the list is for overflow troops, which get prioritised last and so aren't important. Only interesting high priority is "Wormhole_Probe_Troops", 100000.0, which takes precedence I suppose if it ever becomes available.
BUILD LISTS
What follows next is a series of build lists. For each list, the AI will only build ONE type of troop in the list (probably the one at the top of the list, unless it is no longer available - though this is just my guess). After deciding which unit it wants to build, it will then build the specified number of units per city.
Which brings me back to the question of negative numbers. What on earth do they mean? Looking through the list, this is my best guess - negative numbers refer to the most they will ever try to build of a unit at any given time. Meaning that for eg.
Build_List_Element Land_Settler_Troops_Primary[MAX_ELEMENTS];
It will only ever build 2 settlers in all its cities at any given time, instead of building 2 cities. This would also tie in with the MAX_EXEC and MAX_EVAL modifiers above, with the AI only ever evaluating or executing so many goals at a certain time.
This is not to say that the AI will never build more than 2 settlers or 1 nuke etc - it simply limits the total number that can be under construction. This is my best guess.
Positive numbers like:
Build_List_Element Land_Troops_Primary[MAX_ELEMENTS];
Means that it will build that many units per city, depending on what unit it chose. So for example, if it chose to build Pikemen, it would try and build 2.5 Pikemen for every city in the empire. If it chose Leviathans, it would only build 1 Leviathan per 10 cities. And in all cases, it will only build units if it is capable of finishing them within 20 turns (based on int max_build_unit_rounds = 20.0 above). So in other words, the AI won't assign units to be built haphazardly.
Anyway, this is just my best guess.
WONDER AND IMPROVEMENT LISTS
Then we get down to Wonder and Improvement Lists. Again, this is my best guess, but the AI has internal routines that tells it to rank what type of improvement it presently needs. Once it goes ABOVE that threshold, it will choose a building from that list. This is borne out by the behaviour of citywall.aip.
double Wonders_List_Threshhold = 0.8; except for Barbarian (0.99) and citywall (0.6)
The // are the programmers' own comments. End_Game_Object and Capitalization only appear in default.aip. Now following the above logic, it would seem that you'd choose Miscellaneous, End_Game_Object or Capitalization pretty easily. However, that weird comment about 1 - best_rank makes me wonder if the situation is reversed for these three. But I am pretty sure all the way from Wonders to Defense it will choose a building from the list if it exceeds the threshold.
Actually, I think Miscellaneous follows the same rule as well - I've looked into the Miscellaneous list and it contains first a Granary, then City Walls, then a Market, Courthouse and Population Monitor. So it will default to building these buildings first if it doesn't exceed the other thresholds.
Growth and Science seem to take precedence over Gold, so it looks like the AI will not need any tweaking in this regard. It looks like yes, the AI will know how to build Science Improvements when Science slows down (the AI keeps a separate count, accessible only if you Spy on an AI city of "City Science" meaning how much Science is being produced in a particular city - this includes Science from Gold).
What follows after all this are the actual build lists, once again I assume the AI will choose the one with the highest priority, unless it is no longer available for building. If priorities are equal, it will pick the highest on the list.
Some changes will need to be made - for Science buildings, you want it to build a Publishing House before a University, since the University is pretty hopeless. - DONE TLL 14/6/99
Finally, right at the very bottom is the research path the AI will take, and it differs from personality to personality. It will research the highest available on the list, and then work its way down.
You'll have to go through the entire list of AIPs to figure out the other nuances, but this is the general gist of how the AIPs work.
END OF COMMENTS TLL 14/6/99
Back to main Modification page
Apolyton Civilization Site Copyright © Robert Plomp and Jeroen Schweitzer All trademarks and trade names are the properties of their respective owners.
|