Failing to build workers on islands:

Yakk

Cheftan
Joined
Mar 6, 2006
Messages
1,288
I think this is the culprit:

From
UnitTypes CvCityAI::AI_bestUnitAI(UnitAITypes eUnitAI, bool bAsync, AdvisorTypes eIgnoreAdvisor)

Code:
	if (GET_PLAYER(getOwnerINLINE()).getNumCities() <= 2)
	{
		bGrowMore = ((getPopulation() < 3) && (AI_countGoodTiles(true, false, 100) >= getPopulation()));
	}
	else
	{
// I think the bug is here:
[b]		bGrowMore = ((getPopulation() < 3) || (AI_countGoodTiles(true, false, 100) >= getPopulation()));[/b]
	}
	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;                
			}
		}
	}

Overall, it is pretty smart -- but I think instead of counting the number of cities that the player owns, what if we count the number of cities in that land area?

That would make a city on an new continent want to pump out workers to start off.

A better refinement might just increase the cost of a food-requiring unit, rather than simply ignoring every food-requiring unit when we think the city should grow.

Thoughts?
 
True. A financial city with a lighthouse might reach it's happy cap and not build settlers or workers.

I've seen that stop a civ that could get 3 cities on its island stop expanding for a long time. And it doesn't check unhealthiness for floodplains because they're so good. Just not good enough to make you grow faster if the city has so many it's already unhealthy.

But there's another problem in AI_chooseproduction:

here:
Code:
//do a check for one tile island type thing?
    //this can be overridden by "wait and grow more"
    if (!bDanger && (iExistingWorkers == 0) && isCapital())
    {

and here:

Code:
if (!(iExistingWorkers == 0) && !bImportantCity)
	{
        if (!bDanger && (iExistingWorkers < ((iNeededWorkers + 1) / 2)))
		{
			if (AI_chooseUnit(UNITAI_WORKER))
			{

iExistingWorkers is done per area.

That's right, the AI tries to build the first worker on an island or continent in it's capital :lol: . There's another check later on but it counts improvable tiles as a proportion of worked tiles and, yes, most sea tiles are not improvable.

I did report this in February.

I'll try and get the source for the changes I've made up. I'll see how TortoiseSVN does patches.
 
Oh ya, I modified some of that logic.

Sadly, I think we need Blake/Iustus to give us approval to do check-ins.
 
Back
Top Bottom