As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
AI diplomacy behavior

I was digging deeper into diplomacy and I thought I would share my findings.

1. Declaration of War.
-If a diplomatic penalty from Spell of Mastery is applied, there is a 10% chance of DoW.
-If you attack their city overland and win, DoW is automatic.
-If the wizard has a Chaotic personality there is a random chance of Difficulty Level/300 for DoW.
-When a "Declare War on" proposal is successful
-When threatening fails too badly
-When relationship falls below -75 and the AI still remembers a negative diplomatic action of any size.
-When the AI remembers a negative action, Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100, the AI will break treaty or if no such is present and the check is failed at least twice, then War is declared only if Remembered action strength+Personality Modifier<random(100)
-At end of turn if 2 AI wizards are allied and one is at war with a 3rd Ai wizard but the other is not then the other will also declare war on that wizard, this one is for AI wizards only.

2. Breaking of Treaty or Declaration of War if no Treaty is present.
Called once every end of turn, but only after turn 100 or if both wizards involved are AI, a BTODW is made if
-The wizard is militarist or expansionist, not lawful, at an 5% chance if a check for Military situation+relation+hidden relation+personality modifier falls below -150. Military situation checks the cost of units on the wizard's fortress continent so it's pretty unrelated to any actual military power they would have over each other in an actual war.
-The exact same as above repeated for any wizard.
-If the number of wizards at war with the player is fewer than the difficulty level and relationship is worse than -30 then there is an abs(relationship/10) to 15 chance.
-Finally, if wizard A is allied with wizard B, but wizard B is at war with the player, then wizard A will BTODW on any wizard at a 10% chance. This is looking quite buggy and the intended functionality is most likely that if wizard B is at war with any wizard, war is declared on that wizard. Note that wizard B cannot be the player, so your allies will never break their treaties and declare war on your enemies from this effect unless you ask them to yourself. (and it's buggy and declares wars on random people, anyway)

3. Threatening
Success is based on a value of Military modifier+Relation+Hidden Relation+Personality modifier+random(100)+random(100).
Military modifier is the same as before so if you want it to work you should load all your sky drakes on their land and not on the ocean square near their capital. Or something like that, I don't really know if you need more, or fewer troops for success but I would assume more.

4. Proposing a treaty of any sort
x=Relationship+ hidden relationship+personality modifier+Military Modifier+random(100)+ 40 if allied - Treaty type success difficulty +Treaty Type wizard relation.
if x>0 then successful, if below -75 failure, in between the AI will ask for something in exchange.

5. Diplomatic Relation changing events
-Casting a global enchantment (varying amount of penalty)
-Keeping a global enchantment in play (10% of the above penalty per turn)
-Having larger military strength in astrologer than the AI : at most 5% chance to -10 per turn for the player only
-Having a Wizard's pact : 50% chance to +3 per turn
-Having an Alliance : 50% chance to +6 per turn
-When the number of owned towns exceed (Land size+1)*3 : when ((Land Size+1)*3-Towns)/(6+Land Size-Difficulty)*random(4)/3*4 is below zero then a negative event happens for half of that many points, at a 25% chance per turn for the player only. So Tiny land = 3, Small = 6, Medium = 9, Large = 12, Huge = 15, any more and there is a recurring penalty which is scaled up by difficulty.
-Trading a spell successfully if the given spell had a higher research than the received : +5
-5% chance when AI vs AI positive diplomatic action is attempted (like trading a spell), +5+random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, first warning : -random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, third warning : -5 and the wizard breaks treaty. This adds to the hidden relation modifier of that wizard and also to everyone else.
-if there is a unit near town, there is no pact or alliance, at a 5% chance : -random(5)
-Defeating a wizard : -40 to everyone else
-Banishing a wizard : -20 to everyone else
-Attacking despite a treaty : -40
-Attacking a town a winning : -40 (also comes with DoW)
-Attacking a town and losing : -20 but -60 if fortress. The latter causes overflow for lawful wizards which double it and the penalty turns positive.
-At end of combat, based on the other player's losses : -20 per hero, -random(20) per unit, additional -10 for engineers and settlers
-Casting Evil Presence, Famine, Chaos Rift on a town : -5
-Casting Pestilence : -8
-Casting Earthquake : -9
-Casting Call of the Void : -20
-Casting Corruption : -25
-Casting Raise Volcano : -50
-Starting to cast the Spell of Mastery : -50, and another -5 per turn, this also has a recurring chance of DoW directly.
-Casting Black Wind, Fire Storm, Ice Storm on their units : -3

6. Tired of diplomacy penalties
There are hidden modifiers by type of diplomacy. Whenever diplomacy actions are done, whether successful or not, all 3 types get a -10 penalty a set number of times. 10 is refilled per turn.
-1x whenever a Treaty is proposed. Additional loss of 20+random(30) points to "Treaty Modifier" only.
-1x whenever spell trading is attempted
-2x whenever successfully traded a spell
-4x! after every trading attempt, whether successful or not
-2x after a proposal of a Peace Treaty regardless of success
-10x after threatening a wizard
-2x after AI offering peace himself
-1x after unknown negotiating attempt
-3x if AI vs AI end of turn diplomacy was attempted

7. Offering Peace
The AI will sometimes offer peace on his own.
This happens if there is a war and all of the following criteria are met
-Relation+Hidden Relation+personality modifier+random(100)+"Tired of diplomacy 3rd type">=50
-A roll for 1/8 chance is successful
-30*Own Total Power/Player total power<=random(100)
-Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100

Yep, if the relation is too good, peace will not be offered as the entire diplomacy process is skipped. But if it isn't good enough, it also won't be. lol

If it happens, there is a 25% chance that a spell will be offered, if one is available.
Otherwise gold will be offered proportional to the player's number of towns controlled+ the number of the current turn, rounded down to the nearest 25 gold.
"Total power" most likely refers to the size of the bar on the F4 screen, the sum of astrologer "Army", "Power" and "Research".

8. Offering Treaties or any other possible diplomatic action
These have to pass the exact same check as peace treaty, being
Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100
but let's be honest about it, if the relations are negative, there is no way a good offer will make the further checks, and so they never happen.
If the bug wasn't there then the chance to run the procedure to offer a treaty was random(100)<3+Last positive action strength plus AND it also had to pass a roll for 25% success chance on top of that one.

Once inside the procedure, various treaties are considered.
To offer a Wizard Pact :
-Visible relations need to be 15 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=50

To offer an Alliance :
-Visible relations need to be 50 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=100

To ask for a War with another wizard :
-Asker has to be at war with the target.
-A roll for 10% chance has to be made
-If that wizard is really hated for some reason, a spell or gold will be offered

To offer a Spell Exchange :
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=25
-Valid spell targets need to be available.

If none of the others were selected, in that order of priority then
-If player's number of towns controlled exceeds own, a Wizard Pact is offered.

Finally, if an offer for a pact or alliance was chosen, based on the player's number of towns controlled and random chances, gold or a spell might be added to the offer.

All of this is information from the code, as these never happen in the unedited game due to a very similar relationship sum as the ones used here needs to be -100 or lower for any diplomatic action to be ever considered.
Reply

I don't think the CP has ever made an offer to me. Maybe a peace treaty. But definitely none of the other stuff. Attacking a city and losing should also be a DoW.
Reply

(October 23rd, 2015, 22:48)Tiltowait Wrote: I don't think the CP has ever made an offer to me. Maybe a peace treaty. But definitely none of the other stuff. Attacking a city and losing should also be a DoW.

They don't. That formula is for when the player offers the treaty, to calculate if it gets accepted, rejected, or accepted with additional demands.

Attacking a city (and losing) is a -40 diplomatic effect, -60 if it was the capital (this caused an overflow though so I changed it).
While there is no immediate war, a penalty this high will make a war much more likely to happen soon.
Reply

(October 24th, 2015, 02:27)Seravy Wrote:
(October 23rd, 2015, 22:48)Tiltowait Wrote: I don't think the CP has ever made an offer to me. Maybe a peace treaty. But definitely none of the other stuff. Attacking a city and losing should also be a DoW.

They don't.

That's one thing that has always frustrated me about MoM. In Master of Orion, the diplomacy game is pretty much the same. But in MoM, it's been crippled. In MoO the computer players will play the game. They're not the best at it, but at least they're doing something. They'll offer treaties or a technology once in a while. As an advanced player of MoM I don't see the advantages of wizard pact or alliance or asking to declare war on enemies or whatever. The only diplomatic stances that give benefits to me the player are war or offering peace. The CPs will make treaties amongst themselves though.

Other than that the only positive effect of the entire diplomacy system is trading spells. It just looks like they cut corners here or something.
Reply

(October 24th, 2015, 02:52)Tiltowait Wrote:
(October 24th, 2015, 02:27)Seravy Wrote:
(October 23rd, 2015, 22:48)Tiltowait Wrote: I don't think the CP has ever made an offer to me. Maybe a peace treaty. But definitely none of the other stuff. Attacking a city and losing should also be a DoW.

They don't.

That's one thing that has always frustrated me about MoM. In Master of Orion, the diplomacy game is pretty much the same. But in MoM, it's been crippled. In MoO the computer players will play the game. They're not the best at it, but at least they're doing something. They'll offer treaties or a technology once in a while. As an advanced player of MoM I don't see the advantages of wizard pact or alliance or asking to declare war on enemies or whatever. The only diplomatic stances that give benefits to me the player are war or offering peace. The CPs will make treaties amongst themselves though.

Other than that the only positive effect of the entire diplomacy system is trading spells. It just looks like they cut corners here or something.

Thanks to insecticide changes, a Pact or Alliance is actually a valuable thing now that prevents the AI from attacking you but...with all the default penalties it's kinda pointless as they'll break them and declare war eventually no matter what.
I'm modding almost all of these penalties to be more...reasonable. If the treaties are valuable, even offering tribute to get them accepted can be a good choice.

Seriously, who in their right mind would be hostile towards someone who is several times stronger, instead of trying to appear as innocent as possible until they research something that can win against them? Penalties based on the player being too strong are just stupid. By then, it's already too late, war should trigger when your strength is about to reach theirs, not when it's already far above.

Also, at the very least, it should be possible to maintain a pact or alliance with a Lawful or Peaceful wizard without them breaking it first.

Speaking of which, the way the AI tries to decide if you are stronger is also stupid. It either looks at the astrologer, which by default is only the sum of upkeep you are paying, or looks at the units standing on the continent he started on.

Satori's mind reading reveals the inner thoughts of the AI!

Jafar : Heeey, Kali is threatening me with war! Who does she think she is! Does he even have an army? Familiar?
Familiar : Well you own 112 units and he has none at all, sir!
Jafar : I see 9 Sky Drakes if I look out of the windows, aren't those under his control?
Familiar : No way sir, I got reports of no units whatsoever in our lands.
Jafar : Oh, you are right, those windows look towards the sea, that's not my land, who cares what's there! Her puny military strength is no match for my superior units. I'm angry now, I'll declare war on her for this insolence!

Sss'ra : Let's see now, I have here this army of 10 dark elf spearmen, at a cost of 30 each this is a really awesome army.
Familiar : Enemy is reported to have 10 units of Beastmen spearmen, sir!
Sss'ra : Beastmen spearmen? Hah, those lame things only cost 15 to produce each, weaklings! My army is twice as strong! Prepare the troops, we are going to war!
...
Sss'ra : Waaaait just a moment, why do these beastmen have so much health and attack power? No way, we are losing! That can't be, my spearmen were twice as expensive! The guy in the shop said these are really awesome troops that are unstoppable by other spearmen, that's why I paid this much for them. I want my money back, now!
Reply

You know what?

I just found something funny.
There is a procedure that is called at a random chance when there was a positive diplomatic action before, which the AI still remembers.
It looks very much like one that would offer treaties.

I don't remember the AI ever doing that, but the code...seems to be there, actually.
I wonder why it doesn't get used.

Edit : I've located the variable which is used to keep track of AI offers. Setting it to peace treaty made the AI offer the peace treaty as expected. However, setting it to Pact or Alliance had no effect. This seems to imply that the AI does try to perform the actions but they don't show up when they should for some reason. Might be that the text for these is not implemented, idk.

...still couldn't figure out the problem but the lbx contains text for a lot of AI actions
-granting a reward for attacking a common enemy
-Propose to declare a war on someone
-Warn that you are too powerful and he'll soon declare war
-Offer a wizard's pact
-Offer an alliance

I don't think if the coding and text for all of these are included that these really are all unfinished.
There should be a bug somewhere that prevents the actions from going through.

...heck the code is so advanced it even considers situations like "If player is allied with someone I'm at war with, ask to break that alliance before proposing the treaty".
And if the accept button is hit, it does set the treaty. Everything is there, why is it not working, arrrrgh
Reply

Aaaaaaaand it's there!!!!!!

I think I'm the first person to ever see this screen. What a historical moment!

The problem was this. The AI nagging for his problems and the offers and whatnot are in the same variable "AI diplomatic action to take" I guess would be the right name.

Problem is, whenever relations aren't heavily severe, this variable is cleared to 0. And, any form of offer is only considered if the relations fail that check, which is a problem because you can't get offered an alliance AND be hated at the same time.

Now, how am I gonna fix this without breaking the check because it's kinda needed for the negative actions...or is it? not sure. Gonna need to think about this for a while.


Attached Files Thumbnail(s)
   
Reply

Wow, yeah. I've never seen that before. Good job. If there is really a diplomatic game buried in there, and you can get it out, that would be a great accomplishment. I always felt that there was something wrong because if anything, the CP diplomacy should be more advanced than Master of Orion, rather than reduced.
Reply

(October 24th, 2015, 07:28)Tiltowait Wrote: Wow, yeah. I've never seen that before. Good job. If there is really a diplomatic game buried in there, and you can get it out, that would be a great accomplishment. I always felt that there was something wrong because if anything, the CP diplomacy should be more advanced than Master of Orion, rather than reduced.

Well, now that I edited the faulty check out, I'm gonna try playing the game and see if I get anything offered without forcing the triggers from tweaker. I'm wondering what kinds of stuff will happen, I've only really seen Alliance, Pact, Peace, spell exchange and asking for war, but...there is text for some other stuff too, so maybe they'll also be able to trigger now.

I reeeally wonder who was the wise guy who thought

If relation roll<-100 { Check_War_Delaration; Check_Alliance_Offer ; Check_Pact_Offer ; Check_Peace_Offer ; Check SpellExchange_Offer } else { Assigned_Action = Do_Nothing. }

was a good idea to code :D
It even prevents stuff already decided elsewhere to happen.
There are plenty of text with all sorts of warnings like "If you expand further I'll have to stop you" or "Your summoning of X threatens the stability of the world itself" in the LBX file, I really wonder if these will also start popping up.
Maybe they actually intended the game to tell us why everyone is suddenly declaring war on us, it just didn't show up...

Well, my changes are taking effect, but not the above one unfortunately. I reached turn 100, the barrier for the AI to start declaring wars on the player and...
The militarist wizard declared war because my army strength is too low and she thinks I'm easy prey. (mod change)
The peaceful wizard declared war because we have 18 points worth of opposing realm spellbooks total and his army is as weak as mine so he considers me a severe threat. The third one has 21 ranks of opposing books so I expect another war soon, fortunately she is a lot stronger and for now doesn't care yet. (also mod change)
Maybe I should offer tributes to avoid the third war, hmm, now that's something I never needed to consider before!

Edit : confirmed it works. I got an offer in an actual game. The timing was weird, though, it seems that what I thought is the total power of a wizard is actually the number of towns controlled. So if the number of towns is higher then the offer is made, not if the overall power is higher. I think I'll mod this to consider army power instead. A pact is directly harmful towards the AI if the player controls too many towns due to overextension but lacks the forces to protect it, this was very bad default logic.


Attached Files Thumbnail(s)
   
Reply

So, what do Alliance/Wizard Pact actually *do*?

There are five states your diplo status can be in: alliance, wizard pact, war, peace treaty, non-treaty. Is that right? After a peace treaty is signed the CP will not attack for a set number of turns but after that you're right back non-treaty territory.
Reply



Forum Jump: