Your changes in CvCityAI::AI_bestUnitAI look like forcing to me and why did you include the current Era into the calculation?????????
You could try this instead
Code:
//if (!tempCriteria.m_bIgnoreGrowth && foodDifference() > 0)
if (!tempCriteria.m_bIgnoreGrowth && foodDifference(true, true) > 0) // K-Mod
{
// BBAI NOTE: This is where small city worker and settler production is blocked
if (GET_PLAYER(getOwnerINLINE()).getNumCities() <= 2 || isBarbarian())
{
/* original bts code
bGrowMore = ((getPopulation() < 3) && (AI_countGoodTiles(true, false, 100) >= getPopulation())); */
// K-Mod. We need to allow the starting city to build a worker at size 1.
bGrowMore = (eUnitAI != UNITAI_WORKER || GET_PLAYER(getOwner()).AI_totalAreaUnitAIs(area(), UNITAI_WORKER) > 0)
&& getPopulation() < 3 && AI_countGoodTiles(true, false, 100) >= getPopulation();
// K-Mod end
}
else
{
bGrowMore = ((getPopulation() < 3) || (AI_countGoodTiles(true, false, 100) >= getPopulation()));
}
if (!bGrowMore && (getPopulation() < 6) && (AI_countGoodTiles(true, false, 80) >= getPopulation()))
{
if ((getFood() - (getFoodKept() / 2)) >= (growthThreshold() / 2))
{
if ((angryPopulation(1) == 0) && (healthRate(false, 1) == 0))
{
bGrowMore = true;
}
}
}
}
My changes look like forcing because this isn't the only place where there are controls on whether to build a settler or not. This is one filter where settlers are either denied or enabled. If bGrowMore comes out at false here then settlers will be built IF the economy is healthy and if there are not too many existing settlers already (and I think there's a check to make sure there's an identifiable best spot to settle as well.) Those other checks take place in CvCityAI and precede this one.
The general logic involved in the above says cities will build settlers(actually... better put here in C2C, will ORDER a settler to be built - not necessarily in THIS city) if (all of the above checks out and) either the city is large enough and if the city has as many or more improved plots in its region than it does population.
Problem with this was that once a city grows past a point, or if rogues and such have devastated the land around the city it's invalid to order up a settler. It would also impede cities that were well developed (lands improved) until population exceeded the ability to further develop its lands.
The era was really just a proxy used to establish how built up a city should really be before it indicates to the nation that a settler is really needed. This makes the civ focus on growing its cities up a bit before they consider the civ ready to expand, but not by too much population.
Note: this is basically still the root of the k-mod code you posted as a suggestion so would end up in the same trouble.
Code:
bGrowMore = (eUnitAI != UNITAI_WORKER || GET_PLAYER(getOwner()).AI_totalAreaUnitAIs(area(), UNITAI_WORKER) > 0)
&& getPopulation() < 3 && AI_countGoodTiles(true, false, 100) >= getPopulation();
Interesting though... his notes seem to indicate that perhaps all this was originally programming to control the building of workers when in my research and yours confirming it looks more like control for settlers. Worker generation may be a little (seriously) out of whack somehow as well particularly if they're using the same logic which I did not suspect when originally working with this. Looks like it may be that a positive result is necessary for building workers huh?
We may really want to differentiate how this works for workers and settlers!
Also... taking a second look at this code it does show that I'm asking early cities to perhaps grow too much as a prereq. Someone said elsewhere that the civs were taking off after a point but they were sluggish in the beginning and I think turning the 4s into 3s and making a min 1 rather than a 1+ in these equations would free them up more appropriately in the early stages:
Code:
if (isCapital())
{
bGrowMore = (getPopulation() < (4 * (1+(int)GET_PLAYER(getOwnerINLINE()).getCurrentEra())));
}
else
{
bGrowMore = ((getPopulation() < (4 * (1+(int)GET_PLAYER(getOwnerINLINE()).getCurrentEra()))) && (AI_countGoodTiles(true, false, 100) >= getPopulation()));
}
So I'm really suggesting we change it to:
Code:
if (isCapital())
{
bGrowMore = (getPopulation() < (3 * (std::max(1,(int)GET_PLAYER(getOwnerINLINE()).getCurrentEra()))));
}
else
{
bGrowMore = ((getPopulation() < (3 * (std::max(1,(int)GET_PLAYER(getOwnerINLINE()).getCurrentEra())))) && (AI_countGoodTiles(true, false, 100) >= getPopulation()));
}
It makes sense to me to have a minimum population to build settlers.
But where this code may be interacting with worker production is another issue entirely and may explain why one of the civs in the screenshots recently was having a tough time building workers.