Which Python file controls when AI will attack your cities?

I wonder what is causing this issue, I haven't touched the dll Oo

There was a point when the AI did not act this way in the mod, but that was before I added new civics, so I'm wondering if adding the Military Civic option has affected the AI somehow.
 
Sure it's not a difficulty level issue or something? Don't remember if you can actually modify it, but the AI usually holds off of attacking you before a certain number of turns have passed.
 
Not sure, but I remember the AI being much quicker to attack. But it isn't that they won't declare war, its just they will move a stack of units into your borders, then patrol near your capital city, but they will refuse to attack the city itself, and will move their units around tiles near the city.

This continues later into the game as well. The AI will attack other AI civs however...
 
They say a picture equals a thousand words...so here is a screenshot of what I'm talking about

WtH.jpg


Two enemy armies, both of which alone could easily take my one city here, yet none of them will attack. Instead they move back and forth near the city.
 
My guess is that the AI decides to attack the city and pushes the "move to city" to the units. They then stand next to the city and will no longer attack because the odds are not good enough and moves away. Once they are back to start, they decide to attack because they can no longer see your fortified unit and the cycle continues.

I base this on a brief look at the DLL code. The odds can be heavily affected by XML meaning the unmodified DLL can behave very differently depending on XML changes. I'm not sure if it can be affected by python. There is no python references in the code I looked at and I would personally not want something like this to be handled by python due to performance concerns. The AI can be quite CPU heavy, which is why most of the AI is handled by the DLL alone (C++ is way faster than python).
 
What XML would influence the AI like this though? :confused:
Any, which affects combat odds. I assume that would mainly be units and promotions. A good place to start is to see what the combat odds are and if they are what you expect them to be. Also you mentioned civics yourself. Maybe that will be worth taking a closer look into. You could even try to undo your changes there and see what happens (do backup your mod first!).

Also keep in mind that it is only a guess. Assuming the guess to be right, there would actually be two bugs. One is combat strength, which isn't what you expect it to be. The other one is that once it discovers that it don't want to attack the city, it moves away, forgets the defense and decides to attack again, hence getting the units stuck in a loop. Not only is a unit in a loop useless, the units will stay next to your units when the AI decides it would lose combat.

The only way to really figure out why the AI does as it does would be to debug and set a breakpoint where the AI has to decide what to do with the unit. That is the only way to fully see what the AI does and why it decides not to attack. However somehow I find it just plain wrong to say "use the debugger" to somebody, who uses an unmodified DLL. Without debugging, it will likely be a matter of a bit of trial and error approach than a completely systematic "correct" approach.

I don't think the AI is smart enough to try to lure you into attacking their units and that way avoid you from benefitting from city defense. That would actually be clever, but the AI generally is more of a brute force player than a trick and deception player.
 
Thanks Nightinggale you've been very helpful.

I don't know if the Civics would change combat odds, nothing I added effects unit strength directly.

As for Promotions, I did add Desert Combat, but that is pretty much it. In the screenshot none of the units had any promotions I added, and it was very early in the game, so only basic civics were being used.

I'm at a loss why this would cause the loop.
 
I'm not exactly sure what calculations are involved and am not looking it up, so keep that in mind...

The two armies outside the city are presumably also at war with each other due to the "minor" status of everyone. A second enemy stack in the area may be influencing the odds of attacking - each of them may be adding up the strength of all enemy units in the vicinity to determine if it has enough units to attack, and that might include enemy units of some 3rd civ.

Try deleting one stack, or moving them back to their capitol, and see if the other one attacks.
 
Back
Top Bottom