Ja Mes
Chieftain
- Joined
- Dec 5, 2020
- Messages
- 13
Like much of the DLC content, the World Congress is extremely hard-coded into the Civ5 source code. Based off of the CvVotingClasses.cpp, adding a new World Congress resolution that the AI can actually use is nearly impossible, because most of the values the AI is supposed to use to score a vote are hard-coded. I have been trying to think of a way to get around this without modifying the source code. Two ideas seem plausible: forcing delegate trade deals, or hijacking the projects feature.
With the first option, is it possible to use any of the Lua methods to force a trade deal between players such that their delegates are committed to vote for a resolution?
The second option is a little more complex. In the function CvLeagueAI::ScoreVoteChoiceYesNo, which the AI will use to "Score a particular choice on a particular proposal which is a decision between Yes and No" there is one section of code for projects, like the World's Fair or International Space Station:
this is independent of what the project actually is. If the AI has higher relative production to other players, it will score the resolution positively, if not, negatively. If we can artificially manipulate how each AI player ranks their production relative to others as they are casting their vote, we could use Lua to handle all of the decision-making on votes without changing the source code. This could be done by sending all of the AI's cities into Resistance, for example, or temporarily giving every other player an artificial boost to production (a +10000 production dummy building). I haven't been able to figure out the timing for this, and I don't know if it's actually possible. It depends on 1) when the AI scores its decision on the WC resolutions and 2) how this is actually calculated.
It's a long shot, but if this could work, it could introduce non-DLL World Congress mods!
With the first option, is it possible to use any of the Lua methods to force a trade deal between players such that their delegates are committed to vote for a resolution?
The second option is a little more complex. In the function CvLeagueAI::ScoreVoteChoiceYesNo, which the AI will use to "Score a particular choice on a particular proposal which is a decision between Yes and No" there is one section of code for projects, like the World's Fair or International Space Station:
int iOurProductionMight = GetPlayer()->calculateProductionMight();
int iHigherProductionCivs = 0;
int iLowerProductionCivs = 0;
int iAliveCivs = 0;
for (int i = 0; i < MAX_MAJOR_CIVS; i++)
{
PlayerTypes e = (PlayerTypes) i;
if (GET_PLAYER(e).isAlive() && !GET_PLAYER(e).isMinorCiv())
{
iAliveCivs++;
if (GetPlayer()->GetID() != e)
{
int iMight = GET_PLAYER(e).calculateProductionMight();
if (iMight > iOurProductionMight)
{
iHigherProductionCivs++;
}
else
{
iLowerProductionCivs++; // Include civs with equal might
}
}
}
}
bool bStrongProduction = false;
if (iAliveCivs > 0)
{
float fProductionMightRatio = ((float)iAliveCivs - (float)iHigherProductionCivs) / ((float)iAliveCivs);
CvAssertMsg(0.0f <= fProductionMightRatio && fProductionMightRatio <= 1.0f, "Error when evaluating delegates for an international project. Please send Anton your save file and version.");
fProductionMightRatio = MAX(fProductionMightRatio, 0.0f);
fProductionMightRatio = MIN(fProductionMightRatio, 1.0f);
if (fProductionMightRatio >= 0.75f)
{
iScore += 40;
bStrongProduction = true;
}
else if (fProductionMightRatio >= 0.50f)
{
iScore += 20;
bStrongProduction = true;
}
else if (fProductionMightRatio >= 0.25f)
{
iScore += -20;
}
else
{
iScore += -40;
}
}
this is independent of what the project actually is. If the AI has higher relative production to other players, it will score the resolution positively, if not, negatively. If we can artificially manipulate how each AI player ranks their production relative to others as they are casting their vote, we could use Lua to handle all of the decision-making on votes without changing the source code. This could be done by sending all of the AI's cities into Resistance, for example, or temporarily giving every other player an artificial boost to production (a +10000 production dummy building). I haven't been able to figure out the timing for this, and I don't know if it's actually possible. It depends on 1) when the AI scores its decision on the WC resolutions and 2) how this is actually calculated.
It's a long shot, but if this could work, it could introduce non-DLL World Congress mods!