Results 1 to 8 of 8

Thread: Balance Guidelines Project - XCAI - Diplomacy and Aggression

  1. #1
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Balance Guidelines Project - XCAI - Diplomacy and Aggression

    Here we have the first installment of Campaign AI balancing. This is a Work In Progress

    NOTE: Please do not start any modding until you understand this document in its entirety.

    INTRODUCTION:

    The goal here is to give you a thorough understanding of what it takes to get a campaign balanced on the AI side of things. Primarily we will focus on AI diplomacy with other AI's. Then your understanding of that will transfer to balancing it to the human then we will concentrate on other factors such as aggressiveness of the AI.

    I am not going to teach you how to write an AI, I am going to show you what lines to edit in XCAI files to achieve a balance in your mod.

    A big thank you goes out to CA! for their 1.5 update. Because of their inclusion for the game engine to recognize negative values within the campaign AI. That is how we were able to get the AI to be able have reliable diplomacy.

    The first thing you must understand, is that every mod out there is different, and initially things will most likely be "out of balance". The original game or mod was balanced, towards "vanilla" style campaign files. Whether the designer realized it or not.

    There is no such thing as Plug and play, with AI because there are too many other mod specific files that influence it.

    The benefit of integration of XAI into your mod out way the short term issues of balancing.

    Here are a list of benefits you will gain from XCAI integration.
    + Includes levels of difficulty.
    + All religions now have rules in the AI, and the Faction Standings
    + Penalties and bonuses for all religions, for a real medieval religious flavor
    + Makes proper use of Forts, and Stone Forts.
    + Real Naval invasions! like they should be, with full reinforcements.
    + XCAI has rules for all nations and religions, diplomatic, strategic, and tactical decisions.
    + Break-through fix, for handling of ships. Please see the faq (in this faq).
    + Improved the consequences for a players actions, especially trespassing.
    + Aggressive Defense of AI territories and besieging.
    + Improved multiple army attack and defense.
    + Many more epic battles!
    + Sure footed and devious expansion of factions.
    + AI picks invasion targets more careful.
    + Factions builds up! Much larger armies used for assaulting players, and defending territories.
    + Allies cooperation in attacks, for both AI and human.
    + Drastic reduction in steam rolling of opponents.
    + More realistic Diplomacy!

    I am going to show you over time, how to look for issues and troubleshoot and fix them. I will give you pointers and ideas as I go. I am not going to lie to you and say this will be easy. Together we may run into issues that will make us expand these guidelines.

    We are willing to help you complete this project, but we really need you to try and do the best possible job of following the instructions first. I am not the most talented writer around, and I am sure there will be some confusion caused. If you find a better way to do a process, then write it down and maybe we can improve this document. We are all in this mess together, and we all want the same thing. A game that we can play and enjoy. That is why we are still all here!

    We all have real lives in addition to our modding, and I hope you can appreciate that we as a team have to balance our priorities. This is why I am working so hard on this document, so if I am gone you can work your way through it on your own. Then ask us for help on the tougher issues.
    Last edited by xeryx; April 19, 2010 at 08:19 PM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  2. #2
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: XCAI; Campaign AI balancing guidelines

    Setting up you config file

    You must add these lines to your config file! These lines are to create trouble logs, so that you can look at a specific one for certain things. These logs will allow you to identify and troubleshoot aspects of the AI or other files.

    You may change the file names for your own benefit, these are examples of what I use.

    Spoiler Alert, click show to read: 
    Code:
    [io]
    file_first = true
    disable_file_cache = true
     
    [ai]
    ltgd_logging = true 
    
    [log]
    to=logs/KGCM.system.log.txt
    level = * trace
    file = ai.ltgd logs/XCAI.ai.log.txt
    ;file = game.script.* logs/pkh.script2.log.txt
    ;file = game.script* logs/pkh.script.log.txt
    ;file = game.script logs/pkh.scriptoutput.log.txt


    The Blue text is required to be set in this state. The green can be changed to suit your needs, for names.

    The ; in front of the other logs is used to "deactivate" them

    Your logs will be located in you default med 2 directory! you will see this directory \logs.

    The main one we will be using for now is the XAI.ai.log.txt

    The log is very long, but you MUST learn to read this log, if you are to understand what the AI is thinking. Please move on to section 2 in the next post.
    Last edited by xeryx; April 18, 2010 at 04:12 PM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  3. #3
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: XCAI; Campaign AI balancing guidelines

    BASIC Understanding the AI log file

    This is probably the most daunting task you will face. It is paramount that you gain understanding of this log. It is very long because it lists the variable and decisions for every AI faction, and it's decisions against every AI faction, from a defend decision, to an attack decision.

    Per faction, each AI faction (AIF from here on out) makes 2 basic decisions, one for defense and one for offense.

    There are certain decisions that occur in only one or the other, you must learn the basics of this so you know where to look.

    Since we are dealing with AI-AI politics right now we are concerned with defense decisions. These are listed before attack decisions in the log. Unfortunately, all defense decisions for all factions are grouped together, it is not grouped by faction. There is a reason for this, and it is for how the AI makes its decisions.

    We are going to start out with a DEFENSIVE entry in the log, this is only an example.
    Spoiler Alert, click show to read: 
    Code:
    15:08:33.500 [ai.ltgd] [info] <3> LTGD: decision parameters 'spain' (ai_label:catholic) vs faction 'england':
    15:08:33.500 [ai.ltgd] [info] <3>       military: frontline_balance 1, military_balance 0.279735, military_balance_plus_enemies 0.0664313, alliance_military_balance 0.279735, free_strength_balance 1.59256e-005
    15:08:33.500 [ai.ltgd] [info] <3>       faction standing: faction_standing 0, target_faction_standing 0, global_standing 0, target_global_standing 0
    15:08:33.500 [ai.ltgd] [info] <3>       diplomacy: stance Neutral, num_enemies 1, target_num_enemies 0, has_alliance_against 0, num_turns_allied 0, num_turns_ceasefire -1
    15:08:33.500 [ai.ltgd] [info] <3>       trusted_allies: trusted_ally 0, trusted_ally_enemy 0, trusted_ally_protectorate 0
    15:08:33.500 [ai.ltgd] [info] <3>       protectorate: is_protectorate 0, is_protectorate_of_catholic 0
    15:08:33.500 [ai.ltgd] [info] <3>       papal: excommunicated 0, enemy_excommunicated 0, has_ceasehostilities 0
    15:08:33.500 [ai.ltgd] [info] <3>       neighbour: is_neighbour 0, target_weakest_neighbour 0, strongest_neighbour 0, borders_all_our_regions 0
    15:08:33.500 [ai.ltgd] [info] <3>       win conditions: is_faction_to_outlive_target 0, is_target_faction_to_outlive 0
    15:08:33.500 [ai.ltgd] [info] <3>       misc: production_balance 8.64516, target_religion 0, target_faction england, num_settlements 4
    15:08:33.500 [ai.ltgd] [info] <3>             rand 0.197821, difficulty very_hard, turn_number 0
    15:08:33.500 [ai.ltgd] [info] <3>             most_desirable 0, target_human 0, target_is_shadow 
    015:08:33.500 [ai.ltgd] [info] <3> LTGD: (catholic) defend decision: defend = defend_minimal, defend_priority = -1, at_war = 0, want_peace = 0, want_ally = 0, want_be_protect = 0, alliance_against = 0, pts_alliance = -1
    ]


    This is the first line it tells you which FAI - FAI, train your eyes to find it. For now we are not going to concern ourselves with the other lines. For now we are dealing with diplomacy and its balance. The lines in purple are influences to diplomatic decisions, while the BLUE is the final result and bonus to achieve diplomacy.

    Balancing the CAI file is a fine line, and every time I have installed it into a different mod, I have had to adjust it. I wouldn't expect it to be any different for you.

    After the initial 15 turns of play is when you need to start gauging this.

    So now you get to go play! You must play your campaign on VERY HARD for at least 30 turns of play!! I recommend 50.

    If you have a multiplayer mod, you can put it on auto play and jump in as you need too. There are instructions elsewhere on the forums for this. (insert link here)

    What you are looking for is strictly FAI to FAI alliance blocks, and wars. You are looking to achieve a balance here and this is where it gets subjective.
    Last edited by xeryx; April 18, 2010 at 08:55 PM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  4. #4
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: XCAI; Campaign AI balancing guidelines

    Basic Theory and Design
    How AI diplomacy works;Part 1

    Now that some basics are covered and you have played your integration for 50 turns. You should have a basic understanding of what the AI is doing in your mod.

    Now, I will explain the basic concept of AI to AI diplomacy.

    Most likely, you have too many alliances FAI - FAI. Or maybe even not enough, but it is unbalanced.

    What is the proper amount of alliances in a block? That is upto you, honestly and it will vary over the duration of the game.

    Our reccomendations; 3-6 depending on difficulty

    Remember this key note! XCAI has difficulty build into DIPLOMACY!! it is very important to play on Very HARD when setting your inital settings.

    I am going to tell you a secret, of how AI diplomacy really works within the game.

    ALL diplomacy for the AI works based off of its (defensive rules) pts_alliance = 1

    The ease at which AI makes alliances and performs all diplomatic actions is based on this number being in the positive! This number loosely correlates with Faction and Global Standings between FAI's.

    Let me repeat! This number must be in the positive in order for ANY FAI diplomacy to happen. This is also the reason that prior to 1.3 patch for Med2 and 1.5 patch for Kingdoms that the AI always had HUGE alliance blocks. There was no use of negative numbers.

    However, on VH we only want these numbers to go positive at certain times and after certain relations have been achieved, through Neutral and Friendly actions! That is where using Thorn's faction standing file comes in! Because all religions have consequences for their actions, as catholics did in vanilla.
    Last edited by xeryx; May 02, 2010 at 01:25 AM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  5. #5
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: XCAI; Campaign AI balancing guidelines

    How diplomacy works; Part 2

    Every turn that is played, your actions change the humans and FAI faction and global standings. This is all based on the Faction Standings file rules and settings.

    Faction standings: are faction to faction: and based upon your direct actions toward them. This also includes the diplomatic actions.

    Global Standings: are you actions taken upon other religious groups, and how aggressive you are as a player. It is how you are looked at globally.

    Religion in the XCAI is nothing more than a divider for factional groups. It is seperate from the AI labels, but can coincide with them. The FS file uses religion, and the CAI uses AI_labels

    That is all we need to understand for now.

    The XCAI takes difficulty level, differences in religion, whether you are human, and random factors into play to determine when diplomacy will happen. All you have to do as a modder is calibrate the XCAI to properly work. It will do the rest.

    I told you that FAI - FAI diplomacy works when the pts_alliance = 1 is in the positive (above ZERO). The more positive the more likely to achieve diplomacy. This scale can go to whatever the AI is designed to do. I.E. a range from -20 to a 20
    Last edited by xeryx; May 05, 2010 at 09:20 AM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  6. #6
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: XCAI; Campaign AI balancing guidelines

    Adjusting the AI to AI diplomacy.

    What I need you to understand is that this will be relative, and that there will be no specific number to target at this point. It is because there are too many variables, and we are just doing a basic calibration procedure. I will cover that in more detail in an advanced calibration and fine tuning tutorial later.

    The basic MOP (method of procedure) for adjusting.

    1) Play your campaign, determine how big the alliance blocks are for the AI. If they are way too large for your liking on VH. Then we will adjust the bonus for the AI.

    2) Use XML marker, or whatever editor you choose.

    3) Open the desc_campaign_ai_db.xml file

    4) Use the find function and find the blue line. Make sure the green area says false because we are just modding AI- AI right now.
    Start with the catholic ai in defend section.

    Spoiler Alert, click show to read: 
    Code:
             <decision_entry>
                    <!--Adjust this value for the whole Alliance system for the mod (AI)-->
                    <min_entry target_human = "false"/>
                    <max_entry target_human = "false"/>
                    <faction_attitude pts_alliance = "3" continue = "true"/>
                </decision_entry>


    This is a the MASTER offset to this religions general relations with other AI factions. DO NOT CHANGE ANY OTHER VALUES!!

    If you have way too many alliances then lower the red value down by 2, just too many than 1. You may have to go into the negative. (If you have the opposite effect (too few alliances), then you need to raise the numbers)

    5) Repeat for all AI's except papal_faction, nomad, slave and default! You are only concerned with the Main religious sects at this point.

    6) Check for errors, within XML MARKER. Then save the file. Try to load the file with ie explorer to do a final error check. If you get to the end of the file, all is good.

    7) Run the cache clearing procedure, and start a new game.

    8) Run through your many turns document the differences in alliances, and enemies.

    9) pay attention to when alliances are formed, when you see one formed stop on that turn, and proced to the next stage.
    Last edited by xeryx; April 23, 2010 at 05:21 PM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  7. #7
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: Balance Guidelines Project - XCAI - Campaign AI

    XCAI LOGS;

    Right now I am away from my main computer, and using my laptop. So, I will have to finalize more stuff later.

    Now, what you are going to learn is that there are correlations with the points alliance and other values in your mod.

    Looking at your notes, and finding the 2 FAI's that made an alliance, you are going to find them in the AI log. If you have been studying them you will understand what I mean.

    I will provide an actual example later, when I get a chance to play. For now I want to get you going on this.

    So say we had an alliance between Spain and Portugal.

    Do find Spain's decision process in the log. Then find the defense section VS. Portugal.
    Look at the last line and find the point_alliance = "XX" and document it.
    also look at the faction standings and global standings numbers, and document them.

    Now remember these number are fairly relative, but what you are trying to do is get a roundabout idea of the correlation of the points alliance to the Global and Faction standings.

    Now go play some more turns, and find another alliance. I would do this a few times to see the ranges of the points alliance and what the faction and global standings are .

    Continue playing your campaign through, and see how large the blocks are. Remember on VH we are trying to keep the alliance blocks smaller. As this will provide more opportunities for war with neutral nations (this is important for the Catholic nations).

    So now it up to you to on whether you keep adjusting or not.

    But in the factor of learning, I would like you to keep track of these numbers, so that you can post them in the forums. I have never had the time to gather enough information to figure out all of the correlation between faction standing, global standings and the pts alliance. So now I am going to ask that you give back to this team, so that we may find some more ways to make the ai better. If you can gather this information and report it we would greatly appreciate it.
    Last edited by xeryx; April 19, 2010 at 08:46 PM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


  8. #8
    xeryx's Avatar Follow the White Rabbit
    Join Date
    Nov 2006
    Location
    Wyoming, Usa
    Posts
    4,337

    Default Re: Balance Guidelines Project - XCAI - Campaign AI

    Adjusting the AI to HUMAN diplomacy.

    The human rules will be very similar to what we did with the AI. This is because once you get the alignment value set, all other things are taken into consideration for you. This way there is a consistent play though all mods.

    (THERE IS AN INHERANT BONUS for HUMAN DIPLOMACY in the HARDCODE)

    Points alliance also affect the human on the diplomacy screen. It acts as a bonus or a penalty. That is why the alignment is so important, if it is off one way or the other it throws off everything.

    First you will need to do some playing of your campaign, and do lots of diplomacy. Has it been way too easy, or hard on the VH level.

    Find this command in the Catholic section.
    Spoiler Alert, click show to read: 
    Code:
                <decision_entry>
                    <!--Adjust this value for the whole Alliance system for the mod (human)-->
                    <min_entry target_human = "true"/>
                    <faction_attitude pts_alliance = "-3" continue = "true"/>
                </decision_entry>


    You are going to have to do alot of diplomacy, but it will be worth it. Remember to check your logs, after you do some diplomacy.

    This is something you will have to "Use the Force" on! It is a feeling of balance, and is not an exact science.

    Those 2 numbers are the key!!

    Notice how much different the numbers are! between the AI- AI and the AI - Human. That shows you that there is an inherent balance flaw with Vanilla. The Human always had it WAY too easy, that is now fixed, through ingenuity.

    It will be perfectly normal to have diplomacy working, when there are negative numbers.

    However, this balance is all Dependant on the Diplomacy file! It is only used for the human. That file give you your final difficulty multiplier and variables for Human Diplomacy. The pt_alliance for the HUMAN DOES NOT have to be in the positive! to have successful relations. This is partially because of the Diplomacy file and it's modifiers.

    I will get into that more soon.

    This section is now finished.
    The next will be easier for you, as it only pertains to aggression of the AI.
    Last edited by xeryx; May 02, 2010 at 01:26 AM.
    Proudly patronized by B. Ward Click Sig Logo for Downloads, Click forums here and here
    "Do not try and bend the spoon, that is impossible, instead only try and realize the truth.
    There is no spoon, and you will see, it is not the spoon that bends, only yourself."-The Matrix


Posting Permissions

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