jdog5000
Revolutionary
Here is the current method all AIs use for determining the 0 to 99 weighting they apply to all other teams in the game, from CvPlayerAI::AI_doCommerce:
First, zero things out:
Then compute new values:
There is no other place in the code where the AI changes these weightings aside from initializing the values when creating a player. Only when it actually goes to set the weighting are the limits of 0 to 99 enforced.
In the first piece of code I think there is an obvious programming bug ... the weights to other teams will only be reset if the Espionage commerce slider is above 0, this doesn't make any sense. This is especially suspect given that in the second piece of code weights are not changed for vassals or masters, its assuming that the weights were set to zero in the first piece.
The logic for picking weights also seems like it could use some more well logic. Right now there are two terms:
This is a proportional term, (their esp against us - our esp against them)/8. This causes the AI to try to catch up with other teams who are spending against it while also lowering weighting for a team who gets a big lead in espionage points.
The AIs attitude towards the other team is simply subtracted from the proportional term. Attitude values are usually between -15 and +15, though they can be higher.
One example:
Team A hates team B with attitude -15. Team A also has a >= 120 point lead in espionage points. The resulting weighting: 0.
The proportional terms is very strong right now, causing AIs who are behind in espionage spending to another player to weight them very highly regardless while causing players with large leads to reduce their weighting even towards enemies. Certainly the proportional term is important, but right now it's really dominant.
So what can we do to have the AI weight enemies more intelligently? Some ideas:
1) Proportional term is currently absolute, could be made relative to AIs espionage point generation rate or current number of espionage points against the opponent.
2) War plans! If the AI is in or planning war, weighting should be increased drammitically.
3) Target espionage levels. Against enemies, for example, AI should desire to have city visibility level of points and have a new proportional term to help it reach that level.
4) Reduce occurrence of saturation. Current strength of proportional term, particularly when AI has esp point lead, causes AI to set most values to either 0 or 99. Since this is a weighting and not a spending level, hitting saturation simply obscures priorities.
5) Non-zero neutral value. Again because this is a weighting, having 10 or 25 be "neutral" instead of 0 would allow differentiation between known friends at 0 and players the AI is cautious and has small delta esp points with at neutral.
6) Spy mission likelihood. If the AI would consider launching spy missions against the player, weighting could be increased. I don't know what factors which aren't already covered could be added here, need to investigate how the AI picks spy mission targets.
Opinions? Other ideas? Let's brainstorm some improved behavior!
First, zero things out:
Code:
if (isCommerceFlexible(COMMERCE_ESPIONAGE))
{
if (getCommercePercent(COMMERCE_ESPIONAGE) > 0)
{
setCommercePercent(COMMERCE_ESPIONAGE, 0);
for (int iTeam = 0; iTeam < MAX_CIV_TEAMS; ++iTeam)
{
setEspionageSpendingWeightAgainstTeam((TeamTypes)iTeam, 0);
}
bReset = true;
}
}
Code:
for (int iTeam = 0; iTeam < MAX_CIV_TEAMS; ++iTeam)
{
CvTeam& kLoopTeam = GET_TEAM((TeamTypes)iTeam);
if (kLoopTeam.isAlive() && iTeam != getTeam() && !kLoopTeam.isVassal(getTeam()) && !GET_TEAM(getTeam()).isVassal((TeamTypes)iTeam))
{
int iTarget = (kLoopTeam.getEspionagePointsAgainstTeam(getTeam()) - GET_TEAM(getTeam()).getEspionagePointsAgainstTeam((TeamTypes)iTeam)) / 8;
iTarget -= GET_TEAM(getTeam()).AI_getAttitudeVal((TeamTypes)iTeam);
if (iTarget > 0)
{
changeEspionageSpendingWeightAgainstTeam((TeamTypes)iTeam, iTarget);
}
}
}
There is no other place in the code where the AI changes these weightings aside from initializing the values when creating a player. Only when it actually goes to set the weighting are the limits of 0 to 99 enforced.
In the first piece of code I think there is an obvious programming bug ... the weights to other teams will only be reset if the Espionage commerce slider is above 0, this doesn't make any sense. This is especially suspect given that in the second piece of code weights are not changed for vassals or masters, its assuming that the weights were set to zero in the first piece.
The logic for picking weights also seems like it could use some more well logic. Right now there are two terms:
Code:
(kLoopTeam.getEspionagePointsAgainstTeam(getTeam()) - GET_TEAM(getTeam()).getEspionagePointsAgainstTeam((TeamTypes)iTeam)) / 8
Code:
-GET_TEAM(getTeam()).AI_getAttitudeVal((TeamTypes)iTeam);
One example:
Team A hates team B with attitude -15. Team A also has a >= 120 point lead in espionage points. The resulting weighting: 0.
The proportional terms is very strong right now, causing AIs who are behind in espionage spending to another player to weight them very highly regardless while causing players with large leads to reduce their weighting even towards enemies. Certainly the proportional term is important, but right now it's really dominant.
So what can we do to have the AI weight enemies more intelligently? Some ideas:
1) Proportional term is currently absolute, could be made relative to AIs espionage point generation rate or current number of espionage points against the opponent.
2) War plans! If the AI is in or planning war, weighting should be increased drammitically.
3) Target espionage levels. Against enemies, for example, AI should desire to have city visibility level of points and have a new proportional term to help it reach that level.
4) Reduce occurrence of saturation. Current strength of proportional term, particularly when AI has esp point lead, causes AI to set most values to either 0 or 99. Since this is a weighting and not a spending level, hitting saturation simply obscures priorities.
5) Non-zero neutral value. Again because this is a weighting, having 10 or 25 be "neutral" instead of 0 would allow differentiation between known friends at 0 and players the AI is cautious and has small delta esp points with at neutral.
6) Spy mission likelihood. If the AI would consider launching spy missions against the player, weighting could be increased. I don't know what factors which aren't already covered could be added here, need to investigate how the AI picks spy mission targets.
Opinions? Other ideas? Let's brainstorm some improved behavior!