Specific Bug Reports

The AI sometimes sends stacks of nothing but siege, with no actual city attackers.

Report in this thread:

http://forums.civfanatics.com/showpost.php?p=8260183&postcount=99


I've seen similar in games. But for me I'd only witnessed the behavior with small stacks in the early game, and always from minor tribes, so didn't think it was worth reporting. But the example in the link above is a naval invasion where the AI assualts with 10 bombards (catapult-cannon intermediary), and thus would be unable to take the city it is assaulting. Definatly should be looked at. Before the AI sends out a stack it should make sure at least 1/2 the units in the stack are capable of capturing a city.
 
Thanks for the report. The AI does not do much if any checking on the contents of the stacks it sends out yet, it's a bigger problem with naval invasions than land invasions just because of the way land stacks work. Another similar issue can happen when the AI sends out an early naval invasion made of just ATTACK and COUNTER units, with no ATTACK_CITY. ATTACK_CITY are the nucleation points for AI stacks, so I've watched Ragnar launch an exciting early invasion with the wrong troop AI types, land his 8-10 units, and then have them disperse into pairs wandering around the countryside.

That was pretty lame too.
 
I have tried to merge this with the MoreStuffMod. It has been a while but there was something that wasn't a member of CvSelectionGroup. In one of the player infos. I checked and it was right there in CvSelectionGroup. Because of this it wouldn't compile.
 
Daryl95, that isn't caused by the incorrect spelling of separate is it? I seem to recall the same file causing the trouble.

Make sure anywhere there's a seperate you change it to separate.

Hope that helps.
 
Daryl95, that isn't caused by the incorrect spelling of separate is it? I seem to recall the same file causing the trouble.

Make sure anywhere there's a seperate you change it to separate.

Hope that helps.
Thanks now I'll try to recompile it. I have a question though. How did the BBAI team compile it if there was a problem there?
 
Calling "setFoundedFirstCity" or "setNewPlayerAlive" causes python error.
There is no API.

Therefore, when automated player has been destroyed, python error occurs.

I copied them from Revolution mod.
Then it goes well.

Sorry if this problem is already spotted.
 

Attachments

  • setNewPlayerAlive_error.jpg
    setNewPlayerAlive_error.jpg
    130.7 KB · Views: 96
  • setNewPlayerAlive_error2.jpg
    setNewPlayerAlive_error2.jpg
    110.1 KB · Views: 74
I've been wondering about one thing for some time now and it's about the overflow of city production. The question is that are the building/civic modifiers added to the overflow production as well or is the overflow from previous turn only added to the final sum? Ie. is it like this:

(city production + previous turn overflow ) * modifiers

or like this:

city production * modifiers + overflow


I went and looked the code section from the RevDCM sources but I'm not a coder and looking at the code only got me more puzzled:

CvCity.cpp
Code:
int CvCity::getProductionDifference(int iProductionNeeded, int iProduction, int iProductionModifier, bool bFoodProduction, bool bOverflow) const
{
	if (isDisorder())
	{
		return 0;
	}

	int iFoodProduction = ((bFoodProduction) ? std::max(0, (getYieldRate(YIELD_FOOD) - foodConsumption(true))) : 0);

	int iOverflow = ((bOverflow) ? (getOverflowProduction() + getFeatureProduction()) : 0);

	return (((getBaseYieldRate(YIELD_PRODUCTION) + iOverflow) * getBaseYieldRateModifier(YIELD_PRODUCTION, iProductionModifier)) / 100 + iFoodProduction);

}

If I understood it correctly the overflow is added to the base value before the modifiers which does seem odd as in that case overflow would have the bonus from modifiers twice... first in the turn the overflow is created (it's base value only at this time) and then on the turn the overflow is used. Correct me if I'm wrong. :confused: If the bonuses are added twice, it's a bug and could be exploited by player.
 
In CvCity::changeOverflowProduction (which stores overflow from previous production), the overflow is divided by the production modifiers for whatever was recently completed. In the code you have above, overflow is then multiplied by the modifiers for what is being built.

I think it's working right.
 
I've got a problem with the newest BBAI (0.80) and one of my own game options: "No starting technologies".

Code from CvEventManager.py:

PHP:
	def onGameStart(self, argsList):
		'Called at the start of the game'
		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setText(u"showDawnOfMan")
					popupInfo.addPopup(iPlayer)
		else:
			CyInterface().setSoundSelectionReady(true)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)

## NO STARTING TECHS START ##

		for iPlayerLoop in range(gc.getMAX_CIV_PLAYERS()):

			pPlayer = gc.getPlayer(iPlayerLoop)

			iPlayer = pPlayer.getID()

			if (pPlayer.isAlive() and gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_STARTING_TECHS)):

				iTech1 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_FISHING')
				iTech2 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_THE_WHEEL')
				iTech3 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_AGRICULTURE')
				iTech4 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_HUNTING')
				iTech5 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MYSTICISM')
				iTech6 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MINING')
				pTeam = gc.getTeam(pPlayer.getTeam())
				pTeam.setHasTech(iTech1, false, iPlayer, false, false)
				pTeam.setHasTech(iTech2, false, iPlayer, false, false)
				pTeam.setHasTech(iTech3, false, iPlayer, false, false)
				pTeam.setHasTech(iTech4, false, iPlayer, false, false)
				pTeam.setHasTech(iTech5, false, iPlayer, false, false)
				pTeam.setHasTech(iTech6, false, iPlayer, false, false)

## NO STARTING TECHS END ##

		CvAdvisorUtils.resetNoLiberateCities()


This was working under BBAI 0.78. Now, the technologies won't be set to "not known" on init - or it will change too late?! The game crashes when the round ends. I guess it has something to do with your tech diffusion component. Any idea/help/advice?
 
I've added CvAdvisorUtils.py. is there any other important file? I'm using BUG mod in my mod and there is a CvCustomizableDomesticAdvisor.py - do I need the CvDomesticAdvisor.py?
 
Okay... your stock BBAI is crashing too when adding this (correct) code:

Code:
	def onGameStart(self, argsList):
		'Called at the start of the game'

		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setText(u"showDawnOfMan")
					popupInfo.addPopup(iPlayer)
		else:
			CyInterface().setSoundSelectionReady(true)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)

		CvAdvisorUtils.resetNoLiberateCities()

		for iPlayerLoop in range(gc.getMAX_CIV_PLAYERS()):

			pPlayer = gc.getPlayer(iPlayerLoop)

			iPlayer = pPlayer.getID()

			if (pPlayer.isAlive() and gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR")):

				iTech1 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_FISHING')
				iTech2 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_THE_WHEEL')
				iTech3 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_AGRICULTURE')
				iTech4 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_HUNTING')
				iTech5 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MYSTICISM')
				iTech6 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MINING')
				pTeam = gc.getTeam(pPlayer.getTeam())
				pTeam.setHasTech(iTech1, false, iPlayer, false, false)
				pTeam.setHasTech(iTech2, false, iPlayer, false, false)
				pTeam.setHasTech(iTech3, false, iPlayer, false, false)
				pTeam.setHasTech(iTech4, false, iPlayer, false, false)
				pTeam.setHasTech(iTech5, false, iPlayer, false, false)
				pTeam.setHasTech(iTech6, false, iPlayer, false, false)

Dunno why. Any idea?
 
okay. it works with tech diffusion DISabled. so, tech diffusion is the reason. any solution idea?
 
argh! now I cannot compile the dll:

attachment.php



my c++ is noobish, but what about:

Code:
return ((100*iOurTechScore)/std::max(iBestKnownTechScore, 1));
 
Yes, you corrected it exactly right ... sorry, same thing happened to me just after posting that, should have fixed it. The too common ways to ensure no divide by zero (for positive quantities at least) are:

a / (b + 1)

or

a / std::max( b, 1 )

I ended up with a brain-fart hybrid the first time :p
 
Back
Top Bottom