Iustus
King
I have been going through the AI routines in the SDK, trying to get a hold on things, and I ran across what I believe is a cut and paste bug in the code. It is not fixed in the Warlords version.
in CvPlayerAI.cpp, lines 2083-2094 (in the routine AI_bestTech)
I believe the second loop should be calling getFeatureMakesValid, as below:
I know, it is a somewhat obscure bug, but it seemed pretty clearly a bug.
If my analysis is correct, this bug would cause techs which enable builds (from Civ4BuildInfos.xml) which enable improvements (from Civ4ImprovementInfos.xml) to basically double count the terrain and not count the features.
In the default game, this would mean that the following get (slightly) higher than normal values:
Agriculture (+100)
Metal Casting (+100)
Pottery (+100)
Mathematics (+250)
And the following get (slightly) lower than normal values:
Replaceable Parts (-50)
Now, note, that there is a random factor of 0-2000 added to the value, so these are very small values, which is likely why the bug was never detected.
Even so, it does seem to be a bug to me, and with some mods, it could become significant.
-Iustus
in CvPlayerAI.cpp, lines 2083-2094 (in the routine AI_bestTech)
Code:
for (iK = 0; iK < GC.getNumTerrainInfos(); iK++)
{
iBuildValue += ((GC.getImprovementInfo(eImprovement).getTerrainMakesValid((TerrainTypes)iK)) ? 50 : 0);
}
for (iK = 0; iK < GC.getNumFeatureInfos(); iK++)
{
iBuildValue += ((GC.getImprovementInfo(eImprovement).getTerrainMakesValid((FeatureTypes)iK)) ? 50 : 0);
}
I believe the second loop should be calling getFeatureMakesValid, as below:
Code:
for (iK = 0; iK < GC.getNumTerrainInfos(); iK++)
{
iBuildValue += ((GC.getImprovementInfo(eImprovement).getTerrainMakesValid((TerrainTypes)iK)) ? 50 : 0);
}
for (iK = 0; iK < GC.getNumFeatureInfos(); iK++)
{
iBuildValue += ((GC.getImprovementInfo(eImprovement).getFeatureMakesValid((FeatureTypes)iK)) ? 50 : 0);
}
I know, it is a somewhat obscure bug, but it seemed pretty clearly a bug.
If my analysis is correct, this bug would cause techs which enable builds (from Civ4BuildInfos.xml) which enable improvements (from Civ4ImprovementInfos.xml) to basically double count the terrain and not count the features.
In the default game, this would mean that the following get (slightly) higher than normal values:
Agriculture (+100)
Metal Casting (+100)
Pottery (+100)
Mathematics (+250)
And the following get (slightly) lower than normal values:
Replaceable Parts (-50)
Now, note, that there is a random factor of 0-2000 added to the value, so these are very small values, which is likely why the bug was never detected.
Even so, it does seem to be a bug to me, and with some mods, it could become significant.
-Iustus