AI not building new cities with their settlers

Bad Player

Deity
Joined
Oct 31, 2005
Messages
3,534
Location
(Bris)Vegas!
Hi, I'm making a scenario using MNAI modmod for FFH2. I added a bunch of python code in CvEventManager (and modified some values in .xml files) so I assume the problem is from something I did since the AI works fine in regular MNAI for FFH2.

I played more than 100 turns and all the AI civs build a settler but keep them in their capital cities. The game speed is normal and the map is large and has plenty of space for the AI to expand.

To prove that the issue isn't an economic one, I gave each AI civ 500 gold at the start of the game and placed a few cottages for each civ (via WB). Still, the AI didn't build additional cities with their settlers.

I wondered if it is perhaps because I started the evil civs at war with the good civs? Or perhaps to do with the python declare war using WARPLAN_TOTAL? :confused:


Here is the complete CvEventManager.py code http://pastebin.com/yBWxy5GH

Here is some of my code (from the above link) which might be relevant
Code:
	def onGameStart(self, argsList):
		'Called at the start of the game'

...
		
		#Find and set the Team (i.e. player) ID numbers for each civ in the game (could be done manually since it is a scenario with fixed civs)
		#ID's need to be remembered for the onBeginGameTurn section (so if code is moved away from CvEventManager.py to other files then use pickle + Bugdata to remember it perhaps?)
		for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
			pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
			if pGoodAndEvilPlayer.isAlive():
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
					iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
					iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
					iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
					iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
					iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
					iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
					iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
					iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
					iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
				if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
					iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()

				
					
		#Make the good civs at permanent peace with eachother, the evil civs at non-permanent peace with eachother, and the good and evil civs at war		
		#If the setPermanentWarPeace boolean is True then the civs cannot change their peace or war status.  Use declareWar first to keep them at war with the True boolean.
		#If the declareWar boolean is True then you get a pop-up message that the civ declares war on you, if it is False then there is no pop-up message
		#If the meet boolean is True then you get a pop-up message that you met them for the first time, if it is False then there is no pop-up message
		
		for iWarAndPeaceTeam in range(gc.getMAX_CIV_TEAMS()):
			pWarAndPeaceTeam = gc.getTeam(iWarAndPeaceTeam)
			if pWarAndPeaceTeam.isAlive():
				#Make good civs meet other good civs
				if iWarAndPeaceTeam == iBannorTeamID:
					pWarAndPeaceTeam.meet(iElohimTeamID, False)
					pWarAndPeaceTeam.meet(iKuriotatesTeamID, False)
					pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
					pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
				if iWarAndPeaceTeam == iElohimTeamID:
					pWarAndPeaceTeam.meet(iKuriotatesTeamID, False)
					pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
					pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
				if iWarAndPeaceTeam == iKuriotatesTeamID:
					pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
					pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
				if iWarAndPeaceTeam == iLjosalfarTeamID:
					pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
				#Make evil civs meet other evil civs
				if iWarAndPeaceTeam == iCalabimTeamID:
					pWarAndPeaceTeam.meet(iClanOfEmbersTeamID, False)
					pWarAndPeaceTeam.meet(iDovielloTeamID, False)
					pWarAndPeaceTeam.meet(iSheaimTeamID, False)
					pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
				if iWarAndPeaceTeam == iClanOfEmbersTeamID:
					pWarAndPeaceTeam.meet(iDovielloTeamID, False)
					pWarAndPeaceTeam.meet(iSheaimTeamID, False)
					pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
				if iWarAndPeaceTeam == iDovielloTeamID:
					pWarAndPeaceTeam.meet(iSheaimTeamID, False)
					pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
				if iWarAndPeaceTeam == iSheaimTeamID:
					pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)			
				#This section makes the evils civs at war with the good civs 
				if iWarAndPeaceTeam == iCalabimTeamID:
					pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
					pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iClanOfEmbersTeamID:
					pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
					pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iDovielloTeamID:
					pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
					pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iSheaimTeamID:
					pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
					pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iSvartalfarTeamID:
					pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
					pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				#This makes good civs be at peace with good civs
				if iWarAndPeaceTeam == iBannorTeamID:
					pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iElohimTeamID:
					pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iKuriotatesTeamID:
					pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
				if iWarAndPeaceTeam == iLjosalfarTeamID:
					pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
 
Or perhaps to do with the python declare war using WARPLAN_TOTAL? :confused:
I wouldn't be surprised if workers and settlers are kept safe in cities during WARPLAN_TOTAL. However I can't find the code, which decides what to do with settlers in the DLL. I have a feeling that the AI assumes danger in neutral plots if WARPLAN_TOTAL is active... or something like that.

Try not to declare war and see if that fixes the problem. Presumably not what you want, but at least can pinpoint what causes the problem.
 
Play testing it a lot and every AI makes a settler but keeps them in their city/ies and never makes a new city UNLESS I remove my war declaration code. So the bug relates to something about what I'm doing declaring permanent war (tried TOTAL_WAR and LIMITED_WAR).

I tried a regular FFH2 MNAI game with 2 civs (Me vs Sheiam) and the only game option being ALWAYS WAR. Turn 161 and the Sheaim have a settler in their only city but they haven't created a new city. Could it be that the AI doesn't build new cities when ALWAYS WAR is on?
 
I tried starting at peace and then declaring war on a couple of the AI (but not the rest). The peaceful AI built multiple cities but the AI that I declared war on had stunted growth. One of them didn't build a new city (but had a settler) and just conquered a barbarian city and the other AI that I declared war on built 2 cities but much later than the peaceful AI civs.
 
Back
Top Bottom