Bug Reports and Discussion

I'm guessing that a fast and loose way of dealing with the fireball issue could be to make the AI assume that for every fireball caster there exists in the stack a STR 4 MOVE 2 unit.

Sure, the fireball caster may not cast fireball (they may cast a different spell) but it could have the AI a much improved evaluation of an enemy's stack strength.
 
I just had an unexplained crash in my modmod, using the test DLL which fe79 posted to fix the Calabim production issues.

I unfortunately had not saved the game recently.

There is nothing in PythonErr.py, and nothing I find particularly suspicious in any of the other logs.

MPLog.txt ends in two lines containing only spaces and FAVORITE UNITCOMBAT. I don't recall seeing this in this file before, but it is found several other places in that file from previous turns without obvious problems.

PythonDebug.py ends with "PY: Revolt - Completed processing revolution" after the Acquisition of Judicium by Svartalfar. A little higher up it says "WARNING: Civ types 3 and 21 have no unit of class type 265," "WARNING: Civ types 3 and 21 have no unit of class type 266," "WARNING: Civ types 3 and 21 have no unit of class type 274" and higher than that "Error! Minor leaders not found, no short lists available" but it says similar things plenty of other places which must have been long before the crash.

(It might be useful for the log to list the unit class name instead of only its number.)



Also, I've had some complains from MagisterModmod players of some players refusing to expand and falling way behind. Do you know what could be causing such AI issues?

The last time I remember having a major problem like that was when the AI kept pushing or the production of tier 1 units despite having more then the limit I'd place don those in python. I commended out that code so it shouldn't be an issue, but I wonder if maybe you DLL might still be pushing the production of specific buildings or units which are blocked in python under some conditions in my modmod. Could you make sure now to push for the production of anything when it is not possible to build it?
 
I think the AI overvalues fishing as a starting tech, Rohanna for example goes exploration -> fishing right away with just one fish in her capitol BFC.
 
Somehow Sephi got this "spells" part working for AI -at least partially - in his mod AI used ranged spells pretty well.... IIRC autocasting was a big part of it...

The issue in question is about understanding what spells your opponent can cast and how that might affect your troops.

I'm guessing that a fast and loose way of dealing with the fireball issue could be to make the AI assume that for every fireball caster there exists in the stack a STR 4 MOVE 2 unit.

Sure, the fireball caster may not cast fireball (they may cast a different spell) but it could have the AI a much improved evaluation of an enemy's stack strength.

Couple of issues with this approach. Mainly, that it would require hardcoding in the DLL, which is never good in the long run (you really need to do something along the lines of loop through units -> check what spells they have available -> check if that spell is a summons - > check the range, duration, strength and potential collateral of that summons -> then figure out a formula for adding that potential to a stack’s perceived strength). Also, it would require the AI to evaluate potential counter-attacks to its stacks, which I don’t think it does currently. Anyway, this is a rather complex issue. I’ve had a bug entry in on this issue for 2 years now and haven’t even thought about digging into it yet.


I just had an unexplained crash in my modmod, using the test DLL which fe79 posted to fix the Calabim production issues.

There is nothing in PythonErr.py, and nothing I find particularly suspicious in any of the other logs.

MPLog.txt ends in two lines containing only spaces and FAVORITE UNITCOMBAT. I don't recall seeing this in this file before, but it is found several other places in that file from previous turns without obvious problems.

PythonDebug.py ends with "PY: Revolt - Completed processing revolution" after the Acquisition of Judicium by Svartalfar. A little higher up it says "WARNING: Civ types 3 and 21 have no unit of class type 265," "WARNING: Civ types 3 and 21 have no unit of class type 266," "WARNING: Civ types 3 and 21 have no unit of class type 274" and higher than that "Error! Minor leaders not found, no short lists available" but it says similar things plenty of other places which must have been long before the crash.

(It might be useful for the log to list the unit class name instead of only its number.)

The logs don’t really help with unexplained crashes. You have to run a debug DLL which will then point you to the crash area, which isn’t necessarily the problem area but will lead you there with a little sleuthing. I’m occasionally willing to run a debug DLL on a sub-mod mod, but its hard to get motivated to hunt these mod-specific issues down when I have so little time to spend on MNAI itself.

re: MPLog - that line is some old debugging info in regards to tech selection. I’ll switch that section over to use BBAI logs instead.

re: Revolution logging - thats all handled in the Revolutions python code. Should be relatively easy (though possibly a little time-consuming) to switch it to display unit names rather than IDs. Not really on my task list, though. Most of those warnings are about civ-specific units and aren’t especially useful.

Also, I've had some complains from MagisterModmod players of some players refusing to expand and falling way behind. Do you know what could be causing such AI issues?

Do the AIs have Settler units? If so, then they should be making units to group with the Settlers (unless they are at war - are the users playing with the Always War setting or Aggressive AI options?). If you look at the Settler units in debug mode, you can see if they are grouped or not, which would be useful info.

If they aren’t building Settlers, then likely something is happening in the python chooseProduction code. You have some extra code in there for your mod, correct?

The last time I remember having a major problem like that was when the AI kept pushing or the production of tier 1 units despite having more then the limit I'd place don those in python. I commended out that code so it shouldn't be an issue, but I wonder if maybe you DLL might still be pushing the production of specific buildings or units which are blocked in python under some conditions in my modmod. Could you make sure now to push for the production of anything when it is not possible to build it?

canBuild is checked before any build orders are pushed (or canTrain if we’re talking about units).
 
The logs don’t really help with unexplained crashes. You have to run a debug DLL which will then point you to the crash area, which isn’t necessarily the problem area but will lead you there with a little sleuthing. I’m occasionally willing to run a debug DLL on a sub-mod mod, but its hard to get motivated to hunt these mod-specific issues down when I have so little time to spend on MNAI itself.

That is what I figured. I hadn't had a crash with your DLLs in quite a while though. This crash was with fe79's dll instead of yours though, so maybe he can find an issue.

re: MPLog - that line is some old debugging info in regards to tech selection. I’ll switch that section over to use BBAI logs instead.

re: Revolution logging - thats all handled in the Revolutions python code. Should be relatively easy (though possibly a little time-consuming) to switch it to display unit names rather than IDs. Not really on my task list, though. Most of those warnings are about civ-specific units and aren’t especially useful.
It looks like it would only require editing line 541 of RevUtils.py.

Code:
			if( playerUnitType < 0 and cityUnitType < 0 ) :
[COLOR="Green"]##				print "WARNING: Civ types %d and %d have no unit of class type %d"%(city.getCivilizationType(),pPlayer.getCivilizationType(),unitClass)#Magister[/COLOR]

[COLOR="Red"]				if city.getCivilizationType() == pPlayer.getCivilizationType():
					print "WARNING: Civ type %s has no unit of class type %s"%(gc.getCivilizationInfo(pPlayer.getCivilizationType()).getDescription(), gc.getUnitClassInfo(unitClass).getDescription())
				else:
					print "WARNING: Neither Civ type %s nor %s has any unit of class type %s"%(gc.getCivilizationInfo(city.getCivilizationType()).getDescription(), gc.getCivilizationInfo(pPlayer.getCivilizationType()).getDescription(), gc.getUnitClassInfo(unitClass).getDescription()
)[/COLOR]

				continue

(I decided to make it a bit more complicated because it seemed pointless and a bit confusing to list both civ types when they were identical.)
Do the AIs have Settler units? If so, then they should be making units to group with the Settlers (unless they are at war - are the users playing with the Always War setting or Aggressive AI options?). If you look at the Settler units in debug mode, you can see if they are grouped or not, which would be useful info.

If they aren’t building Settlers, then likely something is happening in the python chooseProduction code. You have some extra code in there for your mod, correct?
Those players say that they have tried gifting the player units and using WorldBuilder to end all of their wars, to no avail.

I just checked one saved game that someone posted after mentioning the issue, I see that one of their settlers is in a group with 2 hunters and an archer while the other is the only unit in its group.

They are not nearly as far behind as I was expecting from the complaint though, so it may not be that big of a deal.

canBuild is checked before any build orders are pushed (or canTrain if we’re talking about units).

I don't think that canBuild or canTrain are used in FfH2, MNAI, or MagisterModmod. In PythonCallbackDefines.xml they are set to <iDefineIntVal>0</iDefineIntVal>.


Limits on what can be built or trained are all in cannotBuild or cannotTrain. It does not appear that pushOrder ever checks if things are blocked that way.

Nowhere in the python portion of my modmod is pushOrder ever used for anything that is blocked. I'm not so sure about the DLL.

MagisterModmod uses cannotTrain more then MNAI, but less than base FfH2. It does not have the various AI controls that Kael used before you improved the AI otherwise, but it contains additional blocks to prevent the Luonnatar and Cult of the Dragon units from being trained when the game options are activated to block them. It also is used to limit the Nightwatch and Radiant Guard units so that they can always be built by players with the appropriate state religion but can also be built by players of other religions but the appropriate council membership once the associated council resolutions have passed.

I used to include a block to stop early game unit spamming by preventing the training of any more tier 1 units once a player already had more than a certain number of that unit type per city. I commented this out a while back, after it started causing problems.

The issue I was remembering from a while back was caused by Auric's player AI trying to push for the production of a unit with UNITAI_ATTACK at a point when the only such unit was the basic tier 1 warrior of which he had too many. It kept trying to force another a warrior but it never got built, and in the meantime the player never accomplished anything else including researching the tech needed to make tier 2 units with that UNITAI available.


p.s. I just noticed that the city edit lacks the ability to edit the city's Revolution Index. I believe it had the ability before the WorldBuilder 4.0 merge, and that I forgot to carry it over. I'm also thinking that there is no good reason not to allow you to change the civilization type of a city even if its owner does not have the tolerant trait and thus would not be able to take advantage of it, since someone else with that trait could capture it. I just made those changes, plus made it so that they will be included in worldbuilder saves. I'm just about to get another version ready to upload for you, after I make sure that Platyping hasn't made some more stealth improvements. .
 
I don't think that canBuild or canTrain are used in FfH2, MNAI, or MagisterModmod. In PythonCallbackDefines.xml they are set to <iDefineIntVal>0</iDefineIntVal>.

Limits on what can be built or trained are all in cannotBuild or cannotTrain. It does not appear that pushOrder ever checks if things are blocked that way.

You're right. I keep forgetting that FFH uses the negative checks.

Nowhere in the python portion of my modmod is pushOrder ever used for anything that is blocked. I'm not so sure about the DLL.

I see. I misunderstood what you were asking. Yes, I believe you are correct (not at home now so I cant check the code directly). I believe that pushOrder doesn't do any checks on its own. Those checks should all be done beforehand.

If I get a chance this weekend I'll set up a Magister Modmod install on my laptop so I can take a quick look at some of the saved games with issues.
 
when using advanced tactics, self pillaging will remove your culture from the tile :D

it also seems like you lose peace with the barbarians once you accept a vassal even if he also has barbarian trait. I accepted Hyborem as a vassal and shortly after I noticed barbarian units would attack mine, even if there was no "the barbarians declare war on you" announcement. I'm attaching a save even if it's with extramodmod, it's a perfect one as it's right on the turn that Hyborem asks to become a vassal. I guess he declared war on the barbarians and that's what causes it, IIRC he does that when he wants to conquer barbarian cities.
 

Attachments

[to_xp]Gekko;13306758 said:
when using advanced tactics, self pillaging will remove your culture from the tile :D

By Design. In Advanced Tactics, pillaging causes loss of culture for everyone on the plot (the locals dont appreciate having their infrastructure destroyed).

t also seems like you lose peace with the barbarians once you accept a vassal even if he also has barbarian trait. I accepted Hyborem as a vassal and shortly after I noticed barbarian units would attack mine, even if there was no "the barbarians declare war on you" announcement. I'm attaching a save even if it's with extramodmod, it's a perfect one as it's right on the turn that Hyborem asks to become a vassal. I guess he declared war on the barbarians and that's what causes it, IIRC he does that when he wants to conquer barbarian cities.

Thanks. I updated Bug #91 with this info.
 
automated terraforming doesn't work for sanctify ( unit stays still ) and vitalize ( unit retreats to the nearest city ) , I haven't tried bloom lately but it probably doesn't work as well.
 
In my current game I don't want automated terraforming for sanctify because you get extra goodies from gulcarn, toads, and to some extent razorweed - I manually sanctify around those special resources (if that's what you meant).
 
well of course you'll be required to do it manually if you want to choose exactly which tiles should be hell and which not. what I'm saying is that the unit doesn't behave as intended when set to do it automatically, they just kinda freeze.
 
I just caught an insidious bug which has been present in ExtraModMod for a lot of time and I wasn't able to reproduce consistently. What was happening was that, whenever a player casted a spell which created a unit with a custom duration outside of his cultural borders, this unit would trigger a permanent increase of unit supply costs. Look at the following python code for a spell:

Code:
def spellSeverSoul(pCaster):
	newUnit = gc.getPlayer(pCaster.getOwner()).initUnit(gc.getInfoTypeForString('UNIT_SEVERED_SOUL'), pCaster.getX(), pCaster.getY(), UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH)
	newUnit.setSummoner(pCaster.getID())
	newUnit.setDuration(3);
	newUnit.setHasCasted(True)

When the spell is casted outside of the cultural borders, initUnit will increase CvPlayer::getNumOutsideUnits by 1 (because a new unit has been created) and the supply costs will increase accordingly. The code later sets the duration of the unit to a temporary value, which does not cause CvPlayer::getNumOutsideUnits to be reduced and therefore supply costs stay the same. Since all of the logic around CvPlayer::getNumOutsideUnits ignores temporary units, when the unit is finally destroyed this variable will not be decreased and the supply costs will remain artificially high forever. The effects accumulate through time, up to a point that the player can no longer face the supply costs.

Although this bug should not be present in MNAI (to my knowledge there is no python code in vanilla that does a thing like what I pasted earlier), it could be present in ModMods based on it, and it will probably be present in MagisterModMod, which is from where EMM took this implementation for Sever Soul before it was tweaked. In order to fix this bug, it is needed to do the following changes to CvUnit::setDuration.

Code:
 void CvUnit::setDuration(int iNewValue)
 {
+       /*
+        * Bugfix: If a unit is made temporary or permanent in a place in which units must pay supply costs,
+        * the NumOutsideUnits variable must be updated accordingly.
+        */
+       if (m_iDuration != iNewValue && plot()->getTeam() != getTeam() && (plot()->getTeam() == NO_TEAM || !GET_TEAM(plot()->getTeam()).isVassal(getTeam()))) {
+               if (m_iDuration == 0) {
+                       // The unit is now temporary.
+                       GET_PLAYER(getOwnerINLINE()).changeNumOutsideUnits(-1);
+               } else if (iNewValue == 0) {
+                       // The unit is now permanent.
+                       GET_PLAYER(getOwnerINLINE()).changeNumOutsideUnits(1);
+               }
+       }
+
        m_iDuration = iNewValue;
 }

I will create a new issue in the MNAI tracker for this issue shortly after I'm done with this post.
 
can the AI be thaught to not build forts right next to their cities? it is unwise to offer such a nice healing platform to invaders ;)
 
[to_xp]Gekko;13307564 said:
automated terraforming doesn't work for sanctify ( unit stays still ) and vitalize ( unit retreats to the nearest city )

Working on fixing this and cleaning up the terraformer code at the same time (it is pretty messy). Thanks for the report.

I haven't tried bloom lately but it probably doesn't work as well.

Not only is your assumption incorrect, but this is a rather obnoxious comment and an inappropriate way to present a potential issue.


I just caught an insidious bug which has been present in ExtraModMod for a lot of time and I wasn't able to reproduce consistently. What was happening was that, whenever a player casted a spell which created a unit with a custom duration outside of his cultural borders, this unit would trigger a permanent increase of unit supply costs

...

I will create a new issue in the MNAI tracker for this issue shortly after I'm done with this post.

Thanks for the report and updated code. I'll include this fix in the next release.
 
Svartalfar fire balls can't kill like other civ's fire balls. Is this a glich or intentional?

Intentional. The summoned units of Svartalfar arcane units are illusions, and therefore they can only do damage but they cannot kill.
 
Back
Top Bottom