Page 1 of 6 123456 LastLast
Results 1 to 20 of 108

Thread: AI / Diplomacy modding

  1. #1
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default AI / Diplomacy modding

    Use this thread to discuss your questions on AI and diplomacy modding.
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  2. #2

    Default Re: AI / Diplomacy modding

    Here's a couple of triggers that could help maintain diplomatic relations when neutral and allied (as opposed, or in addition to, the global ones already in the faction_standing file):

    Code:
    ;------------------------------------------
    Trigger 0082_F_Update_Attitude
        WhenToTest UpdateAttitude
    
        Condition FactionStanding = Neutral
     
        FactionStanding target_faction normalise 0.0 200
    
    ;------------------------------------------
    Trigger 0082a_F_Update_Attitude
        WhenToTest UpdateAttitude
    
        Condition FactionStanding = Allied
     
        FactionStanding target_faction normalise 1.0 200
    These are based on the originally commented-out trigger 0082. I suppose one could be added for war too, but that's possibly unnecessary since war tends to result in relations heading towards abysmal anyway.

  3. #3
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by DrJambo View Post
    Here's a couple of triggers that could help maintain diplomatic relations when neutral and allied (as opposed, or in addition to, the global ones already in the faction_standing file):

    Code:
    ;------------------------------------------
    Trigger 0082_F_Update_Attitude
        WhenToTest UpdateAttitude
    
        Condition FactionStanding = Neutral
     
        FactionStanding target_faction normalise 0.0 200
    
    ;------------------------------------------
    Trigger 0082a_F_Update_Attitude
        WhenToTest UpdateAttitude
    
        Condition FactionStanding = Allied
     
        FactionStanding target_faction normalise 1.0 200
    These are based on the originally commented-out trigger 0082. I suppose one could be added for war too, but that's possibly unnecessary since war tends to result in relations heading towards abysmal anyway.
    I use these already, and they work satisfying. That one for war was deleted in version 0.8. Maybe you should play a test campaign and see how things develop before making suggestions.
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  4. #4

    Default Re: AI / Diplomacy modding

    As far as I can see you use ones based on the vanilla "global" ones, which just assess whether you're at war or allied in general and modify your relations accordingly with all factions...

    The ones I suggested were more targeted, i.e. towards the factions you're specifically neutral or allied to. You don't have these in your UltimateAI.

  5. #5
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by DrJambo View Post
    As far as I can see you use ones based on the vanilla "global" ones, which just assess whether you're at war or allied in general and modify your relations accordingly with all factions...

    The ones I suggested were more targeted, i.e. towards the factions you're specifically neutral or allied to. You don't have these in your UltimateAI.
    I know, but I don't see the need to increase faction_standing for free when neutral or allied, as this makes the game far too easy for the human player.

    Edit: Do you see a need for relations increasing over time for free?
    Last edited by GrandViZ; January 06, 2007 at 05:17 AM.
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  6. #6

    Default Re: AI / Diplomacy modding

    It always appeared to me that relations seemed to deteriorate over time in M2TW regardless of many actions. It could be different in your mod however and if doing nothing to instigate aggression doesn't deteriorate relations then yes, there's probably no need. I guess the reason was to simulate that alliances get better over time.

    I find the global ones that were in vanilla rather strange since just being allied improves global reputation regardless of faction involved. If a faction dislikes you, relations would improve with this faction even if you're allied with one of his enemies!

  7. #7
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by DrJambo View Post
    It always appeared to me that relations seemed to deteriorate over time in M2TW regardless of many actions. It could be different in your mod however and if doing nothing to instigate aggression doesn't deteriorate relations then yes, there's probably no need. I guess the reason was to simulate that alliances get better over time.

    I find the global ones that were in vanilla rather strange since just being allied improves global reputation regardless of faction involved. If a faction dislikes you, relations would improve with this faction even if you're allied with one of his enemies!
    Well, in my mod I took out the modifiers - these were linked to difficulty level - artificially making your standing get negative over time. Now only your diplomatic actions count. Therefore I don't see a reason to artificially raise relations, except for those concerned with the religious affairs.

    Global reputation connected to alliances has a meening IMO, as being isolated should hurt your reputation a little. The effect is very small anyway.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  8. #8

    Default Re: AI / Diplomacy modding

    I think the game would play better with some more triggers somewhat like the ones DrJambo suggests. Why?

    First of all, a line such as

    FactionStanding target_faction normalise 1.0 60

    (to cite an extreme example) would improve the faction in question's relation with whichever faction was being tested (which depends on the conditions elsewhere in the trigger). However, a line such as

    FactionStanding target_faction normalise 0.0 60

    will slowly reduce good relations and slowly improve bad ones, effectively causing the AI in question to gradually forget history. While I don't see a need for relations to improve over time per se, I do think that AI's gradually forgetting both injuries and benefits is reasonable.

    Finally, a line such as

    FactionStanding global normalise 0.0 150

    (your trigger 0096) will not, I think, change the faction's relation with any faction. Instead, it will gradually restore the faction's "trustworthiness" to neutral. I haven't tested it, and the documentation isn't crystal clear, but it's an interpretation that makes a lot of sense. (For instance, all but one of the "dishonest transactions" influence the faction's global standing.) To gradually return a factions' relationship with all factions to neutral I would use a line like

    FactionStanding exclude_factions { } normalise 0.0 150


    Given the above, let's look at the code that's there. In general, relationships start off at 0.0 unless otherwise specified (I think? another assumption to test *sigh*). There is a lot of code causing relationships with other factions *of the same religion*, and with very small factions, to normalize towards 0.3. There is no code in UAI causing relationships between nonsmall factions of different religions to normalize towards anything. In Vanilla the code associated with difficulty settings may have done this for the AI's as well as the player, but that's gone, and good riddance.

    As a result of this lack of forgetfulness, I suspect that once two AI's of different religions have gone to war they'll be at each others' throats for the rest of the game, since I highly doubt the AI will do anything nice to another AI that it's at -1.0 relationship with. It's not so much an issue for human players, since they can just throw money at the faction in question.

    I think, under the circumstances, it would be reasonable to put in code normalizing relationships between Catholic and Orthodox factions towards 0.0, corresponding to trigger 0085 which normalizes relationships between factions of the same religion to 0.3. Possibly it would also be good to normalize relationships between Christian and Muslim countries to something like -0.2? I'm not sure.

    Another implication of factions of the same religion normalizing towards 0.3 is that you will tend towards a very peaceful Catholic Europe, consistent with many reports of various players at "medium" and "hard" difficulty settings in the other thread. Vanilla takes care of this with its "tall poppy" code. (For casual readers of this thread, the "tall poppy" code is what causes factions to dislike large factions.) That code has been removed here, and you've thought about its implications at very hard far more than I have, but I suspect that it's needed for games on Medium or Hard settings to work well. Without it, there are no checks or balances for something like an AI HRE, and very few reasons for the other AI's to fight it, ever. Which could be good if a player's looking for the toughest game possible, but not at "Hard".

    "Tall poppy" and/or the generic difficulty adjustments may also be needed for factions to dislike the Mongols and Timurids at easier settings than "very hard": I'm not sure.

  9. #9
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by Isbolg View Post
    I think the game would play better with some more triggers somewhat like the ones DrJambo suggests. Why?

    First of all, a line such as

    FactionStanding target_faction normalise 1.0 60

    (to cite an extreme example) would improve the faction in question's relation with whichever faction was being tested (which depends on the conditions elsewhere in the trigger). However, a line such as

    FactionStanding target_faction normalise 0.0 60

    will slowly reduce good relations and slowly improve bad ones, effectively causing the AI in question to gradually forget history. While I don't see a need for relations to improve over time per se, I do think that AI's gradually forgetting both injuries and benefits is reasonable.

    Finally, a line such as

    FactionStanding global normalise 0.0 150

    (your trigger 0096) will not, I think, change the faction's relation with any faction. Instead, it will gradually restore the faction's "trustworthiness" to neutral. I haven't tested it, and the documentation isn't crystal clear, but it's an interpretation that makes a lot of sense. (For instance, all but one of the "dishonest transactions" influence the faction's global standing.) To gradually return a factions' relationship with all factions to neutral I would use a line like

    FactionStanding exclude_factions { } normalise 0.0 150


    Given the above, let's look at the code that's there. In general, relationships start off at 0.0 unless otherwise specified (I think? another assumption to test *sigh*). There is a lot of code causing relationships with other factions *of the same religion*, and with very small factions, to normalize towards 0.3. There is no code in UAI causing relationships between nonsmall factions of different religions to normalize towards anything. In Vanilla the code associated with difficulty settings may have done this for the AI's as well as the player, but that's gone, and good riddance.

    As a result of this lack of forgetfulness, I suspect that once two AI's of different religions have gone to war they'll be at each others' throats for the rest of the game, since I highly doubt the AI will do anything nice to another AI that it's at -1.0 relationship with. It's not so much an issue for human players, since they can just throw money at the faction in question.

    I think, under the circumstances, it would be reasonable to put in code normalizing relationships between Catholic and Orthodox factions towards 0.0, corresponding to trigger 0085 which normalizes relationships between factions of the same religion to 0.3. Possibly it would also be good to normalize relationships between Christian and Muslim countries to something like -0.2? I'm not sure.

    Another implication of factions of the same religion normalizing towards 0.3 is that you will tend towards a very peaceful Catholic Europe, consistent with many reports of various players at "medium" and "hard" difficulty settings in the other thread. Vanilla takes care of this with its "tall poppy" code. (For casual readers of this thread, the "tall poppy" code is what causes factions to dislike large factions.) That code has been removed here, and you've thought about its implications at very hard far more than I have, but I suspect that it's needed for games on Medium or Hard settings to work well. Without it, there are no checks or balances for something like an AI HRE, and very few reasons for the other AI's to fight it, ever. Which could be good if a player's looking for the toughest game possible, but not at "Hard".

    "Tall poppy" and/or the generic difficulty adjustments may also be needed for factions to dislike the Mongols and Timurids at easier settings than "very hard": I'm not sure.
    I've already integrated above mentioned triggers into version 1.0.

    ;------------------------------------------
    Trigger 0104_Increase_Faction_Standing_When_Allied
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = Allied

    FactionStanding target_faction normalise 1.0 80
    FactionStanding target_enemies normalise -1.0 160

    ;------------------------------------------
    Trigger 0105_Decrease_Faction_Standing_When_War
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = AtWar
    and not TargetFactionType slave

    FactionStanding target_faction normalise -1.0 80
    FactionStanding target_allies normalise -1.0 160
    FactionStanding target_enemies normalise 1.0 160

    ;------------------------------------------
    Trigger 0106_Faction_Standing_When_Neutral
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = Neutral

    FactionStanding target_faction normalise 0.0 80

    I'm currently testing. However it is far from being total peace - in turn 50 there is total global war with nearly all alliances perished. The other extreme.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  10. #10

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by GrandViZ View Post
    I've already integrated above mentioned triggers into version 1.0.

    ;------------------------------------------
    Trigger 0104_Increase_Faction_Standing_When_Allied
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = Allied

    FactionStanding target_faction normalise 1.0 100
    FactionStanding target_enemies normalise -0.5 200

    ;------------------------------------------
    Trigger 0105_Decrease_Faction_Standing_When_War
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = AtWar
    and not TargetFactionType slave

    FactionStanding target_faction normalise -1.0 80
    FactionStanding target_allies normalise -0.5 200
    FactionStanding target_enemies normalise 0.5 200

    ;------------------------------------------
    Trigger 0106_Faction_Standing_When_Neutral
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = Neutral

    FactionStanding target_faction normalise 0.0 100

    I'm currently testing. However it is far from being total peace - in turn 50 there is total global war with nearly all alliances perished. The other extreme.

    Regards
    GrandViZ

    Nice triggers! I made a few suggestions in bold. There's maybe no need for a target_faction modifier with the faction you're at war with, since the natural actions of being at war, such as blockading ports, battles, sieges, etc, will lower relations anyway. All my wars end up with me and the faction at abysmal. In terms of a divisor 80's quite small, so I upped that a little to lessen the impact.
    Last edited by DrJambo; January 09, 2007 at 07:21 AM.

  11. #11
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by DrJambo View Post
    Nice triggers! I made a few suggestions in bold. There's maybe no need for a target_faction modifier with the faction you're at war with, since the natural actions of being at war, such as blockading ports, battles, sieges, etc, will lower relations anyway. All my wars end up with me and the faction at abysmal. In terms of a divisor 80's quite small, so I upped that a little to lessen the impact.
    Hi DrJambo,

    you're right about the atWar modifier (it is a matter of turns to be at abysmal anyway). However I'm not sure about changing the values.

    Trigger 0106 will reduce the effect of the modifiers for target_allies and target_enemies. For example if you are at war with faction A and neutral with its ally B. Then trigger 0105 and 0106 will apply! Therefore I think the values are ok, and I'm testing them atm with good results.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  12. #12

    Default Re: AI / Diplomacy modding

    ;------------------------------------------
    Trigger 0104_Increase_Faction_Standing_When_Allied
    WhenToTest UpdateAttitude

    Condition DiplomaticStanceFactions = Allied

    FactionStanding target_faction normalise 1.0 80
    FactionStanding target_enemies normalise -1.0 160
    FactionStanding target_allies normalise 1.0 160

    Presumably you could have another line introduced here (in bold)?

  13. #13
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by DrJambo View Post
    Presumably you could have another line introduced here (in bold)?
    A friend of a friend is a friend? This is bad as it would include possible natural enemies and excommunicated factions as well, and from the test games I made, I didn't feel, it was necessary, but perhaps we should check, how the current settings behave in the long run (> 150 turns) first, before integrating new triggers.

    However, from the conceptual perspective you are right.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  14. #14
    kleemann's Avatar Libertus
    Join Date
    Jan 2006
    Location
    In EU (Estonia)
    Posts
    74

    Default Re: AI / Diplomacy modding

    If file descr_diplomacy.xml

    - <item name="offer_ceasefire">
    <cost modifier="-0.1" />
    <faction_standing modifier="0.75" />
    <global_standing modifier="0.75" />
    </item>

    What these values mean? How they affect the AI? Or how this value is calculated?
    Trading tip: Load your mercants on your (crapy, cheap upkeep) unit and place that crapy unit on the valuable trade ressource. All will earn money on that single ressourec AND other merchants can't do anything! ha:ha

    BUT it has bad side efect, if the unit rebel you will lose your merchants :hmmm:

    How-to: edit battle_model.modeldb to add new animations and skins.

  15. #15
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by kleemann View Post
    If file descr_diplomacy.xml

    - <item name="offer_ceasefire">
    <cost modifier="-0.1" />
    <faction_standing modifier="0.75" />
    <global_standing modifier="0.75" />
    </item>

    What these values mean? How they affect the AI? Or how this value is calculated?
    It refers to the diplomatic ceasefire offer made by the human player to an AI player. Note that offer_ceasefire is treated as a demand by the M2TW engine!

    In general it works like this:

    The higher the cost for an offer the higher the value for the AI.

    Test cost modifiers for offer_alliance of 3.0, 1.5, 1.0, 0.5, 0.0, -0.5, etc. and ask for money payment in exchange. You'll see the higher the cost the more money you'll get from the AI. At the same time the offer will be regarded as very generous, generous, neutral, demanding, very demanding.

    For demands the cost modifier works inversely. Test this with demand_map_information.

    The higher the cost the more money you have to pay in exchange and the less willing is the AI to agree. And you will see that in both cases higher and lower values as 1.0 or -1.0 work. With 3.0 you will have to pay more for the map information than with 2.0 etc.

    You should also note, that some entries like offer_ceasefire are treated as demands although their name tells you it should be an offer. Therefore decreasing the cost modifier for offer_ceasefire will make it more easy to achieve it.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  16. #16
    kleemann's Avatar Libertus
    Join Date
    Jan 2006
    Location
    In EU (Estonia)
    Posts
    74

    Default Re: AI / Diplomacy modding

    Thank you for your explanation. But what about

    <faction_standing modifier="0.75" />
    <global_standing modifier="0.75" />

    As i understand, these are some kind of extra constants what increase or lower the cost of casefire. For example, if you are very untrustworthy then you will have to pay more? Am i right?
    Trading tip: Load your mercants on your (crapy, cheap upkeep) unit and place that crapy unit on the valuable trade ressource. All will earn money on that single ressourec AND other merchants can't do anything! ha:ha

    BUT it has bad side efect, if the unit rebel you will lose your merchants :hmmm:

    How-to: edit battle_model.modeldb to add new animations and skins.

  17. #17
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by kleemann View Post
    Thank you for your explanation. But what about

    <faction_standing modifier="0.75" />
    <global_standing modifier="0.75" />

    As i understand, these are some kind of extra constants what increase or lower the cost of casefire. For example, if you are very untrustworthy then you will have to pay more? Am i right?
    That is right, however I had not the time to test these as much as I did it for the cost modifiers.

    Regards
    GrandViZ
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  18. #18
    kleemann's Avatar Libertus
    Join Date
    Jan 2006
    Location
    In EU (Estonia)
    Posts
    74

    Default Re: AI / Diplomacy modding

    I 'll test it out and report what i find..

    Testplan:
    declare war

    1. see, how much it will cost to get ceasefire..
    relations Absymal 0 enemy and 1 enemy

    2. mod relations to So-So in descr_strat.txt and put at_war in thare
    etc..

    3. mod relations to perfect in descr_strat.txt and put at_war in thare
    etc..
    Trading tip: Load your mercants on your (crapy, cheap upkeep) unit and place that crapy unit on the valuable trade ressource. All will earn money on that single ressourec AND other merchants can't do anything! ha:ha

    BUT it has bad side efect, if the unit rebel you will lose your merchants :hmmm:

    How-to: edit battle_model.modeldb to add new animations and skins.

  19. #19
    GrandViZ's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Berlin, Germany
    Posts
    2,026

    Default Re: AI / Diplomacy modding

    Quote Originally Posted by kleemann View Post
    I 'll test it out and report what i find..

    Testplan:
    declare war

    1. see, how much it will cost to get ceasefire..
    relations Absymal 0 enemy and 1 enemy

    2. mod relations to So-So in descr_strat.txt and put at_war in thare
    etc..

    3. mod relations to perfect in descr_strat.txt and put at_war in thare
    etc..
    Thanks, your help is appreciated.
    Creator of the Ultimate AI
    Co-Author of Broken Crescent

    Under the Patronage of Trajan

  20. #20

    Default Re: AI / Diplomacy modding

    thought i'd drop in to give my 0.02 cents worth.

    i've been playing a campaign as Spain on vh/vh. i'm on the year 1114. i believe thirty five, i think. well into it, though.

    i noticed right off the bat that, let's say, i was allied to france and they were at war with milan. i was neutral with milan. the war between them was kinda petty. as soon as i offered an alliance with milan and they accepted, the war between them and france was automatically over. a cease fire. this happened a few times.

    and i have been back stabbed by an ally a 'grand' total of zero times! not once. and i haven't really given them a reason to do so. i've had portugal (ally since the beginning) step on my land once or twice. never acted in a threatening manner.

    oh, and i made the moors my, well you know. i demanded that the 'infidels' be my vassal. they didn't like it but they took it. they own only arguin.

    regarding medieval: total war, when you were allied with two countries at war with each other, you had to choose which one you wished to stay allied with. why doesn't medieval 2 total war have this?

    this may be the wrong place, sorry if it is.

Page 1 of 6 123456 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •