Is there any logic to an AI DoW?

Thank you Dan for your answer! And I can confirm it from practical experience, it has just happened to me 5 min ago! :crazyeye:

Monty just DoWed me when I sent him off even though he was at war with SB...The whole manipulative pacifistic approach blew up in my face. Well, at least it's a limited war...how bad could it be from Monty? :rolleyes: :cringe:

Oh, one more thing: how's the 'bordering tile' defined? Do tiles that only have 1 corner in common also count or do they at least need to have one mutual side? (I've been counting tiles to stay under the LT limit. :mischief:)

EDIT: Is it also possible that not giving in to demands could override Friendly status? If that's true, diplomacy just got a lot more complicated...
 
^^Been there, done that..... :(
And I can confirm it from practical experience, it has just happened to me 5 min ago! :crazyeye:

:)

I've just compiled the top 10 charts of the most notorious sneak attackers (iDemandRebukedSneakProb / CONTACT_DEMAND_TRIBUTE * 100). And who is first? :D



Also interesting, all 3 French leaders show up in here too :hmm:

Oh, one more thing: how's the 'bordering tile' defined? Do tiles that only have 1 corner in common also count or do they at least need to have one mutual side? (I've been counting tiles to stay under the LT limit. :mischief:)

CvTeamAI::AI_isLandTarget(TeamTypes eTeam) asks for the number of 'adjacent' land plots -- this includes the NE|SE|SW|NW directions (Other functions like the random spreading of forest/jungle are limited to the 'cardinal' directions N|E|S|W.). The corresponding plots of both teams need to be land plots.

Edit: the AIs will only demand things when <= CAUTIOUS (DemandTributeAttitudeThreshold).
 
:)

Edit: the AIs will only demand things when <= CAUTIOUS (DemandTributeAttitudeThreshold).

I know that, but is it just paying tribute that can trigger the demand rebuked mechanism? What about pleads for help, joining wars, adopting religion, etc...? In my game, Monty asked me to join the war against SB and I declined. On the next turn he attacked. Well, theoretically it could be some rebuked tribute demand from while back...but I can't remember not paying for a tribute and I don't have it in my game notes either...:hmm:

EDIT:

Nope, it just came back to me, his arrogant face and some ramblings about my pitiful defense or sth...:mischief: I must have repressed it in my memory. ;) Well, time to draft some muskets I guess and forget Pacifism. :ar15: Oddly, he only sent 1 trebuchet for the attack and nothing more in the next few turns...

Anyway, if it's just not paying for tribute that can cause the war then it isn't such a big problem. Another interesting thing is that there are some civs that have iDemandRebukedSneakProb = 0, Fred for example. AI bluffer! :lol:
 
You can relax, Yamps ;). AI sneak attacks are restricted to the diplo event REJECTED_DEMAND (they either demand gold, your maps, a tech, or a resource). The only consequences of the other diplo events you mentioned (REFUSED_HELP, NO_CONVERT, NO_REVOLUTION, NO_JOIN_WAR, NO_STOP_TRADING) are the -1 or -2 diplo demerits ("You refused to help us during war-time!" etc). The code is in CvPlayer::handleDiploEvent().

The 10 bluffers whose demands you can safely answer with a "shove it!":

 
Great! :) Back to diplo manipulation it is. :cool:
 
That thread is just incredible helpful - I never though that the go-to-war-decision is as complex :goodjob:

One question...


The other interesting factors are how Vassals and the financial situation affect the probabilities for wars. I don't really know what to think of the HUSP-factor (HighUnitSpendingPercentage). For boxed in unit spammers this should be huge (compact empire = low total expenses). E.g. checking the 990AD save of Sisiutil's ALC24 shows Mehmed with USP = 12/57 = 24% (HUSP = (USP-7)/3 = 5) and 2-city-Pacal with 2/4 = 50% (HUSP = 14) (note: foreign trade is not taken into account!). So they should consider a total war 6 / 15 times as often, but Pacal's power is probably much to low to actually find a valid victim.
It's also interesting how the raiders don't care about the attitude that much (NWR+10), so Boudica will declare at pleased if she is in financial trouble! (Edit: no she won't due to the capping at 99 and her NoWarProb=100)

If I understand that passgae and the table below it correctly, most civs will not enter wars, if they are in financial troubles (40% slider for gold not enough to break even comes to my mind from another passage), except they are a raider, right? I first wondered what determined this character, but looking on the table it seems to be related to having a iLimitedWarRand, iMaxWarRand and/or(?) iDogpileWarRand below 100?
Is that correct and if yes, is one value enough or need to be all below 100? If not, what determines is then?

Thanks in advance!


Edit: Another question concerning this:

iDeclareWarTradeRand - this is where it gets interesting. This xml value is 40 for all leaders except for one, Pacal's is 60; it is used to determine the probability that an AI bribes another player to join a war it is currently fighting with a 3rd player. The formula for the chance to consider a bribe strongly depends on the duration of the most recent war (CHOSEN dogpile wars get a penalty -> fewer bribes):
WarCounter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ...
Chance: 50%| 33%| 25%|5.8%|4.7%| 4%|3.4%| 3%|2.7%|2.5%|2.5%|2.5%| ...These numbers are for the xml value of 40; since higher values result in lower chances (it's a "...Rand" in contrast to the "...Prob"s), Pacal's chances are 50%|25%|20%|4%... There is a sharp drop after the 3rd turn.

In CvPlayerAI::AI_doDiplo() the AI loops over all other players (the human player comes last); if it doesn't decide to contact the current potential trading partner for any other reasons it will try to bribe him into one of its wars (this does not need to be the most recent war!) with the above mentioned probability. That's how I understand the code, I'm quite shocked about the 50/50 chance on the first turn after the DoW, but more requirements must be met. The human player cannot be bribed (normally, see below ).
If the RNG agrees to a potential bribery, the code loops over all valid dogpile victims and determines the "best".

If the human player is considered here (though last), I wonder what the relation or difference to "iContactRand: CONTACT_JOIN_WAR" is?
Are those to seperate ways of the AI to get a human player into an ongoing inter-AI-war? And why gets a human player never offered a tech for joining a war, if the AIs do that frequently among each other?
 
The more exact criteria for AI_isFinancialTrouble() were given here:
Edit: some minor corrections:
A) 4. AI is in financial trouble when (Inflated Costs + foreign trade deficit) > 60% of (beakers per turn + taxes income + foreign trade surplus), threshold increases by additional +8% when aiming for cultural victory, +12% when at war or preparing one, +10% when researching Future Techs​

The statement "can't break even @ 40% research-slider" was a very rough approximation not taking into account beakers and gold income from shrines/wonders/specialists and commerce spent on culture or espionage.
BTW while looking at the code in AI_isFinancialTrouble() again I'm afraid I found yet another minor bug: the foreign trade deficit is actually subtracted from the inflated costs --> an AI's risk to get into financial trouble is decreased by spending a lot of :gold:/turn to buy resources :crazyeye:.

Your questions:

1. An AI in financial trouble only opposes war if it is currently not using AI_STRATEGY_DAGGER and it isn't an aggressive raider who likes wars as a means to get money. Your understanding of the condition is correct -- the developers IMHO intended that an AI in financial trouble will still consider to start one of the 3 types of war (MaxWar, LimitedWar, DogpileWar) if its respective iWarRand is smaller than 100 (iMaxWarRand < 100 --> consider a MaxWar-Raid; iLimitedWarRand < 100 --> consider a LimitedWar-Raid; iDogpileWarRand < 100 --> consider a DogpileWar-Raid). However, as described in post#84, they made a slight mistake so that now the iMaxWarRand affects both the war check for MaxWars and LimitedWars. Since the number of leaders with iLimitedWarRand < 100 (20 leaders) is way bigger than the number of leaders with iMaxWarRand < 100 (6 = only Alex, Boudica, GKhan, Monty, Ragnar, Shaka) this bug decreases the likelihood of limited wars started by financially troubled civs.

2. Yup, these are two completely separate diplo events --> one is a request the other is a trade offer. There are explicit isHuman()-checks in the code of CvPlayerAI::AI_doDiplo(), so that only the human player receives the requests to join a war, and only other AI-players are allowed to receive the trade offers (if you check the AI-AI diplo modifiers in the glance screen you will never encounter "You refused to help us during war-time!"). Most leaders have a 5% chance per turn to bug us human players with this join-our-war-request, while 5 leaders (Cathy, Liz, KKhan, Sal, Sury) are even more annoying (10%). The Contact Delays are equal for all leaders (20 turns), but Cathy, KKhan, Sury, and Toku will give you a -2 for a denial instead of the -1 of all other leaders (except Gandhi). BTW no AI will ever bother you with this request if you declared war on them or hired a war alliance against them at one time in the game --> it may actually be better for the relations to bribe someone like Monty into a war against these PITAs (Cathy, KKhan, Sury) than to accumulate several -2 for join-war-denials... :hmm:
 
Thanks for the explanations :)

The reason why I'm digging into this stuff is that I try to make the AI in the Planetfall mod a bit more warlike. I have edited the leaderhead.xml to achieve this (increased war rands and war power ratios, modified the attitude tresholds which can prevent wars; also reduced hindering defensive pacts), but there still seems to be something wrong - nearly all AIs seem to prepare for wars, but hardly anyone of them declares. Is it possible that AIs can stay at "WHEOOHN" for 100 turns or more without declaring war? Is there any special problem which can cause this behaviour? Or is there a value to set how long preperation should take?

I have understand the informations in this thread the way that e.g. both financial problems (if they lead to a no-war decision at all) and the Saladin problem with too few offensive-programmed units lead to either no WHEOOHN-phase at all or to its cancellation.

In the test game I'm refering to most AI seem to be indeed in financial troubles (silder between 50-90% Gold), so it could be that those wars in preperation are ones for acquiring money (because I modfied the war rands for this game for all AIs in the way that they can do both Total and Limited wars for raiding, means values <100). Gifting more units via worldbuilder or continuing the game with even higher PowerRatios didn't help.


2. Yup, these are two completely separate diplo events --> one is a request the other is a trade offer. There are explicit isHuman()-checks in the code of CvPlayerAI::AI_doDiplo(), so that only the human player receives the requests to join a war, and only other AI-players are allowed to receive the trade offers (if you check the AI-AI diplo modifiers in the glance screen you will never encounter "You refused to help us during war-time!").

Regarding the bribe-into-war-mechanism between AIs, would it be complicated to enable that for the human player as well? Which checks would have to be removed or altered? (I'm asking because the AIs offering you "a compensation for war expenses" was another cool feature of SMAC)


Edit: In case it helps to identify the problem, if have attached the spreadsheat with the values of the leaderhead.xml (the leaders relevant for the mod are the 7 at the bottom) I used. I also checked, if there were eventually weights for AI unit strategies left over from BTS, but none of the leaders has them.
 

Attachments

  • CivLeaderPlanetfall-v4a.zip
    15.2 KB · Views: 126
Aahh interesting. I've just downloaded the mod and took a quick look -- nice to see the old friends&foes again. But the problem is, I have no idea what changes have been made to the mod's code/dll, so I can only tell you about mechanics in BTS 3.17.

Gold slider @50-90% sounds very suspicious - is this normal? Is there generally less commerce available in Planetfall (tile yields, improvements, trade routes, buildings, ...) compared to the expenses? I noticed you significantly increased the leaders' MaxGoldTrade values. I couldn't find any connection between these values and the preferred slider positions in BTS, but it might be different in Planetfall. :dunno: What are the AIs doing with all that gold? I guess it would be best to post a save of your current test-game, together with your used leaderheads.xml -- I really want to take a look at this (I found debug mode works fine :D).

BTS-AIs in financial trouble will disband excess units (only xp level 1) until they are in the green again, but only if they are currently not in WHEOOHRN mode. But since you say that almost all AIs have entered WHEOOHRN mode but stay eternally in it without actually DoWing a target, this should not be the problem.

So maybe it is a pathfinding problem. E.g. the default BTS-AI is not able to figure out that it has to use boats to get the land units to a target in the case that the target is located on the same landmass, but the path is blocked by impassable terrain (only mountain peaks and inland lakes in BTS). During my quick test of Planetfall I popped a Chopper from a Unity Pod and was a bit irritated about its available movement options until I read "Unit may not reveal undiscovered terrain except inside a player's territory" (btw. how can I have fog=undiscovered terrain within my cultural borders?). Furthermore I noticed Armors can't enter Fungus and that there is no direct way from a flat land tile up to a ridge tile. While these are probably pretty cool features I can imagine that they are rather "challenging" for a pathfinding algorithm. I'm not 100% sure, but I guess the individual attack units are grouped together and the AI searches a path for the whole selection group to reach the target. And if it can't find one because some of the units are restricted in their movement options in such ways, the whole group of units just keeps sitting in the city... This could be readily tested by some quick WB-terraforming.

~~~~~~~~~~

re. the bribery hack:
IIRC I had only changed a few lines of code at the very end of CvPlayerAI::AI_doDiplo() to achieve the bribing of the human player described in this post. I removed the isHuman()-check and copied the code block from the trade-maps offer to establish the diplo contact. But of course I didn't run any sophisticated tests whether or not this change introduces any game-breaking "side effects" plus I guess there are some good reasons the developers decided to not allow this bribery for the human player... But feel free to hack this restriction -- I'd be interested in your findings :D.
 
Gold slider @50-90% sounds very suspicious - is this normal? Is there generally less commerce available in Planetfall (tile yields, improvements, trade routes, buildings, ...) compared to the expenses?

My average slider setting is probably a bit more leaned towards gold then in BTS, but that might be also because I play Planetfall at Emperor, while Prince to Monarch is my setting in BTS.
Income sources...biggest difference to BTS is probably the absence of cottages. Their early (non-leveling) replacement are windmills which yield 1-4 commerce extra (terrain dependant), much later you get solar collectors, which can easily double those yields. The booster buildings are weaker in their effect (just 25% increase), merchant slots are more sparse especially in the beginning. Less trade route and ressources giving money. Last source of income is a speacial "wealth" process which converts one hammer into two cerdits, but it can be only used to cover city and unit maintenance (AI should be able to use it as well).
Regarding expensis, unit support climbs for later units, also for each special ability a unit has, but inflation has been removed in exchnage for that. Also there is no civic maintenance and also no colonial expenses for oversea bases.


I noticed you significantly increased the leaders' MaxGoldTrade values. I couldn't find any connection between these values and the preferred slider positions in BTS, but it might be different in Planetfall. :dunno: What are the AIs doing with all that gold?

I always found the BTS values much too low and restrictive for trading. It is often impossible to do fair tech trades, because the AIs have no money for exchange. OTOH, if you trade them a lot of gold it vanishes in a kind of black hole after that. Another reason is that the attitude requirements for tech trading have been greatly increased (at least "pleased" is required), so the additional cash should allow the AI tech purchasesn among each other. I did such trades in my testgame, but in both directions (so it was not me plundering out the AI)


I guess it would be best to post a save of your current test-game, together with your used leaderheads.xml -- I really want to take a look at this (I found debug mode works fine :D)

I have done so - the attachment contains saves of the years 2172, 2202, 2231 und 2271. Not all AIs were planning a war in 2172, but in 2202 that stated was already reached and continued until 2271 (were I stopped playing) and also the used leaderhead.xml (rename by removing "-v4e" before using!) There was one exception in the overall war planning stasis - Miriam declared on me in 2204 (the war lasted until 2232, when I initiated peace).


So maybe it is a pathfinding problem. E.g. the default BTS-AI is not able to figure out that it has to use boats to get the land units to a target in the case that the target is located on the same landmass, but the path is blocked by impassable terrain (only mountain peaks and inland lakes in BTS). During my quick test of Planetfall I popped a Chopper from a Unity Pod and was a bit irritated about its available movement options until I read "Unit may not reveal undiscovered terrain except inside a player's territory" (btw. how can I have fog=undiscovered terrain within my cultural borders?). Furthermore I noticed Armors can't enter Fungus and that there is no direct way from a flat land tile up to a ridge tile. While these are probably pretty cool features I can imagine that they are rather "challenging" for a pathfinding algorithm. I'm not 100% sure, but I guess the individual attack units are grouped together and the AI searches a path for the whole selection group to reach the target. And if it can't find one because some of the units are restricted in their movement options in such ways, the whole group of units just keeps sitting in the city... This could be readily tested by some quick WB-terraforming.

Regarding the chopper, I think it is meant that way that you can reveal undiscovered terrain outside your borders, as long as you stay with the chopper inside (will probably make not always a difference, but maybe on mounrains or at the coast)

The common means to get over the altitude difference flat land - rigde are either using dropships (a kind of transport plane) or the automatic movement-over-water for land units.
Also units with the Flying promotion (e.g.Hovertank). I have seen AIs with dropships (though I'm not sure how effective they can use them, also they come later in the tech tree), but they are definetly able to use the water movement for land units (the automatic pathfinder treats the water like land in this regard). Centauri Hydrology enables traveling that way over your own territory, Pressure Dome adds +1 movement and units with the Amphibious promotion can travel 6 tiles.


re. the bribery hack:
IIRC I had only changed a few lines of code at the very end of CvPlayerAI::AI_doDiplo() to achieve the bribing of the human player described in this post. I removed the isHuman()-check and copied the code block from the trade-maps offer to establish the diplo contact. But of course I didn't run any sophisticated tests whether or not this change introduces any game-breaking "side effects" plus I guess there are some good reasons the developers decided to not allow this bribery for the human player... But feel free to hack this restriction -- I'd be interested in your findings :D.

Thanks a lot :)
 

Attachments

  • permanentWHEOOHN.zip
    890.5 KB · Views: 139
I think one of the reasons the game hides the gold values of the AI to some extent is that you can trade tech for gold at any disposition. If every AI showed their gold you could essentially sell them techs gradually and run deficit research the majority of the game. That's pretty broken...you start winning lib before 800 AD w/o bulbing at all and so forth.
 
The other interesting factors are how Vassals and the financial situation affect the probabilities for wars. I don't really know what to think of the HUSP-factor (HighUnitSpendingPercentage). For boxed in unit spammers this should be huge (compact empire = low total expenses). E.g. checking the 990AD save of Sisiutil's ALC24 shows Mehmed with USP = 12/57 = 24% (HUSP = (USP-7)/3 = 5) and 2-city-Pacal with 2/4 = 50% (HUSP = 14) (note: foreign trade is not taken into account!). So they should consider a total war 6 / 15 times as often, but Pacal's power is probably much to low to actually find a valid victim.
It's also interesting how the raiders don't care about the attitude that much (NWR+10), so Boudica will declare at pleased if she is in financial trouble! (Edit: no she won't due to the capping at 99 and her NoWarProb=100)


Does the percentage of unit maintenance costs of the total maintenance costs play a role in war declarations?? Because Planetfall doesn't have civic maintenance. Meaning the percentage of unit maintenance of the total maintenance would usually be much higher in Planetfall than in unmodded Civ4.


I'll remove the chopper movement restrictions in the next version. :mischief: They're not really needed anymore.
 
If I understand previous posts in this thread correctly though, a high percentage of your costs being unit maintenance should INCREASE the frequency of total war plans. And the issue of Planetfall is too few war declarations.

I have also read in this thread that there is different logic for deciding when to plan to war than for actually starting a war. Is it possible that the conditions to actually start a planned total war are different/higher than the conditions to start a planned limited war, meaning that if we got the AI to plan less total wars, there would in fact be more wars in general (of the limited and dogpile kind) in the game?
 
- A planned war generally leads to war with exceptions
- A total war is more likely than a limited war since lots of gold spent on units increases the likelyhood of total but not of limited war.
-Less total war just means less war if i understand the code correctly.

For your mod it might be important to understand that it's not high unit cost alone, the deciding factor is total gold spent on units per turn / total gold spent for the entire empire. DanF inferred and i tend to agree with him that Gilgamesh is so dangerous early game (without modifiers he's not more aggressive than Charlemagne) because ziggurath brings down total gold for empire. Also Gilg has an early UU and this also increases the chance for a war.
 
Strangely enough I always get along with Ragnar.

same. Once i walk the line with him once, like say, He requests a tech, I'll give it to him. If it's war tech, I'll trade something else to him. Once he's please, he seems to stay there after that. Guess that makes two of us?

Friendly on the other hand? I can't seem to get him there.
 
@Pfeffersack:

I checked your attached saves (thanks, they are very interesting) and found that in the MY2202-save EVERYBODY is either preparing for a total war (WARPLAN_PREPARING_TOTAL) or has already finished preparing for one (WARPLAN_TOTAL) AGAINST YOU. So you have done a great job to make the AIs like wars better by tweaking the leaders-xml --> the real problems are probably in the dll.

1. The AIs generally seem to lack the necessary offensive units to actually start their wars. They spam a lot of defensive units though (maybe because native live in PF is more abundant and threatening compared to the regular barbs in BTS).

IIUC in order to actually start a total war, an AI needs a "Stack of Doom" = a group of units lead by a unit with UnitAI ATTACK_CITY. In the MY2202-save only Miriam and Deirdre have such a stack. While Miriam's is big enough for a DoW (happening in 2204AD), Deirdre's is too small consisting of only 3 units.

In the early game the minimum number of units in a SoD is 4 -- only then a stack is "ready to attack" so that the head unit can run the AI_targetCity-mission and the selection group starts moving towards the enemy, triggering the DoW when it crosses the borders. With a lower unit count the group will run the AI_moveToStagingCity-mission = move to the most threatened city and wait there.

I gave Deirdre a Walker (UnitAI ATTACK) via WB and put it into her capital Gaia's Landing where her mini-SoD is located (2 Flame Throwers lead by a Rover). The Walker joins this group thus putting it above the magic 4-units-threshold and the SoD starts moving onto the NW tile heading for your capital. Unfortunately it never arrives there (see 2.).


2. I noticed that Planetfall's special movement rules do indeed get the AIs into trouble, especially the movement of land units over water. On the next turn Deirdre's SoD enters the lake south of Gaia's High Garden, since the pathfinder dictates to go the fastest route (2-moves for land units over water). But the units leaving the landmass results in them going from one area (the continent, for which Deirdre has calculated the AreaAI AREAAI_OFFENSIVE) to a different area (the lake, with AREAAI_NEUTRAL = the default AreaAIType for water areas).

As the AreaAI is crucial for the units' decisions and a new decision is made after the usage of each single movement point, the SoD on the lake tile forgets about all the planned warring and heads straight back to Gaia's Landing. The monster-SoD is caught in a loop, repeating these two movements each turn. :run:

After world buildering in a Mag-Tube the SoD starting from Gaia's Landing chooses the faster route over land (never leaving the area) so that Deirdre DoWs after two turns.



One special problem here is that Deirdre's stack is a mix of 1:move: and 2:move: units. The 2:move: Rover spends 1 of his 2 movement points when entering the lake which triggers a new decision for the whole selection group. If for example you give Santiago a SoD of 4 ATTACK_CITY Walkers (1:move:) in Sparta Command she will move this stack 2 tiles to the SE (x=59;y=36) on a path leading E - SE - S with the first 2 steps over water (she has the tech Pressure Dome for +1:move: over water; movement starts in MY2206 after she has finished her preparations and switches to WARPLAN_TOTAL). But since this movement is just one swift step of the whole 1:move:-group, she doesn't think about her plans while having her SoD on the water and will then continue her assault on University Base.

These things are pretty tricky ... but also funny to find out :D.
 
Thanks for your investigations DanF5771! Very interesting!

Now just figure out a solution for these problems. I'm kinda clueless. :(
 
Top Bottom