Having trouble getting the AI to research techs in a specific order.

chillbaka1

Chieftain
Joined
Nov 13, 2016
Messages
46
I've been trying to make a "flavors" mod that personalizes the AI leaders better but no matter what I do the research AI does not seem to change.

Here is the particular problem I am having right now. I'm working on personalizing Alexander to make him really go for dom victories, the only problem is that he researches almost everything BESIDES horseback riding, bronzeworking, and ironworking. He seems to build a campus, holy site, and commercial hub BEFORE he even gets around to researching bronze working.

Any ideas? Ive tried messing with the boost handlers, adding new AI lists, AiListTypes, AiFavoredItems, and a couple of other things with no effect. He always rushes currency when i want him to go straight for bronze working, build an encampment, build his UB, then continue doing whatever. This is the part I am trying to implement.
 
So I've been at this pretty much all day and nothing seems to work. I was even just trying to get rome to go for iron working or build encampments first but nothing seems to work. In the excel debug file "AI_Research" (located in Documents\My Games\Sid Meier's Civilization VI\Logs) it shows the values that each civ applies to each tech every turn but nothing I do seems to affect these values.

Here is the turn 1 data for alexander. He already decides that he is going for writing before turn 2, and from there he ends up researching "education" and "cartography" before ironworking or bronze working.


GameTurn Player Action Tech Score Column1
1 1 Tech TECH_POTTERY 164.6 RESEARCHING
1 1 Tech TECH_ANIMAL_HUSBANDRY 149.5
1 1 Tech TECH_MINING 149.5
1 1 Tech TECH_SAILING 82.6
1 1 Tech TECH_ASTROLOGY 113.7
1 1 Tech TECH_IRRIGATION 198.5
1 1 Tech TECH_ARCHERY 183.5
1 1 Tech TECH_WRITING 205.6 GOAL
1 1 Tech TECH_MASONRY -9849.5
1 1 Tech TECH_BRONZE_WORKING -9849.5
1 1 Tech TECH_THE_WHEEL -9849.5
1 1 Tech TECH_CELESTIAL_NAVIGATION -9802.6
1 1 Tech TECH_CURRENCY -9793.4
1 1 Tech TECH_HORSEBACK_RIDING -9815.5
1 1 Tech TECH_IRON_WORKING -9849.5
1 1 Tech TECH_SHIPBUILDING -9916.4
1 1 Tech TECH_ENGINEERING -9849.5
1 1 Tech TECH_CARTOGRAPHY -9916.4
 
There is an error in the code where FXS inadvertently attached the wrong leader trait to Alexander's preferred techs. They have them attached to John Curtin's "Citadel of Civilization" instead of "To The World's End". So consequently AlexanderTechs never get attached to Alexander, but to John Curtin. Try correcting that and see if it helps.
 
There is an error in the code where FXS inadvertently attached the wrong leader trait to Alexander's preferred techs. They have them attached to John Curtin's "Citadel of Civilization" instead of "To The World's End". So consequently AlexanderTechs never get attached to Alexander, but to John Curtin. Try correcting that and see if it helps.

Already tried that, but thank you for the suggestion. I tried fixing and updating the trait, deleting his agenda and creating new lists from scratch, and assigning other leader traits but with no luck. I even tried giving him the kongo's "no religion" ability, and also the "forbid religious victory" trait just to try to stop him from making a holy site but he still does. I just can't figure out what produces those values.
 
If all else fails, it is possible to directly set the tech a player is researching via an lua script. I am unsure whether the AI can then "change its mind" on the next turn and research something else before the selected tech is completed or not, as I never tested for that, but there is an lua hook-event that fires whenever a player selects a tech to research, and the override of what the AI is selecting could then be re-established.

We cannot however do any of this with the Civics.
 
If all else fails, it is possible to directly set the tech a player is researching via an lua script. I am unsure whether the AI can then "change its mind" on the next turn and research something else before the selected tech is completed or not, as I never tested for that, but there is an lua hook-event that fires whenever a player selects a tech to research, and the override of what the AI is selecting could then be re-established.

We cannot however do any of this with the Civics.

I haven't really gotten into lua modding, I know just about everything when it comes to the xml stuff but I guess I always thought lua was for interface stuff. Where would I even start if I wanted to implement what you are talking about? I've run out of ideas to get this working, so I guess i'll be learning lua today.
 
Here's a mod that allows specification of the order techs ought to be researched by AI players. As coded it applies to all AI players who are major civilizations.

  1. The SQL file creates a new database table for specifying these research orders.
  2. The XML file establishes some sample "orderings" for several techs that all AI major players will use until they've researched everything set up in the XML file.
  3. The lua file reads the data in the XML file and creates the effect of re-directing the AI player's research efforts in the order given in the XML file.
As coded, you can have more than one technology with the same setting for OrderPriority. The lua file will then force the AI players to complete all these same-numbered techs in the order they are listed in the base-game's <Technologies> table. So if you assign an OrderPriority of "1" for both "TECH_POTTERY" and "TECH_MINING" in the new table called <Technology_AIResearchOrdering>, the lua code will force AI major civs to complete "TECH_POTTERY", then "TECH_MINING". The OrderPriority in the new table is set-up so that lower numbers are first in research priority, and higher numbers are of later priority. If one of the techs listed in the new table <Technology_AIResearchOrdering> has PrereqTechs that the player has not researched as yet, that player would still (as normal) have to complete those PrereqTechs before being able to research the one listed in the new table.

In adapting or including the code into another mod, you must also set up the two UpdataDatabase actions as shown, with the LoadOrder settings set-up so that the SQL file has a lower LoadOrder number than the XML file.
 

Attachments

  • AI_Research_Ordering.zip
    3 KB · Views: 137
Top Bottom