We can't say that not building settlers would have nothing to do with stalled growth - it certainly can. But in this case we've eliminated that as the problem.
You're right about everything you say... it could have to do with the brokerage system failing in some way or being overly cautious. I'm less suspicious of the brokerage stuff though because it does seem to be working for other areas - but if it's the source of the issue then it's a much bigger problem with deeper implications in many other areas.
I do some more testing but i think i simply give settlers CITY_BUILD_PRIORITY_CEILING then looking for a escort.
I was bored from working on the new Schema-Validation so i gave this another try.
ContractFloatingDefenders has the highest priority(CITY_BUILD_PRIORITY_CEILING) when looking for Units, Settlers requesting a Unit as escort only HIGH_PRIORITY_ESCORT_PRIORITY.
If a Unit is build because of a Settlers request it's possible that the CityDefence get's that Unit and the Settler waits. Also the AI seems to scrap Settlers if they have nothing to do after a while so this could be a huge possible problem.
I do some more testing but i think i simply give settlers CITY_BUILD_PRIORITY_CEILING then looking for a escort.
Ok giving those Settler requests for a escort that high priority has an effect. But i'am not happy with the result because in some cases it leads to even more CityDefenders.
The next thing i try is adding a new UnitAI type for those Settler escorts.
[1024.021] Tribe (UNITAI_SETTLE): 1
[1024.021] Gatherer (UNITAI_WORKER): 1
[1024.021] Hunter (UNITAI_ATTACK): 1
[1024.021] Hunter (UNITAI_HUNTER): 1
[1024.021] Stone Maceman (UNITAI_CITY_DEFENSE): 9
[1024.021] Stone Maceman (UNITAI_CITY_COUNTER): 1
[1024.021] Stone Axeman (UNITAI_CITY_DEFENSE): 10
[1024.021] Stone Axeman (UNITAI_CITY_COUNTER): 1
[1024.021] Atlatlist (UNITAI_CITY_DEFENSE): 10
[1024.021] Tribal Guardian (UNITAI_CITY_DEFENSE): 1
[1024.021] Rogue (UNITAI_SPY): 1
//Safely escape the Occasional an inf loop here.
if (m_iLastUnitUpdated != m_iID)
{
m_iLastUnitUpdated = m_iID;
m_iSameUnitUpdateCount = 0;
}
else if (m_iSameUnitUpdateCount > 0 &&
((m_contractualState == CONTRACTUAL_STATE_AWAITING_ANSWER || m_contractualState == CONTRACTUAL_STATE_AWAITING_WORK) ||
(m_contractualState == CONTRACTUAL_STATE_NONE && getGroup()->getMissionType(0) == -1)))
{
m_iSameUnitUpdateCount = 0;
getGroup()->pushMission(MISSION_SKIP);
return false;
}
else
{
m_iSameUnitUpdateCount++;
if (m_iSameUnitUpdateCount > 99)
{
FAssertMsg(m_iSameUnitUpdateCount <= 99, "A Unit has hit an infinite loop in its AI and triggered a loop escape");
m_iSameUnitUpdateCount = 0;
getGroup()->pushMission(MISSION_SKIP);
return false;
}
}
Actually that example looks about right though it's odd that spearmen aren't being built as part of that group.I don't mean law enforcement because such units aren't possible in the early ancient era. Did you also count the Units with UNITAI_CITY_DEFENSE the AI put's on plots around the city?
I havent done much gaming myself in the last weeks so i might be wrong about too much CityDefenders. Maybe i just put this change in the svn and wait how it turns out.
EDIT:
Here is a example what i call too much, these are the unit counts of a random player from a recent autoplay session.
Thanks to 45°38'N-13°47'E for finding the change causing this issue
@thunderbrd
It is caused by a change you made in CvUnitAI::AI_update and the 'else if' added by myself.
Code://Safely escape the Occasional an inf loop here. if (m_iLastUnitUpdated != m_iID) { m_iLastUnitUpdated = m_iID; m_iSameUnitUpdateCount = 0; } else if (m_iSameUnitUpdateCount > 0 && ((m_contractualState == CONTRACTUAL_STATE_AWAITING_ANSWER || m_contractualState == CONTRACTUAL_STATE_AWAITING_WORK) || (m_contractualState == CONTRACTUAL_STATE_NONE && getGroup()->getMissionType(0) == -1))) { m_iSameUnitUpdateCount = 0; getGroup()->pushMission(MISSION_SKIP); return false; } else { m_iSameUnitUpdateCount++; if (m_iSameUnitUpdateCount > 99) { FAssertMsg(m_iSameUnitUpdateCount <= 99, "A Unit has hit an infinite loop in its AI and triggered a loop escape"); m_iSameUnitUpdateCount = 0; getGroup()->pushMission(MISSION_SKIP); return false; } }
I don't remember why we added this but it has to go.
Actually that example looks about right though it's odd that spearmen aren't being built as part of that group.
Yeah, I'm NOT happy with how the AI sends city defense units to hang out outside its cities. If we want local regional defenders that will take terrain defensive roles outside the city then they should be their own AI role, not City Defense! This is currently one of the big weaknesses of the AI I think.
I hope we CAN get rid of it safely. It was a temporary solution, an escape to a huge problem with infinitely looping unit AIs that I found myself incapable of finding the root of the problem at the time. It's entirely possible the original problem was solved since then - or perhaps we'll end up finding it again as a result of getting rid of this and be able to tackle it more properly this time.
The problem stems from the units that should be defending cities not getting the benefit of nearly enough of their potential fortification bonus. They move in as soon as they know they need to and if you're fast enough it's too late, particularly later in the game when you're moving in with Commando units. At that stage they don't even have warning enough to know they need to move into the city before you've stolen it out from under them.It was changed to be this way and if they move into the city in case of real danger i don't see a problem. I think we could change it so the AI leaves a bit more units in cities and give settlers a stronger escort to have a stronger defense in new cities.
Yeah... I'll admit it was a problem that was over my head so I could do little but put this bandaid on it... I'm baffled by how it creates a problem but I've been finding the brokerage system a bit baffling in the first place.We can get rid of it safely because it breaks the game so not having it can't be any worse. If there is another case of infinitely looping there has to be another way to fix it.
The problem stems from the units that should be defending cities not getting the benefit of nearly enough of their potential fortification bonus. They move in as soon as they know they need to and if you're fast enough it's too late, particularly later in the game when you're moving in with Commando units. At that stage they don't even have warning enough to know they need to move into the city before you've stolen it out from under them.
I change the AI code to leave at least two-thirds of their CityDefense in the city instead of the half. The Commando promotion should have a negative CityAttack i think about -20%.
Not only do I vehemently disagree that the commando promo be nerfed (due to it already having extremely stringent requirements to reach) but it also wouldn't help. By this time, air units are able to diminish city defenses and the healths of the units within them so severely that 20% wouldn't make much of a difference (unless there were so numerous defenders all under the shelter of the bunker protection that the city offers, that the amount of damage the air units can deliver is diffused greatly among the defensive stack in the city.)
Additionally, we're doing what we can to nerf naval fleet invasions but they still present the same issue, hitting up to 3 cities per round per fleet they catch city defenders outside the city all the time as well, making those cities fall quite easily too.
I can see a point in having maybe 1/4 of the city defense force outside the city - spreads out bombing raid focus and may help in that regard, and keeps some refreshments capable of coming in after bombardment and collateral hits the city and wears down those stationed there. So this might be better at least somewhat. Just seems they lose a lot of power by losing that fortification bonus.