Social Policy Technology Prerequisites

Androrc the Orc

Emperor
Joined
Apr 19, 2004
Messages
1,621
Location
Vienna, Austria
In the vanilla Civilization V game, there is a XML field for social policies for making them require a technology. Such a field, while unused in the vanilla game, does work if a mod makes use of it.

However, there are no UI indications that the social policy requires the technology. This mod changes this, changing the tech tree and tech civilopedia screens to show which policies a tech unlocks, and changing the policy civilopedia to show which technology a policy requires, if any.

As an example, this mod makes the Scholasticism social policy require the Theology technology.

My lua UI changes can be found by searching for the "Andrettin" and "Androrc" tags.



 
Yes, I noticed the lack of UI indications for tech prerequisites in my own Alpha Centauri mod, which is why I altered the Polcy UI about a year ago to display unmet tech prerequisites in red text whenever you viewed the help text for a policy, and adding the policies' icons to the tech tree. It's been a core part of my mod's design since the beginning.

The thing to watch out for is that if you start adding tech prereqs to existing policies, the AI will break. The game only allows each AI player to have two open branches at once; if it can't choose any policies in its open branches because of limitations like this, then the AI will get stuck and not spend any Culture, even if those policies become available later. I had to add a hard override, forcing the AI to open a new branch if it ever reached a situation like this.
 
Well, it doesn't prevent them from getting stuck again if a similar situation comes up in the future involving a different set of policies. But it at least appears to "unstick" the AI from the first instance of the problem, to where that player will have no problem adding policies in the newly-opened branch even though it's technically over its normal limit on number of branches. The problem is the trigger: how exactly can you tell when an AI gets stuck? You can get a player's total culture, and the cost of his next policy, but you can't easily add up how much Culture he gets each turn. You can get culture from specialists and buildings easily enough, but what about players who get Culture from other sources, like killing barbarians? You don't want this triggering in cases where the AI isn't actually stuck, because that actually hurts the AI (by opening more branches instead of finishing the existing ones to get Finisher bonuses).

The game has a lot of annoying little problems like this, where the amount of effort needed to fix something is huge compared to the problem itself. Take, for instance, negative-Happiness buildings; they just won't work, because the game will ignore a negative value in either the <Happiness> or <UnmoddedHappiness> fields. I'm not referring to the fact that the UI will show a happy face with "+-1" for that building, I mean it won't actually modify your empire's Happiness. So to add a negative-happiness building (like I've done in my own mods) you have to use a really complicated workaround involving a hidden Policy (since the Happiness-per-building field in the Policies table CAN accept a negative value), which screws up all sorts of things in both XML and Lua, including the "stuck" AI issue I've mentioned here. So my mod has a bunch of under-the-hood Lua functions and UI alterations designed to mask the fact that the solutions to these problems are not simple.
 
Yes, of course. In my own mod I've set that to 3 because of my custom Social Engineering branch. But that won't stop it from getting stuck, which can happen whenever an AI thinks it wants a certain Policy for various reasons but can't actually take it. The problem isn't that it'd have two open, unfinished branches and couldn't open a third when it runs out of options, it's that even having ONE open branch can cause the AI to get stuck if there's a policy in that branch that is locked out through techs, because the AI is built (internally) to automatically prefer policies in its currently open branches to all policies in closed branches. You could set multiple Flavor ratings on that policy to -999 and it'd STILL prefer the locked-out policy over one in a new branch.
 
Yes, of course. In my own mod I've set that to 3 because of my custom Social Engineering branch. But that won't stop it from getting stuck, which can happen whenever an AI thinks it wants a certain Policy for various reasons but can't actually take it. The problem isn't that it'd have two open, unfinished branches and couldn't open a third when it runs out of options, it's that even having ONE open branch can cause the AI to get stuck if there's a policy in that branch that is locked out through techs, because the AI is built (internally) to automatically prefer policies in its currently open branches to all policies in closed branches. You could set multiple Flavor ratings on that policy to -999 and it'd STILL prefer the locked-out policy over one in a new branch.


This should be easily tested. Just enable AI logging and look Policy files. That shows policy flavors after calculation. There is values at GlobalAIDefines.xml which suspiously looks like modifying branch taking. I have not tested those.

A side note that AI flips coin between the two highest flavored policies. This leads to strange behavior. For example not getting the last policy of tree, basically doing AI culture victory highly unlikely and your behavior. Yes I know this is stupid but this is again thing to wait .dll.

Joltis
 
Top Bottom