Page 1 of 2 12 LastLast
Results 1 to 20 of 40

Thread: All about the CAI (Campaign Ai).

  1. #1
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default All about the CAI (Campaign Ai).

    Preamble:
    First off please note this is still in development and nothing is certain, the facts here may be right or wrong, they have worked for me however. Feel free to contest them.
    This is a guide I’m writing to share some of the things I have learned over a year or so of fiddling with the warscape campaign ai which I feel a lot of people have missed or are not obvious and are thus worth sharing. It is aimed at those who have some experience of db editing and can use pfm well already, I’m not here to teach people how to mod from scratch. It largely concerns shogun which in my opinion is by far the most moddable due to the new features C.A have implemented and the numerous new easily accessible soft coded aspects of the ai. Nothing in this guide is absolute so do not take it as gospel, it is largely theory that has worked for me and remain such, please contest anything you feel is wrong or have proved wrong via research and experimentation. Most CAI values can be researched very easily by simply setting it to an extreme however there are so many researching them all would take week to do. Some values have an ambiguous effect and may well be entirely defunct as Ca moves functionality elsewhere.

    My projects
    UaisgII


    I have left all the past versions up so you can download and see the progression from version to version if you wish (doubt anyone will bother but meh )

    Uaintw

    A bit on the CAI
    The CAI uses a system called 'beliefs, desires and intentions' or 'BDI' to determine its decisions, this is a set of values with a small degree of randomisation that is supposed to give the ai and consistent and fairly intelligent manner. Each faction has a unique set of beliefs desires and intentions i.e. one faction may hate another or desire a certain region whoever holds it. The initial BDI is in the startpos.esf, it is theoretically editable however to my knowledge no one has yet done this. This is why at the start of many campaigns the same things often happen, units move to the same places, Oda always dies as does Shimazu. It is however possible to change the way the BDI is formed through Ca's system of tables.

    Notes on format
    -Tables columns will be shown in content boxes like so where possible
    table "column 1" "column 2"


    -The word "foo" will be used to represent a changeable or variable part of a name or value


    Tools
    -Pack File Manager Usage tutorial
    -Taws Db converter Tutorial on use
    -ESF Editor 1.4.8 Startpos modifying
    -Microsoft Excel can be handy or
    open office which is free and will do the same job.
    -Be aware that if PFM can’t open a table taws tools may be able to or visa versa

    General Recommendations
    -Rename every single table
    -Add a visible Ui component to the main menu and save the mod pack as movie, this guarantees the mod loads and adds a visual indicator to the menu showing you that it has loaded.
    -Check values by using extremes but be aware truly large values may cause instability.
    -Be prepared to run a lot of test campaigns , getting the ai to do something can take a lot of tweaking.

    List of CAI components
    Non moddable
    -The exe
    Theoretically possible but practically not possible without major development
    -Startpos.esf
    -pathfinding.esf (and all the other map files)
    Moddable
    -The Database (patch(foo)/db/foo
    -Scripting.lua (can be used to influence the ai but not covered here check out topcats scriptorama for more info on this)

    List of CAI db tables and Index

    General
    -campaign_ai_personality_junctions_tables
    -campaign_ai_manager_behaviour_junctions_tables


    cai_personalities_tables (very very important)

    May have small effects
    -cdir_configs_tables
    -campaign_variables_tables

    Recruitment
    -campaign_variables_tables
    -cdir_unit_balance_template_junctions_tables
    -cdir_unit_balance_group_qualities_tables
    -cdir_unit_qualities_tables
    -cdir_unit_balances_tables

    Construction and technology (interlinked due to building research requirements)
    -cai_base_building_context_values_tables
    -cai_personalities_construction_preference_policy_building_junctions
    -campaign_ai_technology_path_junctions_tables
    -campaign_ai_technology_manager_path_junctions_tables

    Finance
    -cai_personalities_budget_allocations_tables
    -
    cai_personalities_budget_allocation_policy_junctions_tables

    Character devlopment
    -campaign_ai_character_skill_tree_distribution_junctions_tables
    -campaign_ai_character_skill_tree_manager_agent_junctions_tables
    -campaign_ai_character_skill_tree_junctions_tables

    Reference (some may be important with major esf modding otherwise just used to find values)

    -cai_agent_distribution_profiles_tables
    -cai_agent_distribution_types_tables
    -cai_agent_record_to_cai_agent_type_junctions_tables
    -cai_agent_recruitment_profiles_tables
    -cai_agent_recruitment_types_tables
    -cai_agent_type_distribution_profile_junctions_tables (this can also be used to edit behaviour hover is a crude way of doing it so is best avoided)
    -cai_agent_type_recruitment_profile_junctions_tables
    -cai_agent_types_tables
    -cai_military_aggressiveness_policies_tables
    -cai_military_behaviour_policies_tables
    -cai_personalities_budget_context_types_tables
    -cai_personalities_budget_policies_tables
    -cai_personalities_construction_preference_policies_tables
    -cai_personalities_reliability_policies_tables
    -cai_personalities_religious_conversion_policies_tables
    -campaign_ai_personalities_tables
    -campaign_ai_managers

    Last edited by The Hedge Knight; June 07, 2011 at 05:55 AM.

  2. #2
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.


    The general tables
    -campaign_ai_personality_junctions_tables
    -campaign_ai_manager_behaviour_junctions_tables
    -cai_personalities_tables

    Campaign Ai Personality Junctions
    Campaign ai personalities are applied per faction in the esf , in shogun 2 there is only one personality however more can theoretically be added to the esf as in past total war games in order to Taylor certain specific factors to a factions situation. More on that can be found here; I don’t think it’s necessary though, default has always suited my needs and the 'sub personalities' (explained later) make up for this.

    The table itself should be fairly self explanatory in format

    Table Format
    "Personality" "Value name" "value"


    This table does have a lot of values I’m unsure of but could be tested relatively easily, if you know what one does please don’t hesitate to say.

    Interesting values

    BASIC_DESIRE_FORT_MAINTAINENCE_OWNED_REGION_OCCUPIED_FORT_UPGRADE_foo
    -Forts were only in empire so this is defunct

    BASE_CONSTRUCTION_BIAS_foo
    -This value has a lesser effect in shogun due to the new ways the ai constructs buildings, buildings are chosen by assigned value now not just randomly.

    BAWP_WEIGHTING_foo
    -I’m pretty sure that BAWP stands for begin war and peace; however these values determine the situations in which the ai will consider war.

    COMPOSITE_VALUE_ANALYSER_REGION_foo
    -These values determine whether the ai will give up a region. If the loss multipliers are set very low then the ai will retreat when invaded giving up the region. It will also become very passive. If set high the ai will become stubborn (loss multipliers) and/or suicidal in the attack. The groups referred to are the army groups the CAI forms

    GRANULOID_CONSTRUCTION_BIAS_PERSONALITY
    -Notice this is set to 0 in shogun, one of the reasons I feel the base construction bias' are now somewhat defunct

    INVASION_OBTAINING_LOCAL_MOBILES_ARMY_STRENGTH_MULTIPLIER_FOR_BALANCE_TYPE_foo
    -High values make the ai suicidal, low very defensive, these should be well balanced

    LOOT_SETTLEMENT_ALWAYS_LOOT_CEILING
    -the dice roll value for whether to loot, keep this high as the ai is naturally bad at handling disorder

    MINIMUM_CHANCE_OF_SUCCESS
    -Seems to be for invading a region

    NAVY_LOCAL_DISTRIBUTION_IMPORTANCE_PCT_MOBILE
    NAVY_LOCAL_DISTRIBUTION_IMPORTANCE_PCT_PORT
    NAVY_LOCAL_DISTRIBUTION_IMPORTANCE_PCT_REGION
    NAVY_LOCAL_DISTRIBUTION_IMPORTANCE_PCT_TRADE_ROUTE
    These four values tell the ai what percentage of its fleets to put in what areas the PCT_OWNED_BY values then tell the ai whose areas of control they could be placed in. This can be used to make the ai attack ports and trade routes more easily. Higher region values may make naval invasion more likely

    PERSONALITY_PROPORTION_OF_DESIRED_STRENGTH_NECESSARY_TO_CONSIDER_RAIDING
    -A raid is not an invasion, it’s the ai running round with small stacks burning your buildings. It may result in undefended regions being captured though.

    PRIORITY_RANDOMIZATION_DESIRE
    -Randomisation in the BDI can be used to make the CAI more unpredictable however high values may cause instability.

    RECRUITMENT_ARMY_CATEGORY_BASE_PROPORTIONS_foo
    -Pretty certain these are now defunct

    RECRUITMENT_ARMY_POSSIBLE_ADDITIONAL_UNITS_PER_REGION_HIGH
    -Extra units to consider recruiting when a new region is captured

    RECRUITMENT_MINIMUM_NEW_ARMY/NAVY_SIZE
    -Minimum units before it moves out as a stack

    REGION_DEFENCE_BASE_PRIORITIES_foo
    -Only works if you can actually make the ai defend

    SUPPORT_OBTAINING_LOCAL_MOBILES_ARMY_STRENGTH_foo
    -Seems to be generally a defensive function also does seem to include garrisons

    VALUE_ANALYSIS_TIME_HORIZON
    -This value according to DARTH VADER (full credits to him) controls how many turns ahead the ai will consider when making moves. High values will cause system crashes as they cause over strenuous calculations with large CAI empires.

    WAPM_CORRIDOR_SIZE_IN_UNITS_ABOVE_WHICH_ARMY_SPLITS_ARE_ALLOWED
    -Just throwing in that distances on the map show no real scale of any obvious distance, just bear in mind the interception distance of armies is 3.
    [/CONTENTBOX]

    [CONTENTBOX="[COLOR=#365F91]campaign_ai_manager_behaviour_junctions_tables[/COLOR]"]
    Managers are different from personalities in that they control how likely the ai is to do a specific action such as to expand rampantly or be diplomatic. They are once again assigned per faction in the esf.

    The managers in shogun are
    -sho_ashikaga
    -sho_major
    -sho_minor
    -sho_minor_full
    -sho_wako
    -sho_tutorial

    in the grand campaign the Ashikaga is controlled by sho_ashikaga
    The 11 majors (including Ikko Ikki) are controlled by sho major.
    All the minors are sho_minor_full
    The Portuguese and Wako use sho_wako
    sho_tutorial and sho_minor are only used in the tutorial campaign.

    Value notes
    FORT_MAINTAINANCE_BEHAVIOUR
    -there are no forts

    GLOBAL_CONSTRUCTION_BEHAVIOUR
    -More controlled in budget contexts but a higher value does seem to see the ai build more

    MINIMUM_SAVING
    -Ai will try and not fall below this, not having no money may impact diplomacy

    CULL_EXCESS_FORCES
    -Unit disbandment

    EXCESS_RECRUITMENT_BEHAVIOUR
    -If the ai has excess money a high value here will make it pour money into building units

    EXPANSION_BEHAVIOUR
    -Seems largely defunct by cai_personalities

    HELP_ALLY_AT_WAR
    -Likelihood of aiding ally, note too high a value will produce a suicidal ai which fails to defend itself in favour of its allies.

    NAVY_DISTRIBUTION
    -High value = wider spread

    NAVY_STRENGTH_MANAGER
    -Higher value = more ships

    RAID_BEHAVIOUR
    -Too high a value here will impact on full invasions making them less likely

    RECAPTURE_BEHAVIOUR
    -Causes ai to throw units at recently lost towns if too high, normally they invading army is quite large making this suicidal

    RESEARCH_TECHNOLOGY
    -Ai researches stuff whatever you put here so ignore it

    UBER_GENERAL_BEHAVIOUR
    -Uber generals (i.e. daimyo’s) attack far more frequently if this value is set high

    Last edited by The Hedge Knight; June 07, 2011 at 04:23 AM.

  3. #3
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Cai Personalities
    This is a new table and extremely powerful, it allows you to make different factions act in unique ways as assigned in the esf. I call these sub personalities.

    Table format
    "agent distribution pattern"
    "Agent recruitment bias"
    "budget type"
    "general upgrade path"
    "building bias"
    "sub personality name"
    "aggression"
    "attitude towards shogunate"
    "reliability"
    "religious conversion policy"
    "tech path"
    "unknown (doesn’t seem to affect anything like the other columns)"


    Obviously this would be useless unless you knew which factions had which sub personality so I made a list (may not be 100% accurate but works well for me)

    Factions to sub personality
    01 oda p_oda
    02 hojo p_hojo
    03 Shimazu p_shimazu
    04 Mori p_mori
    05 Tokogawa p_tokogawa
    06 Takeda p_takeda
    07 Uesegi p_uesegi
    08 Date p_date
    09 Chosokabe P_chosokabe
    10 Hattori p_hattori
    11 Ikko Ikko
    12 Ito Aggressive Default
    13 Sagara Peaceful_reliable
    15 Shoni Default_Reliable
    16 Ouchi Default Reliable
    17 Kono Random
    18 Sogo Default_Reliable
    19 Miyoshi Defensive
    20 Amako Agressive Unpredicatable
    21 kikkawa Pirate
    22 Matsuda Random
    23 Otomo Random
    24 yamana Random
    25 Besho Random
    26 Takaoka Random
    27 Hatano Random
    28 Sakai Random
    29 Hatakeyama Default_Reliable
    30 tsutsui Default Reliable
    31 Ashikaga Ashikaga
    32 Asai Ninja
    33 kitabatake Defensive
    34 Saito Default Reliable
    35 Jinbo Random
    36 anegakoji Random
    37 Kiso Defensive
    38 Imagawa Default_Reliable
    39 Murakami Default_Unpredictable
    40 yamanouchi Defensive
    41 ogigayatsu Defensive
    42 Satomi Random
    43 Satake Random
    44 Ashina Agressive Reliable
    45 Honma Pirate
    46 Mogami Default Reliable
    47 Portugal Wako and nanban
    48 Wako Wako and Nanban


    Column notes

    Agent distribution
    Required tables for reference
    -cai_agent_type_distribution_profile_junctions
    -cai_agent_distribution_types
    -cai_agent_distribution_profiles
    -cai_agent_record_to_cai_agent_type_junctions

    Look at cai_agent_type_distribution_profile_junctions

    Table format "agent" "distribution profile name" "location bias"


    So the first column of cai_personalities decides what each sub personality does with its agents.

    What each location in cai_agent_type_distribution_profile_junctions does:

    cai_agent_distribution_types
    this gives the location bias'

    cai_adt_borders_enemy_biased
    -agents will hang around the countryside in your land

    cai_adt_enemy_capital_centric
    -Agents will move to your towns

    cai_adt_enemy_capital_centric_presence_of_own_forces_biased
    -agents will move with armies

    cai_adt_home_captial_centric
    -agents will defend own lands


    Agent recruitment bias
    Reference Tables
    -cai_agent_record_to_cai_agent_type_junctions
    -cai_agent_recruitment_profiles
    -cai_agent_recruitment_types
    -cai_agent_type_recruitment_profile_junctions

    Should be fairly self explanatory, the three tables reference to cai_agent_type_recruitment_profile_junctions which is then referenced in cai_personalities


    budget type
    One of the tables I have not cracked really

    Reference tables
    -cai_personalities_budget_context_types
    -cai_personalities_budget_policies
    -cai_personalities_budget_allocations
    -cai_personalities_budget_allocation_policy_junctions

    These tables have resisted my best efforts.

    it is clear cai_personalities_budget_allocation_policy_junctions

    goes "situation name" "situation type" "budget type" "id/order"

    cai_personalities_budget_allocations then gives each budget types spending allocations (somehow)

    I theorise the order is:
    "money band 1 cap"
    "percentage spending category 1"
    "percentage spending category 2"
    "percentage spending category 3"
    "money band 2"
    "percentage spending category 1"
    "percentage spending category 2"
    "percentage spending category 3"
    "money band 3"
    "percentage spending category 1"
    "percentage spending category 2"
    "percentage spending category 3"
    "money band 4"
    "percentage spending category 1"
    "percentage spending category 2"
    "percentage spending category 3"
    "name"
    "money band 5"
    "percentage spending category 1"
    "percentage spending category 2"
    "percentage spending category 3"

    But its untested so ignore this unless you feel like some experimentation


    general upgrade path
    Tables (not just for reference)
    -campaign_ai_character_skill_tree_distribution_junctions_tables
    -campaign_ai_character_skill_tree_manager_agent_junctions_tables
    -campaign_ai_character_skill_tree_junctions_tables

    only campaign_ai_character_skill_tree_manager_agent_junctions seems worth editing if any are

    table format "agent to be upgraded" "skill tree distribution to use" "personality type referenced in cai_personalities"



    Building bias
    Will talk about this later in more detail

    reference
    -cai_base_building_context_values_tables
    -cai_personalities_construction_preference_policies_tables
    -cai_personalities_construction_preference_policy_building_junctions

    This simply makes the sub personality more likely to build certain building types, but scroll down.


    aggression
    Not much to say, higher value = more insane ai in expansion

    Reference
    -cai_military_aggressiveness_policies_tables

    Notes
    Default = utterly random, decided once at start of game

    cai_pmap_low_to_high and cai_pmap_medium_to_high are both decided at the beginning of the game only.

    cai_pmap_very_low will not ever attempt to capture units, the Ashikaga Shogunate will expand rapidly if you change this for them


    attitude towards shogunate
    Reference
    -cai_personalities_reliability_policies

    Self explanitory, sort of a secondary expansion behaviour. Preservists are more likely to side with the shogunate after realm divide, anarchists will try and seize Kyoto.


    religious conversion policy
    Reference
    -cai_personalities_religious_conversion_policies

    Affects the ai's likelihood to build temples and monks


    Tech path
    More on this later as its quite complex

    Reference tables
    -campaign_ai_technology_path_junctions_tables
    -campaign_ai_technology_manager_path_junctions_tables


    Last edited by The Hedge Knight; June 06, 2011 at 04:34 PM.

  4. #4
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Construction
    Tables
    -cai_base_building_context_values_tables
    -cai_personalities_construction_preference_policies_tables
    -cai_personalities_construction_preference_policy_building_junctions

    It should be noted all values take the form of a probability not a definite value. All constructions have some degree of randomisation.

    cai_personalities_construction_preference_policies_tables and cai_personalities_construction_preference_policy_building_junctions are to do with the sub personality. cai_base_building_context_values_tables is simply a base set of values.

    cai_base_building_context_values_tables
    -This tables has both contexts and priorities for building a certain building within that context, what the contexts are is not 100% percent clear right now however I have determined some:

    Column 2: Peacetime policy, some threat, economic build up needed
    Column 3,6 and 9: I generally assume these are unused/random
    Column 4: Ai feels no threat so concentrates on civil buildings
    Column 5:mobilisation and war
    Column 7:economic deficit

    cai_personalities_construction_preference_policies_tables
    -This tables is a list of the construction preferences listed in cai_personalities.

    -cai_personalities_construction_preference_policy_building_junctions
    columns "unused" "unused" "building name" "construction preference" "value"


    So the likelihood of the ai building any given building is determined by
    -its situation
    -the base change
    -the personality modifier

    So just as an example
    when at was a faction may build any of the three dojo's, the values are

    Yari: 112
    Sword: 121
    Bow: 120
    Cavalry: 88

    So a usual faction will build the sword dojo. A Buddhist build bias faction however has a +10 buff on the archery dojo so will build that instead.


    Technology
    Technology is once again done through cai_personalities with different sub personalities having different priority bias.

    Tables
    -campaign_ai_technology_path_junctions_tables
    -campaign_ai_technology_manager_path_junctions_tables

    These tables form a sort of tree like system for working out what to research with one leading to the other.

    campaign_ai_technology_manager_path_junctions

    This table acts as a sort of base for research.
    Format "technology bias group name (referenced in CAI personalities)" "specific technology branch" "bias towards that branch"


    So the first column is the type of tech generally, the second more specific and the third a probability that that branch of tech will be followed.

    The branches are things like 'way of fire' (rush to guns) and 'civil teir 1' (complete all low level civil techs then move up). I hope this makes sense: D, it’s quite confusing to write about.

    campaign_ai_technology_path_junctions_tables

    This table references each tech to each "technology branch" as defined in campaign_ai_technology_manager_path_junctions

    Table format "specific technology branch" "specific tech" "probability/priority"


    Once again this table has a degree of randomisation so higher priority does not necessary mean a higher chance of researching said tech.


    Last edited by The Hedge Knight; June 06, 2011 at 04:26 PM.

  5. #5
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Recruitment Getting good recruitment is vital to a good AI. The structure the ai uses is like a tree. Type of army, Type of unit, unit class, specific unit.

    Tables

    -cdir_unit_balance_template_junctions_tables
    -cdir_unit_balance_group_qualities_tables
    -cdir_unit_qualities_tables
    -cdir_unit_balances_tables

    perhaps
    -campaign_variables_tables


    cdir_unit_balance_template_junctions_tables
    -This table tells the faction which type of army to consider recruiting, there is of course some degree of randomisation. The armies are then defined in cdir_unit_balances_tables.

    Table format
    "faction" "army name" "bias"


    DONT try adding your own factions, it doesn’t work like that and I’m not 100% sure how to add new ones, likely some link in the esf.

    cdir_unit_balances_tables
    -This defines army compositions in a very general manner.

    Table format
    "army name" "min units???" "Max units???" "unit class" "proportion of army" "min proportion of army" "bools (ignore)"

    Make sure the proportion of army adds up to 1 or the game will freeze when the ai trys to make that army. The minimum proportion does not have to add up to 1.

    You can add new classes and proportions to those classes to the army, check cdir_unit_balance_group_qualities_tables for reference as to the classes you can add.

    The unit types within the unit classes are then defined in cdir_unit_balance_group_qualities_tables

    cdir_unit_balance_group_qualities_tables
    Table Format
    "faction" "unit class" "unit category" "priority"


    Once again don’t try and add your own factions or classes. You can add new unit catergories to the table however to give a wider range of units within the class. Check unit classes tables for this.


    Finally the units within the categories are defined by cdir_unit_qualities_tables; the ai will recruit the best unit for the job according to this table.

    Table Format
    "Faction" "unit category" "specific unit" "priority within category"


    And thus the ai makes armies.


    Also in campaign_variables_tables
    -cdir_unit_quality_foo
    May have an effect on CAI recruitment however i have not noticed this with my experimentation.

    BUT

    Remember the ai can only build balanced armies if it has the right buildings and the right technologies to do so.


    Additional credits
    Vragos
    DARTH VADER
    Radious
    Last edited by The Hedge Knight; June 19, 2011 at 04:56 AM.

  6. #6

    Default Re: All about the Campaign Ai.

    Nice work - cleared up a few tables that were puzzling to me. Thanks a bunch.

    Here are some of my ramblings, take it for what it is worth.



    @buildings

    Regarding the randomization of buildings, I stumbled across a value of 5 or 10 for that somewhere... now just to find where it was, I'll get back to you on that. Edit: Might be the PRIORITY_RANDOMIZATION_DESIRE value in campaign_ai_personality_junctions.

    Also I found that adjusting
    cai_finance_const_bias_xxx_level and cai_finance_const_bias_xxx_level in the campaign_variables has a huge impact on how well the AI spend their money on construction. I stumbled across it recently, and have not fully tested it yet - but it seems to have a massive impact in how quickly they build buildings, espcially how often they start new contructions. I adjusted them to the values of legendary, and suddenly saw AI cities with 2-3-4 buildings being constructed at once - as I often see in my own cities. It seems that at lower difficulty there is a delay put in as to how often the AI is allowed to start new construction, severely limiting the challenge they present in late game.


    @recruitment and army balancing section

    Quote Originally Posted by The Hedge Knight View Post
    Once again don’t try and add your own factions or classes.
    I managed to add siege and special infantry as new classes in the cdir_unit_balance_xxx tables, so I was more in control of how the AI balance their armies. Works fine, but you got to be thorough and get all the tables adjusted for it ofcourse. (Not in the relased version of my mod, but in the wip version)



    Quote Originally Posted by The Hedge Knight View Post
    Finally the units within the categories are defined by
    Quote Originally Posted by The Hedge Knight View Post
    cdir_unit_qualities_tables; the ai will recruit the best unit for the job according to this table.


    You absolutely sure about this? Because I thought so as well at first, but I found that it works like this:
    Chosokabe needs archers, it has quality 800 set for this in cdir_unit_balance_group_qualities... however it can only recruit units of quality 250 based on values in cdir_unit_qualities, so it compensates by recruiting more thus pushing the values in cdir_unit_balances out of proportion. It was supposed to recruit say 0,2 (4 units) of the army as archers, but ended up recruiting 800/250*0,2 =0,64 so roughly 12 units instead of the 4 units that cdir_unit_balances stated.

    From what I found, it was the main reason for the "archer bug" that so many have seen - where the AI wasn't able to meet the requirements for the quality of archers and thus spammed them to compensate. That they have 50% loss rate in autoresolves means they get merged very rarely leading to almost full stacks of archers.


    @the tools, I use open office instead of MS excel - works great with TSV copy-pasting and it's free.



    alright... 10th edit of this post done, bedtime... again, awesome work putting this together.
    Last edited by Vragos; June 06, 2011 at 06:20 PM.

  7. #7
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Quote Originally Posted by Vragos View Post
    Nice work - cleared up a few tables that were puzzling to me. Thanks a bunch.
    Also I found that adjusting cai_finance_const_bias_xxx_level and cai_finance_const_bias_xxx_level in the campaign_variables has a huge impact on how well the AI spend their money on construction. I stumbled across it recently, and have not fully tested it yet - but it seems to have a massive impact in how quickly they build buildings, espcially how often they start new contructions. I adjusted them to the values of legendary, and suddenly saw AI cities with 2-3-4 buildings being constructed at once - as I often see in my own cities. It seems that at lower difficulty there is a delay put in as to how often the AI is allowed to start new construction, severely limiting the challenge they present in late game.
    This is essentially a cheat im pretty sure as it gives the ai a building cost bonus.
    @recruitment and army balancing section


    I managed to add siege and special infantry as new classes in the cdir_unit_balance_xxx tables, so I was more in control of how the AI balance their armies. Works fine, but you got to be thorough and get all the tables adjusted for it ofcourse. (Not in the relased version of my mod, but in the wip version)
    Yes actually its possible to add an existing class to an army setup, ill expand on this later perhaps. I remember now i did it by adding seige units army setups in the uai . Should clarify this. Thanks.


    You absolutely sure about this? Because I thought so as well at first, but I found that it works like this:
    Chosokabe needs archers, it has quality 800 set for this in cdir_unit_balance_group_qualities... however it can only recruit units of quality 250 based on values in cdir_unit_qualities, so it compensates by recruiting more thus pushing the values in cdir_unit_balances out of proportion. It was supposed to recruit say 0,2 (4 units) of the army as archers, but ended up recruiting 800/250*0,2 =0,64 so roughly 12 units instead of the 4 units that cdir_unit_balances stated.

    From what I found, it was the main reason for the "archer bug" that so many have seen - where the AI wasn't able to meet the requirements for the quality of archers and thus spammed them to compensate. That they have 50% loss rate in autoresolves means they get merged very rarely leading to almost full stacks of archers.

    @the tools, I use open office instead of MS excel - works great with TSV copy-pasting and it's free.


    alright... 10th edit of this post done, bedtime...
    I must admit this sorta makes sense to me but doesnt. I play with the fog of war off when ai testing and know that the archers were not being spammed due to dodgey merging but actually being recruited. Also this rather falls down when it comes to stacks of samurai bowmen which have a high value and thus according to this theory should stop the archer spam. But i will have to look into this further.

    Also added open office to the tools
    Last edited by The Hedge Knight; June 06, 2011 at 06:24 PM.

  8. #8

    Default Re: All about the Campaign Ai.

    In patch6.pack the value for ranged and ranged_late is 800 for archers in _group_qualities. The value for standard bow samurai is 400 in _qualities.

    And yeah, they AI will keep recruiting, because they make "new" armies - which they then end up merging for invasion armies. The old armies suffer double the losses in all other categories than ranged due to the value of 0,5 in
    autoresolve_unit_land_ranged_casualty_reduction in campaign_variables. Thus they merge the infantry and cavalry units after battles, but rarely the archer units.

    Again, this is just based on my observations while making my own CAI.
    Last edited by Vragos; June 06, 2011 at 06:30 PM.

  9. #9
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Too tired for maths at half midnight so will look tommorow . Sounds a fair theory though.

    Also just on a note cdir unit qualities was the onyl table (in a different format ill give) in ntw and it definitelly made the ai recruit the units with the highest values it could in that table. Hence why the ai never recruited howitzers; cannons had a larger value and were lower down the building chain.

    But anyway tommorow.

  10. #10

    Default Re: All about the Campaign Ai.

    This is essentially a cheat im pretty sure as it gives the ai a building cost bonus.
    Really should be getting some sleep, but that makes little sense to me. cai_finance_const_bias_very_hard_turns and cai_finance_const_bias_very_hard_level sounds like pure bias adjustments, the cost reduction is in the campaign_difficulty_handicap_effects tables. It makes sense to me that they wanted to be able to control how often the AI decides to start new contructions though. I have rarely seen them build master smiths even past 150 turns while playing on hard for example, before I changed these values. Essentially they put in some cap on what level the AI would raise buildings to, and how quickly... maybe to simulate realistc development, maybe just to give the player a chance.

  11. #11
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Perhaps, though some values in that table such as autoresolve_very_hard_difficulty_AI_advantage definitelly do give the ai an advantage in the campaign. I just cant see how the ai could build more right now without some kind of advantage.

    I mean with my uai its not uncommon to get stuff like this:

    on normal difficulty later in the campaign.

    But will give it a go when im a tad less jetlagged.
    Last edited by The Hedge Knight; June 07, 2011 at 05:05 AM.

  12. #12

    Default Re: All about the Campaign Ai.

    Thanks Hedge Knight, good work.

    I wonder when AI considers unit recruitment as reinforcement or forming a new army. So, for example, if one army has lost so many of its 'x' type of units, the new recruitment will be 'x' type and they will walk up to merge with the existing army OR will the new units generally follow the trend of recruitment?

  13. #13

    Default Re: All about the Campaign Ai.

    Have anyone found a value for making the AI more likely to make regions vassals instead of looting or occupying them?

  14. #14

    Default Re: All about the Campaign Ai.

    Thanks Hedge, this's really helpful. However, do you know how to make the AI accept and offer peace treaty more often?
    In my last campaign with UAI 2.0 and Radious diplomacy (H/H), the AI never accepts peace treaty even after being beaten to peaces, but in another campaign (N/H difficulty), the AI accepts them very often and sometimes even offer peace treaties

  15. #15
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Campaign difficulty plays a big role. Nothing you can really do about that.

  16. #16

    Default Re: All about the Campaign Ai.

    Have you figured out what values are associated with making the AI actually defend its territory if it only has 1 army/region? I tried making REGION_DEFENCE (in campaign_ai_manager_behaviour_junctions) the highest value so that the clan should put that above everything else, but they still send their one army to attack me when another clan is right there to take their region.

    I've been irritated by this more then once, when the AI basically just kamakazi's into me instead of defending the region even when there is a rival army right on their doorstep.

  17. #17
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    The usefulness of campaign_ai_manager_behaviour_junctions has been blown to bits by shogun, it just doesnt do that much anymore as its been largelly replaced by cai_personalities.

  18. #18
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: All about the Campaign Ai.

    Updated

  19. #19

    Default Re: All about the CAI (Campaign Ai).

    Hi!

    Splendid resource, very helpful, thanks for sharing.

  20. #20

Page 1 of 2 12 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
  •