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

Thread: AI Expansion

  1. #1

    Default AI Expansion

    AI Expansion

    Spoiler Alert, click show to read: 

    nb1 This is a work in progress.

    nb2 Originally i followed this process for my own modding, testing to 50 turns - which took ages. When i decided to repeat the process and write it up as a tute i couldn't handle doing dozens of 50 turn tests again so i started with 30 then finally 12. The first set of edits show an obvious improvement in AI performance within 12 turns but some of the later map edits e.g the Caffa land-bridge only show an improvement around 40-50 turns. This may be a little confusing later but the most important changes show within 12 turns.


    Introduction

    This tutorial will consist of a series of posts exploring techniques for improving the AI's campaign map performance with the least amount of modding effort. It's mainly aimed at people who've already modded a bit but maybe haven't looked at AI behaviour but i'll also detail the modding steps involved in some of the changes i make as a general modding tutorial. I'll use the vanilla campaign as the test case.

    The general pattern of the posts will be:
    1. Description
    2. Modding Details
    3. Effect

    The effect will be based on running automated tests after modding and seeing if the AI takes more or less regions than they did compared with the vanilla files.

    The list of areas covered will be:

    Intro
    Setting up

    Part 1

    Universal changes that show up in short tests i.e 12 turns
    --Movement points
    --AI movement trait
    --Brigands, Pirates and Revolts (part 1)
    --Brigands, Pirates and Revolts (part 2)
    --Pre-building
    --Rebel garrisons

    Changes relating to specific factions to help their individual expansion or edits to particular regions the AI has a problem with. These will be:

    --Scotland
    --Russia
    --Denmark
    --Portugal
    --Caffa region


    Part 2

    --New Baseline
    --England and Venice
    --Mystery Improvement
    --Modding for the AI (Rebels)
    --Modding for the AI (Missions, Money Shocks and Upkeep)
    --Unit Stats
    --Campaign AI


    +++

    Next post: Setting up
    Last edited by tupodawg999; February 03, 2010 at 02:44 PM.

  2. #2

    Default Re: AI Expansion

    Post 2: Setting Up

    The best way to get a feel for how the AI behaves is to start the game (or mod) as a faction that is out of the way and doesn't get bothered in the early game e.g egypt, then pick a faction to watch and click end turn while watching what that faction does. You'll soon see the problems (it helps to have a spy nearby to look into woods) but figuring out the solutions to those problems is mostly guesswork and trial and error.

    However, many of the AI's problems relate to random events such as army revolts which do not occur consistently for each faction at the same point in each game. To test to see if edits related to that sort of thing has a beneficial effect on the AI's expansion then i think you need to run sets of tests, average out the results and then compare them to a vanilla baseline.

    To do this we need to set up a mod in a way where we can automate the AI for a specified number of turns.

    Modding Details

    The first step is to get our testing mod set up and ready.

    Step 1

    1) Create a "mods" folder inside your main MTW2 folder.
    2) Create an "ExpansionTest" folder under the mods folder.
    3) Create a "data" folder under the ExpansionTest folder.
    4) Copy the "world" folder from your main MTW2 "data" folder and copy it into expansiontest/data.

    Step 2

    1) Make a copy of your medieval2.preferences.cfg file in your main MTW2 folder and rename it to "expansiontest.cfg".
    2) At the top of this new file add

    Code:
     
    [features]
    mod = mods/ExpansionTest
    Lower down find the section that should look something like:

    Code:
     
    [hotseat]
    autoresolve_battles = 0
    disable_console = 0
    disable_papal_elections = 0
    save_prefs = 0
    update_ai_camera = 0
    validate_diplomacy = 1
    and replace it with

    Code:
     
    [multiplayer]
    playable = true
    [hotseat]
    autoresolve_battles = 0
    disable_console = 0
    disable_papal_elections = 0
    save_prefs = 0
    update_ai_camera = 0
    validate_diplomacy = 1
    Step 3

    1) Create a new text file in the same main MTW2 folder, name it "ExpansionTest.bat" and write in

    medieval2.exe --io.file_first @ExpansionTest.cfg

    Step 4

    1) Run the .bat file

    If it's all working right what should happen is the game will load and if you select single player / grand campaign / england / start then you should see the hotseat screen for your first turn as england. You don't need to bother about the password just click start. You'll be in a standard vanilla campaign in hotseat mode running from a mod folder.

    Quit game.

    Step 5

    1) Go to the mods\expansiontest\data\world\campaign\imperial_campaign folder and open the campaign_script.txt file.
    2) Near the top of the file, just below where it says:
    Code:
     
    ;----------------------
    ; monitors
    add

    Code:
     
    monitor_event FactionTurnStart TrueCondition
    console_command control england
    terminate_monitor
    end_monitor
     
    monitor_event FactionTurnStart FactionType slave
    and I_TurnNumber = 10
    console_command control england
    terminate_monitor
    end_monitor
    What these scripts do is as soon as the game starts control of the england faction is handed over to the to the ai. After the number of turns determined by the value you put in the script (in this case 10) control is returned to the player.

    Effect

    1) Use your expansiontest.bat file to start the game again, select single player / grand campaign / england / start and when the hotseat screen comes up click through that. What should happen if everything is working right is the ai should immediately take control of the england faction as well as all the others and carry on that way for n turns at which point control of england is handled back to you.

    2) When the ai takes control hit the space bar once so the game uses fast movement.

    3) Open up the console - on my keyboard it's the @ key that brings up the console but i believe it varies - then type "toggle_fow" so you can see the whole map.

    nb The number of turns to use is tricky as you need to use different numbers to test different types of edit. The testing process is a lot faster if the number of turns is low so it's a good idea to test changes that show an effect within a few turns first with a low number of turns, then lengthen the test runs later if neccessary.

    4) Count something.

    What to count will depend on what you're trying to test. If you're testing general AI expansion and you've set the number of turns to be low then it's quicker to count the number of regions the AI factions have taken. If you've set the number of turns higher then it will eventually become quicker to test something else like the number of rebel regions remaining.

    5) Repeat the test a number of times and average the results to try and iron out random events.

    Baseline

    For my initial tests i'm going to set the number of automated turns low and count the number of regions taken by the AI factions.

    For the initial group of tests i set the number of automated turns to 10. As the game starts at turn 0 this returns control after 11 turns (i meant it to be 12 but counted wrong).

    Six tests using the vanilla files gave me a baseline total of 102 regions gained by the AI factions.

    nb The numbers per test were 18, 17, 20, 18, 12, 17. Generally in my testing the numbers tend to mostly cluster but with dramatic outliers. I think this is because in an average game maybe 2-3 factions have a major glitch. In some games maybe only one does and the expansion is particularly good. In other games maybe 4-5 factions have a major glitch and there's a big drop.

    Given the level of randomness in the game i don't think six tests is really enough but it takes too long to do more. However i think if a change produces an improvement of 10%+ then it's reasonable to assume there's some benefit.

    Lastly instead of adding each change on top of each other i'll make a change, test it individually, then remove it again before the next change so each test will be compared purely with the vanilla game. This is because the same problem can have multiple work-arounds. One fix might help with 10 AI problems and another might help with 30 but some of those problems will be the same. It's easier to see the general scale of improvement if it's just compared to vanilla.

    +++

    Next post: Movement points
    Last edited by tupodawg999; January 15, 2010 at 10:15 PM.

  3. #3

    Default Re: AI Expansion

    Post 3: Movement Points.

    The AI in MTW (and RTW) has major path-finding problems. One of the main reasons for slow AI expansion is the AI armies are constantly getting stuck trying to reach their targets.

    I believe the main problem is simply that the path-finding calcs take too long when there's a lot of units to move in the AI turn so the game uses a strong path-finding method to find a route to a target up to one turn's worth of movement points away and if it hasn't found the target within that range then the ai switchs to a weaker but faster method of path-finding. Therefore increasing the army movement points increases the range the game uses the strong path-finding method for each AI each turn.

    The downside is this can have a dramatic effect on the length of the AI turn to the point where the game becomes unplayable (at least to me) so there's a compromise to be made. Strict agent limits can help with this as the AI factions have a habit of clogging up the game spamming spies and other agents.

    The default value for army movement is 80 movement points. What value to increase it to will depend on map size, scale, region density etc and will have to be found by trial and error and tested late game when the map is swarming with AIs. From previous testing with the vanilla map i think 120 is a good value so i'll go with that.

    Modding Details

    Step 1

    Copy the vanilla descr_character.txt file from the vanilla mtw2 data folder and copy it to our mods/expansiontest/data folder.

    Step 2

    Open decr_character.txt and edit the values for movement points to be 120 for armies and 180 for admirals and agents:

    Code:
    starting_action_points 120 ; default value for all characters and pathfinding calculations
    Code:
     
    type named character
    actions moving_normal, moving_quickmarch, garrison, assault, attack, besiege, entrench, ambush, diplomacy, bribe, exchange, building_fort, building_watchtower
    wage_base 100
    starting_action_points 120
    Code:
     
    type general
    actions moving_normal, moving_quickmarch, garrison, assault, attack, besiege, entrench, ambush, exchange
    wage_base 0
    starting_action_points 120
    and for the agents and admirals

    Code:
     
    type spy
    actions moving_normal, spying
    wage_base 100
    starting_action_points 180
    Code:
     
    type admiral
    actions moving_normal, quick_sail, blockade, disembark, exchange
    wage_base 50
    starting_action_points 180
    repeat for all the others.

    Effect

    Run the ai-controlled tests and count the number of regions captured by the AI.

    In my case the total was 139 which is a nice improvement over 102.

    (20, 23, 27, 23, 23, 23)

    Increasing the base movement points will give the biggest improvement for the least modding effort.

    +++

    Next post: AIMovementBonus trait.
    Last edited by tupodawg999; January 15, 2010 at 09:25 PM.

  4. #4
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: AI Expansion



    A lot of interesting stuff here. I would suggest to move this thread to the scripting section.


    Quote Originally Posted by tupodawg999 View Post
    Another possibility might be to have just one level of the trait that gave a 100% bonus right away but with an anti-trait and triggers that removed the bonus. The anti-trait triggers might be:
    1) Post-battle - to hopefully reduce retreating too far
    2) Ended turn in settlement.
    3) Ended turn outside a settlement but with < 50 movement.

    I'm not that familiar with anti-traits so i did it this way with four incremental bonus movement levels to dilute any unintended consequences a bit.
    An antitrait reduces points of his opposing trait first before accumulating points itself. That is, when you have GoodCommander and BadCommander as antitraits and a character gains one level in GoodCommander for winning a battle, the next battle lost will not give him a level in BadCommander (what would result in him being a good and a bad commander at the same time) but take away the level acquired before in GoodCommander. Further battles lost would then give him points in BadCommander.

    For your purpose I would indeed suggest to use one level in AIMoveBonus and a trigger with a negative value for reset:

    Code:
     
    ;------------------------------------------
    Trait AIMoveBonus
    Characters family
    ;Hidden
     
    Level AIMoveBonus1
    Description AIMoveBonus1_desc
    EffectsDescription AIMoveBonus1_effects_desc
    Threshold 1 
    Effect MovementPoints 10
    ;===============================================================
    
    Trigger Reset_AIMoveBonus_trigger
    WhenToTest CharacterTurnEnd
     
    Condition Trait AIMoveBonus = 1
    
    Affects AIMoveBonus -1 Chance 100
    ;--------------------------------------------
    Trigger AIMoveBonus_trigger
    WhenToTest CharacterTurnEnd
     
    Condition IsGeneral
    and not EndedInSettlement
    and RemainingMPPercentage > 95
    and not FactionIsLocal
     
    Affects AIMoveBonus 1 Chance 100
    That way the bonus trait will be reseted for each character who has it and instantly afterwards given anew for anyone qualifing, allowing him to use the bonus movement the next turn.

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  5. #5

    Default Re: AI Expansion

    @Konny
    A lot of interesting stuff here. I would suggest to move this thread to the scripting section.
    Ty. I posted here because some of the changes will be map edits so the changes will be both text file and map.

    For your purpose I would indeed suggest to use one level in AIMoveBonus and a trigger with a negative value for reset:
    Yes on reflection i think you're right. I'll redo it.

  6. #6

    Default Re: AI Expansion

    Post 4: AIMovementBonus Trait

    (Hat-tip to Konny for suggesting an improvement to this which i've incorporated.)

    Most players will have seen the basis of the next change many times without realising the significance - an AI stack will join a crusade/ jihad and suddenly attack a nearby city that has nothing to do with the crusade / jihad target. A lot of players will have seen France do this with Bruges early in a vanilla game but it will happen all over the map at some point or other during a game.

    What happens is one of the most common pathing glitches involves an AI stack moving to attack a city gets stuck at a point more than one but less than two turns movement away from the city. However anything that brings the target city within one turn's movement of the bugged army fixs the problem and the stack moves again. Many things can do this like a road being built in the region but one of the most common in MTW2 is the stack joins a crusade and gets its movement points doubled, and it seems, because the army was stuck when it joined the crusade, the original target city takes precedence over the crusade target city.

    This will only happen with a general army and not a captain army obviously.

    The AI much prefers to have its generals as governors - unless it has spare generals it will usually move all of them into cities and use mostly captain armies. However one advantage the AI seems to have is it often gets captains promoted to generals on the move and the captains that get promoted seem to be almost always those armies that have been told to capture a city. What this means is the critical AI stacks - the ones that get stuck on the way to attack settlements are the ones most likely to get general promotions.

    This kind of promotion is not rare but it's not common either - it's somewhere in between. I've seen an AI captain getting promoted en route to attack a city many times while testing but the frequency overall doesn't seem to be more than one per faction at a time and my guess would be when the faction already has a governor in each of its cities. There's also either a random element to it or it's very specific i.e when the faction has exactly x generals in x cities and captain armies moving to attack cities. If there's already excess generals it may not happen at all.

    Regardless of the details there will be many times during an average game where an AI captain army will get promoted to general while stuck more than one but less than two turns of movement away from its target.

    This provides the opportunity for a trait fix to help the AI expansion.

    Modding Details

    Step 1

    1) Add a "text" folder in "mods/expansiontest/data".
    2a) Either copy the export_VnVs.txt.strings.bin file from the main mtw2 "data/text" folder into mods/expansiontest/data/text and use the strings_bin_converter from http://www.twcenter.net/forums/downl...o=file&id=1006 to convert it to export_VnVs.txt. Delete the .bin file afterwards.
    2b) Or download the text files http://www.twcenter.net/forums/downl...do=file&id=951 , then copy the export_VnVs.txt file and paste it into "mods/expansiontest/data/text".
    3) Add at the top:

    Code:
     
    ¬--------------------
    {AIMoveBonus1} AIMoveBonus1
    {AIMoveBonus1_desc}
    AIMoveBonus.
    {AIMoveBonus1_effects_desc}
    +100% to Movement Points
    Step 2

    1) Copy export_descr_traits.txt from the main mtw2/data folder into mods/expansiontest/data.
    2) Under

    Code:
     
    ;===============================================================
    ;== TRAIT DATA STARTS HERE ==
    ;===============================================================
    add

    Code:
     
    ;------------------------------------------
    Trait AIMoveBonus
    Characters family
    ;Hidden
     
    Level AIMoveBonus1
    Description AIMoveBonus1_desc
    EffectsDescription AIMoveBonus1_effects_desc
    Threshold 1 
    Effect MovementPoints 10
    3) Lower down the same file underneath

    Code:
     
    ;===============================================================
    ;== TRIGGER DATA STARTS HERE ==
    ;===============================================================
    add

    Code:
    ;------------------------------------------
    Trigger Reset_AIMoveBonus_trigger1
    WhenToTest CharacterTurnEnd
     
    Condition Trait AIMoveBonus = 1
    Affects AIMoveBonus -1 Chance 100
     
    ;------------------------------------------
    Trigger Reset_AIMoveBonus_trigger2
    WhenToTest PostBattle
     
    Condition Trait AIMoveBonus = 1
    Affects AIMoveBonus -1 Chance 100
     
    ;------------------------------------------
    Trigger AIMoveBonus_trigger
    WhenToTest CharacterTurnEnd
     
    Condition IsGeneral
    and not EndedInSettlement
    and RemainingMPPercentage > 95
    ;and not FactionIsLocal
     
    Affects AIMoveBonus 1 Chance 100
    nb1 The live version of the trait would be Hidden and AI only but those parts are commented out for testing.

    nb2 There seems to be an odd glitch with the "RemainingMPPercentage" condition. In the original version of this trait when i had "RemainingMPPercentage = 100" in the trigger it wouldn't fire with base movement points of 120 plus a previous 20% movement bonus - some kind of strange rounding error somewhere maybe - however setting it to "> 95" works. This may be useful info for anyone getting odd results with that condition.

    nb3 The reason for the postbattle trigger is one of the unintended consequences of the trait i already knew about was the common situation where an AI army goes move->siege->siege->assault. In this case the AI would get the movement bonus at the end of the turn of sieging and then if the assault on the next turn fails the stack would sometimes retreat the full distance given by the move bonus. This could then lead to situations where the AI gets stuck at the spot they retreated to but the move fix won't help them because they already have it. Removing the movement trait postbattle hopefully prevents that.

    nb4 Getting stuck after retreating is the second biggest AI movement problem.

    Effect

    I removed the previous changes to bring the mod folder back to the vanilla state, made this change and then ran the six tests.

    My result was 114 regions gained (compared to the baseline of 102).

    Actual values 18, 22, 16, 17, 17, 24

    +++

    Next post: Brigands, Pirates and Revolts (part 1)
    Last edited by tupodawg999; January 15, 2010 at 10:16 PM.

  7. #7

    Default Re: AI Expansion

    Post 5: Brigands, Pirates and Revolts (part 1)


    Brigands, Pirates and Revolts have both good and bad effects on the AI.

    Some examples:

    1) An AI army is moving to attack a target settlement along a narrow valley. Brigands spawn along the route blocking the pathing. The AI army stops in front of the brigands. The faction sends a second army to attack the brigands but they can't reach them because the first army is in the way.

    2) An AI army moves to the coast to join a fleet for a naval invasion but the fleet is being constantly attacked and retreated by pirates in some cases causing it to eventually glitch.

    3) An AI army en route to attack a target settlement revolts and joins the rebel garrison making it a much tougher target than before.

    Some examples of how it can help.

    1) An AI army is stuck en route to attacking a target settlement. However eventually it revolts thereby clearing the glitch and allowing the AI faction to try again.

    2) An AI army which is stuck, or appears so, has brigands spawn nearby. In this case it moves to attack the brigands and after the battle finds its new position doesn't have a pathing problem so the army is no longer stuck and carries on moving to whatever its original target was.

    On top of the specifics, *because* rebels, pirates and revolts effect the AI a great deal they are one of the prime causes of randomness in the game.

    Modding Details

    In keeping with the basic idea of making changes that take the least amount of work we'll first try and remove the negative effects in the simplest way.

    Step 1

    1) Go to the mods/expansiontest/data/world/maps/campaign/imperial_campaign folder
    2) Open descr_strat.txt
    3) Near the top where it says:

    brigand_spawn_value 20
    pirate_spawn_value 28
    change to

    brigand_spawn_value 50
    pirate_spawn_value 50
    This greatly reduces brigands and pirates.

    nb setting it to 0 gives you max brigands

    Step 2

    1) Copy the file descr_campaign_db.xml from the main MTW2 data folder into the mods/expansiontest/data folder.

    2) Open the file and edit where it says:

    <ai_revolt_modifier float="0.25"/>
    change it to

    <ai_revolt_modifier float="0.0"/>
    I don't know if this stops revolts completely but it appears to.

    Effect

    Rolling back the previous changes and applying these edits to the vanilla game gave results of 113 gained regions (compared to the baseline of 102).

    Actual results 16, 19, 18, 19, 20, 21.

    +++

    Next post: Brigands, Pirates, Revolts (part 2)
    Last edited by tupodawg999; January 16, 2010 at 12:06 AM.

  8. #8

    Default Re: AI Expansion

    Post 6: Brigands, Pirates, Revolts (part 2)



    As mentioned in the previous post brigands, pirates and revolts can have good effects as well as bad so ideally there'd be edits that could reduce the negative effects while leaving the good. To do that we'd need to identify what the more precise cause of the problems were.

    My take on that is:

    Brigands

    I think both the positive and negative effects of brigands are equally related to their spawn frequency but the negative consequences are more related to the *strength* of the actual spawned army. For example if you open descr_rebel_factions.txt and look at the entry for "english rebels" you see:

    rebel_type English_Rebels
    category peasant_revolt
    chance 3
    description English_Rebels
    unit Peasants
    unit Levy Spearmen
    unit Armored Swordsmen
    unit Longbowmen
    unit Longbowmen
    unit Mailed Knights
    unit English Knights
    unit Town Militia
    unit Spear Militia
    unit Archer Militia
    The game will pick a number of units to be spawned then seems to randomly assign those units from the list above. Some of those units are very strong and occasionally a brigand army will appear that can keep an AI faction tied down for numerous turns trying to finish it off. There's nothing wrong with that in itself except to make the game a challenge we want to change things in the game that cause the AI more problems than the player.

    So a possible solution would be to keep the brigand frequency the same but reduce the average strength of the brigand armies so they provide the randomizing effect without causing the occasional AI road-block.

    Pirates

    Pirate ships are stronger than the factional starting ships.
    They can spawn in groups of two or three.
    They often merge into bigger fleets.
    The AI factions merge their fleets less.
    The AI factions don't hide their fleets in safe ports until they're needed.

    Combined together this all means the pirates are too strong and this can mean big problems for potential naval invasions especially in the early game unless the AI faction in question starts with a strong fleet and sometimes even then.

    Revolts

    Revolts are a useful mechanic to make the game more challenging but currently they impact on the AI much more than the player. This is simply because the revolt chance is much higher for captain led armies and the AI mostly has captain-led armies whereas the player (at least me) hardly ever moves an army without a general. The game tries to balance this with an AI specific modifier to reduce their revolts but i don't think it's enough.

    Modding Details

    Step 1

    1) Copy descr_rebel_factions.txt from the main MTW2 data folder to the mod data folder.
    2) Change the existing entries to be more like:

    rebel_type English_Rebels
    category peasant_revolt
    chance 3
    description English_Rebels
    unit Peasants
    unit Peasants
    unit Peasants
    unit Peasant Archers
    3) Leave the brigand spawn rate at 20

    Step 2

    1) Copy export_descr_units.txt from the main MTW2 data folder to the mod data folder.
    2) Find the entry for pirate ships and edit the combat stats. As a trial attempt i changed the attack and defence from 10 to 6 and reduced the number of soldiers from 20 to 18.

    Soldiers:

    soldier Peasants, 18, 0, 1
    Attack:

    stat_pri 6, 0, no, 0, 0, melee, melee_simple, slashing, none, 25, 1
    Defence:

    stat_pri_armour 0, 6, 0, flesh
    3) I left the spawn frequency at 28 for the test but i think it's probably better to increase it a little as after my tests the AI fleets still looked like they'd come off worst. Another alternative would be to reduce the number of soldiers a bit more.

    Step 3

    1) Copy the file descr_campaign_db.xml from the main MTW2 data folder into the mods/expansiontest/data folder.

    2) Open the file and where it says

    <ai_revolt_modifier float="0.25"/>
    change it to

    <ai_revolt_modifier float="0.1"/>
    This should dramatically reduce the number of revolts while still hopefully leaving enough of a chance to clear stacks that are stuck in position for many turns.

    Effect

    Clearing the previous edits and running with these changes gave test results of 112 so pretty much the same 10% ish improvement to AI expansion without completely removing them.

    nb These changes help the player as well as the AI but you can compensate for making it easier for the player as well by adding player-only revolt scripts.

    +++

    Next post: Pre-building
    Last edited by tupodawg999; January 16, 2010 at 02:08 AM.

  9. #9

    Default Re: AI Expansion

    Post 7: Pre-building


    The vanilla game is set up such that initial faction settlements have high starting populations, high-ish starting settlement levels but very low levels of pre-placed settlement buildings. The high population, high growth rate and high-ish settlement levels help the AI in terms of long-term cash but here we're interested in short-term expansion and so our third change is to pre-build some military buildings in the starting settlements.

    However it's not as clear-cut as it first appears. The AI vs rebel garrison batles will all be done by autocalc and will therefore rely on the autocalc strengths of the units and the relative numbers of each unit in the army which is ultimately determined by buildings and recruitment settings. In the TW games missile units, cavalry and especially horse archers have generally been weak in autocalc so if you're adding buildings to help with early AI expansion that is a factor to take into account.

    For the sake of argument let's say the foundation of the autocalc strength is number of soldiers times melee attack then if we look at early castle units for england we have:

    Peasant, 150 x 4 = 600
    Levy Spearmen, 150 x 5 = 750
    Peasant Archers, 120 x 2 = 240
    Hobilars, 80 x 7 = 560
    Knights, 80 x 10 = 800

    So counter intuitively, if knights were cheaper the AI would expand best if there were no pre-built buildings and the AI produced just knights. The expense would interfere with that idea obviously. The next best option is the Levy Spearmen. One noticeable thing, if these were the genuine autocalc strengths, is how adding a Bowyer building might actually weaken the early autocalc armies. If for example the AI recruited

    Peasants, Spearmen, Peasants, Spearmen, Peasants, Spearmen
    then building a Bowyer made the sequence

    Peasants, Spearmen, Peasant Archers, Peasants, Spearmen, Peasant Archers
    the average autocalc strength being produced would dip from:

    600 + 750 + 600 + 750 + 600 + 750 = 4050 / 6, per turn
    to

    600 + 750 + 240 + 600 + 750 + 240 = 3180 / 6, per turn
    This is in fact what happens (over a short number of turns). I added a garrison_quarters, bowyer and stables to all the AI starting castles and the number of regions captured over 12 turns dropped slightly. When i tested over a longer number of turns adding all three buildings produced an improvement. I think what happens is adding all three buildings does dip the average output of autocalc strength slightly but having the three buildings pre-built speeds up the point where the AI builds the next upgrade so over a longer number of turns it averages out.

    There's a lot more to say about how to help the AI factions optimize their autocalc potential through recruitment based on the units they have but i'll come back to it when talking about specific factions, particularly horse archer factions.

    For now, looking at the unit list above it does seem as if adding a garrison_quarters to all the AI starting castles would be a completely safe bet as a way to increase early AI expansion and as this segment is about the first 12 turns i'll do that.

    Modding Details

    1) Clear the previous changes to get the mod folder back to vanilla status.
    2) Go to the mods/expansiontest/world/maps/campaign/imperial_campaign folder and open descr_strat.txt

    Add the following building to all the AI starting castles

    Code:
     building
     {
      type castle_barracks garrison_quarters
     }
    Some of the starting castles already have some of the military buildings. I deleted them to make the test more clear cut.

    Effect

    With adding garrison_quarters, bowyer and stable the total regions captured in six tests was 99, which compared to the baseline of 102 was no improvement.

    Just adding garrison_quarters on its own gave a total regions captured score of 111.

    Obviously changes like this helps the player as well, but personally i think because of all the AI-specific pathing and other glitchs that making the base expansion easier for both player and AI and then giving the player handicaps is better than making the expansion harder and then giving the AI more money.

    nb1 Another strat file related aspect to this is the AI starting armies - strong or weak starting units can make a big difference to early expansion.


    +++

    Next post: Combined Effect (1)
    Last edited by tupodawg999; January 26, 2010 at 05:45 AM.

  10. #10

    Default Re: AI Expansion

    Post 8: Combined Effect (1)

    The previous posts cover those universal changes that show up an obvious effect in a short number of turns so after showing their individual effects i'll combine them now and see how we're doing so far. Redoing and combining the previous changes to include:

    Movement point increase
    AI movement trait
    Rebel changes (2nd version)
    Pre-built garrison_quarters

    Six tests to turn 12 gave me a total of 159 captured regions compared to the vanilla baseline of 102 which i think comprises a pretty substantial improvement.

    The next set of posts will comprise of changes for specific factions and regions. Individually these won't have a dramatic effect on the total number of regions captured but will help individual factions slightly or modift their expansion in some way. I'll combine these changes with the current set and test them at the end. When those are done i'll go back to looking at universal changes that help the AI generally but those changes that need longer test runs to show up.

    +++

    Next post, Rebel Garrisons
    Last edited by tupodawg999; January 17, 2010 at 02:56 AM.

  11. #11

    Default Re: AI Expansion

    Post 9: Rebel Garrisons

    This is fairly obvious. Strong rebel garrisons slow the AI, weak ones speed it up. Just a few points.

    1. Even if you want to have strong garrisons and slow expansion it pays to have low garrisons initially to speed up testing for problems the AI has reaching certain regions.

    2. Regions on the edges of the map that are only targeted by one faction should have weaker garrisons *or* make sure your campaign AI doesn't give too high invade priorities to attacking rebel regions when the faction is at war with another AI faction. Otherwise you can have situations where for example a faction is being invaded and conquered from the west by another faction but it's ignoring them and instead battering against strong rebel garrisons in rebel regions to the east. Either let them get to an edge in a reasonable number of turns or switch off attacking rebels when in a war with a faction.

    3. Buffer regions in the middle of multiple factions can have very strong garrisons without causing problems as the repeated attacks from multiple factions will eventually wear it down. These sort of regions provide a good randomizing effect.

    4. Slightly off-topic but similar, peripheral rebel regions far from the likely attacking faction's capital e.g Timbuctoo should ideally be made into castles rather than towns as the AI doesn't deal with rebellion very well.

    Modding Details

    Just for the sake of completeness in terms of stating all the changes i make to the vanilla files.

    1. Slightly reduced the garrisons in the edge regions of Dublin, Oslo, Stockholm, Helsinki, Dongola, Arguin and Timbuctoo.
    2. Changed Dublin, Arguin, Timbuctoo and Stockholm to castles.
    3. Reduced garrisons of Jerusalem and Edessa and increase that of Antioch and Adana.

    Effect

    Should be slight especially in short tests. Testing after all the factional edits are made should confirm that.

    +++

    Edit

    This turned out to be an example of exactly what not to do. Almost every change you make can effect the AI expansion and needs to be tested to check as it's so easy to a make a little change which can have dramatic unintended consequences.

    The major one in this case was greatly reduced Egyptian expansion.

    Watching vanilla to see what had changed there's a stack in Gaza and a captain stack in the desert nearby. The vanilla garrison of Jerusalem is quite large so the AI must decide it needs both stacks and moves the captain to merge with the Gaza army before attacking Jerusalem.

    Watching my modified version showed that because the garrison of Jerusalem was lower the AI had changed tactics. The Gaza army had switched targets to Jedda while the captain army remained targeted at Jerusalem. However some kind of pathing problem to Jerusalem from that spot led to the captain army being stuck leading to Jerusalem not being attacked at all within the 11 turns. So my quick untested attempt to improve egyptian expansion by reducing the Jerusalem garrison had the opposite effect.

    As an indication of the scale of that one small change, in the previous set of six tests the egypt AI managed to capture a total of 16 regions whereas after the garrison changes in the next set of six tests they only managed 5.

    I'll leave this post up as an example but i'll roll back all the garrison changes specified above for now and come back to the point later.

    +++

    Next post: Specific cases.
    Last edited by tupodawg999; January 20, 2010 at 03:38 AM.

  12. #12

    Default Re: AI Expansion

    Post 10: Specific Cases

    General AI expansion can be improved with various universal improvements like those specified above but on top of that there will also be more specific problems with particular regions or particular factions. These problems will be different on every map but i'll go through some of the vanilla map ones as examples.

    You can spot factions that expand badly or regions that the AI seems to have problems capturing through seeing the end results of the automated tests. However when you have identified a problem area you usually need to watch the AI moving turn by turn.

    To do this comment out the multiplayer bit in the .cfg file

    Code:
    ;[multiplayer]
    ;playable = true
    and the automation script in the campaign_script.txt file

    Code:
    ;monitor_event FactionTurnStart TrueCondition
    ;console_command control england
    ;terminate_monitor
    ;end_monitor
     
    ;monitor_event FactionTurnStart FactionType slave
    ;and I_TurnNumber = 10
    ;console_command control england
    ;terminate_monitor
    ;end_monitor
    then start the game - i usually pick egypt as you're not hassled by diplomats - then watch your problem faction closely while clicking end turn for the first few turns. With enough practice you can generally get to the point where you can tell where they're stuck and why.

    +++

    Next post, Specific faction, Scotland.
    Last edited by tupodawg999; January 18, 2010 at 03:03 AM.

  13. #13

    Default Re: AI Expansion

    Post 11: Specific Case, Scotland

    This is another small local change that will only have a small effect but a lot of small improvements add up to a big improvement.

    In my tests Scotland and England have four rebel regions to take and take all four maybe half the time. I want to increase that and one simple way is to make Inverness the Scottish start settlement.

    I'm not entirely sure why it works out better but having just a single way to go at start seems to make the Scottish AI glitch less.

    Apart from that it'll be more fun playing both Scotland or England if the Scottish faction has lots of Highlanders from the start.

    Modding Details

    1) Use the console and "show_cursorstat" to get the x, y co-ordinates of Edinburgh and Inverness.

    2) Change the x, y co-ordinates of the faction leader to those of Inverness.

    ;inverness
    character Malcolm Canmore, named character, male, leader, age 50, x 99, y 181
    traits Factionleader 1 , GoodCommander 2 , NaturalMilitarySkill 1 , PublicFaith 2 ...snip...
    army
    unit NE Bodyguard exp 1 armour 0 weapon_lvl 0
    nb I removed his army as the Scottish faction will have less money without Edinburgh.

    The other generals can be left where they are.

    unit NE Bodyguard exp 1 armour 0 weapon_lvl 0
    unit Highlanders exp 0 armour 0 weapon_lvl 0
    unit Highlanders exp 0 armour 0 weapon_lvl 0
    unit Highlanders exp 0 armour 0 weapon_lvl 0
    unit Peasant Archers exp 0 armour 0 weapon_lvl 0
    nb1 I changed their armies to to reflect the castle start.
    nb2 I removed the fleet as i don't want Scotland sailing off to Bruges early on)

    3) Find the rebel garrison for Inverness and change the x, y co-ordinates to those of Edinburgh.

    ;edinburgh
    character sub_faction scotland, Stuart Maknauchtan, general, male, age 32, x 102, y 174
    army
    unit Town Militia exp 2 armour 0 weapon_lvl 0
    unit Town Militia exp 0 armour 0 weapon_lvl 0
    unit Town Militia exp 0 armour 0 weapon_lvl 0
    unit Town Militia exp 0 armour 0 weapon_lvl 0
    nb I changed the units to Town Militia to reflect being in a town. This is just a habit of mine and not neccessary in any way.

    4) Find the settlement entry for Inverness in the slave faction section of the descr_strat file then cut and paste it into the Scottish faction section above the Edinburgh entry, modified to suit so it looks something like:

    faction scotland, balanced smith
    ai_label catholic
    denari 8000
    denari_kings_purse 1500
    settlement castle
    {
    level town
    region Inverness_Province
    year_founded 0
    population 1600
    plan_set default_set
    faction_creator scotland
    building
    {
    type core_castle_building wooden_castle
    }
    building
    {
    type castle_barracks garrison_quarters
    }
    }
    5) Cut the Edinburgh entry and move it down into the slave section modified to suit e.g

    settlement
    {
    level town
    region Edinburgh_Province
    year_founded 0
    population 1600
    plan_set default_set
    faction_creator scotland
    building
    {
    type core_building wooden_pallisade
    }
    }


    Effect

    In previous tests Scotland and England between them were gaining all four local rebel regions roughly 3 times out of 6. With this change it's roughly 4 or 5 times out of 6 so just a minor improvement but it all helps

    +++

    Next post: Specific Case, Russia
    Last edited by tupodawg999; February 05, 2010 at 01:41 AM.

  14. #14

    Default Re: AI Expansion

    Post 12: Specific Case, Russia


    Russian AI problems

    In the vanilla setup Russia hardly expands at all which is no fun if you're playing Poland or Denmark.

    After watching the AI it seems the vanilla Russia faction has three main problems.

    Problem 1

    The most obvious one is the large distances between regions. This is as it should be for this part of the map imo. I don't want to change the russia faction so that it can rapidly take all the steppe regions only to increase the average number of regions russia takes in the early expansion.

    Problem 2

    Russian armies attacking Helsinki often retreat and get stuck. This is fixed 80%+ of the time by the movement and trait changes outlined in earlier posts.

    Problem 3

    The Russian AI has a pathing problem between Novgorod and Smolensk. This is major because the Russian AI targets Smolensk very early and wastes a large army which is stuck outside Novgorod potentially for many turns. The other two fixs don't give russia the same benefit as the other factions because such a large part of its early armies are stuck outside Novgorod.

    Conclusion

    There are multiple ways of trying to fix this but in keeping with the principle of most benefit for the least amount of work the simplest solution is to just give Smolensk to Russia from the start. As Russia only starts with one town and most factions start with at least a town and a castle i think that's a good solution all round.

    Factions coming from the south don't have the pathing problem so it would only recur later in the game if a southern faction took Smolensk and Russia wanted to take it back. However by then road improvements or some other factor may have fixed the issue and anyway it's the early glitches which effect the AI the most because they cascade through the whole game.

    Modding Details

    To give Smolensk to Russia

    1) Start the game as Russia, hover the mouse over Smolensk, bring up the console and type "show_cursorstat". This will give you the co-ordinates of the city which are 212,162. Make a note of them.

    2) Open the descr_strat.txt file in the mods/expansiontest/data/world/maps/campaign/imperial_campaign folder and search for 212 until you find the rebel army with the same co-ordinates. This is the rebel garrison for Smolensk.

    3) Delete the garrison or comment out the lines with semi-colons so the game ignores it i,e

    Code:
    ;character sub_faction russia, Iosif of Smolensk, general, male, age 26, x 212, y 162 
    ;army
    ;unit  EE Archer Militia    exp 1 armour 0 weapon_lvl 0
    ;unit  EE Archer Militia    exp 0 armour 0 weapon_lvl 0
    ;unit  EE Spear Militia    exp 0 armour 0 weapon_lvl 0
    4) Search for Smolensk until you find the settlement details in the rebel section of the strat file:

    Code:
     
    settlement castle
    {
     level town
     region Smolensk_Province
     year_founded 0
     population 2200
     plan_set default_set
     faction_creator russia
     building
     {
      type core_castle_building wooden_castle
     }
    }
    Cut the above lines for the settlement and search for Novgorod. Paste the details for Smolensk between the section for Novgorod and the start of the russian starting armies. Add some starting military buildings so the russia section looks like:

    Code:
     
    faction russia, balanced smith
    ai_label default 
    denari 11000
    denari_kings_purse 2500
    settlement
    {
     level city
     region Novgorod_Province
     year_founded 0
     population 4000
     plan_set default_set
     faction_creator russia
     building
     {
      type core_building stone_wall
     }
     building
     {
      type barracks town_guard
     }
     building
     {
      type market corn_exchange
     }
     building
     {
      type temple_orthodox small_church_o
     }
     building
     {
      type hinterland_roads roads
     }
    }
    settlement castle
    {
     level town
     region Smolensk_Province
     year_founded 0
     population 2200
     plan_set default_set
     faction_creator russia
     building
     {
      type core_castle_building wooden_castle
     }
     building
     {
      type castle_barracks garrison_quarters
     }
     building
     {
      type missiles bowyer
     }
     building
     {
      type equestrian stables
     }
    }
    5) Of the three russian starting generals Prince vladimir is in Novgorod so move the Grand Duke into Smolensk by changing his starting x,y co-ordinates to those of Smolensk i.e 212, 162.

    Code:
    character Ysevolod, named character, male, leader, age 50, x 212, y 162 
    traits Factionleader 1 , GoodCommander 2 , Energetic 2 , Intelligent 1 , Drink 1 , Bloodthirsty 2 , ReligionStarter 1 
    army
    unit  EE Bodyguard    exp 1 armour 0 weapon_lvl 0
    unit  EE Archer Militia    exp 0 armour 0 weapon_lvl 0
    unit  EE Archer Militia    exp 0 armour 0 weapon_lvl 0
    unit  Woodsmen    exp 0 armour 0 weapon_lvl 0
    unit  Woodsmen    exp 0 armour 0 weapon_lvl 0
    unit  Kazaks    exp 0 armour 0 weapon_lvl 0
    That's it.

    Effect

    There won't be much effect in our short tests as we've effectively reduced Russia's short term autocalc strength by removing a free general but this change should produce a cumulative benefit over higher number of turns. I'll test all these faction changes together at the end.

    +++

    Next post: specific cases, Denmark.
    Last edited by tupodawg999; January 18, 2010 at 03:22 AM.

  15. #15

    Default Re: AI Expansion

    You might find these 2 links helpful

    http://rtw.heavengames.com/cgi-bin/f...&f=9,6718,,all

    http://forums.totalwar.org/vb/showthread.php?t=95416

    If your looking specifically for 'easy' modification, look at the part about the descr_strat.txt in the first link. If you change the 'personallity' as noted you will see an improvement (particularly late game) in AI expansion and army build.

  16. #16

    Default Re: AI Expansion

    @CavCmmdr

    Ty, i'll check those out, especially the second one as i think i may have written some of the first before my last divorce from TW games.

  17. #17

    Default Re: AI Expansion

    Post 13: Specific Cases, Denmark

    The Denmark AI is quite slow taking the two scandinavian regions. It's not critical but i'd like Denmark to expand better in that direction so it's more of a challenge if playing HRE and potentially russia, poland also.

    Secondarily i want to try and nudge the Denmark AI faction into having its centre of gravity slightly more towards the baltic and slightly less towards Antwerp and Bruges.

    I think the simplest way to try and achieve this is by creating a new region in the south of the Stockholm region. The effects should be:

    1) The new region will be closer to Arhus and therefore easier to take.
    2) There are no roads from Arhus to Oslo or Stockholm because of the land-bridge but once the new region is captured the AI will build roads which will make Oslo and Stockholm closer to Arhus in terms of movement costs. So although i am adding a third region i am expecting the denmark AI to take all three in roughly the same number of turns (on average) as it used to take the original two, possibly a bit less.
    3) Apart from any time benefit, adding the new region should shift denmark AI's activities to the east slightly and hopefully lead to more Baltic wars.

    Modding Details

    There are more complete tutorials on adding regions but the check list is:

    1) Go to mods/expansiontest/data/text folder.
    Open the imperial_campaign_regions_and_settlement_names.txt file. (If you don't have the text file then download and copy it from http://www.twcenter.net/forums/downloads.php?do=file&id=951 )

    Search for:

    Code:
    {Stockholm_Province}Stockholm Region
    {Stockholm}Stockholm
    copy and paste underneath and then change all the second set of "Stockholm" to "Lund" so it looks like this:

    Code:
    {Stockholm_Province}Stockholm Region
    {Stockholm}Stockholm
    {Lund_Province}Lund Region
    {Lund}Lund
    Delete imperial_campaign_regions_and_settlement_names.txt.strings.bin.

    2) Go to mods/expansiontest/data/world/maps/base.
    Open map_regions.tga.
    Pick an unused color and make a note of it.
    Paint a new region out of the south part of Stockholm.
    Add a black and white dot for town and port.
    Delete map.rwn.

    3) Open descr_regions.txt in the same folder
    Find the entry for Stockholm.
    Make a copy and paste it underneath.
    Change the names and the region color to be the one used for the new region so it looks something like this:

    Code:
     
    Stockholm_Province
     Stockholm
     denmark
     Norse_Rebels
     252 245 42
     silver, furs, iron, slaves
     5
     3
     religions { catholic 75 orthodox 8 islam 0 pagan 15 heretic 2 }
    Lund_Province
     Lund
     denmark
     Norse_Rebels
     200 100 100
     amber, timber, slaves
     5
     3
     religions { catholic 75 orthodox 8 islam 0 pagan 15 heretic 2 }
    4) Load the game and see if it works so far.

    You should have the new region with a rebel village as the settlement and no garrison.
    Check to see the port is displayed correctly.

    5) Go to mods/expansiontest/data/world/maps/campaign/imperial_campaign.
    Open descr_strat.txt and search for the stockholm settlement entry, below it add:

    Code:
     
    settlement
    {
     level town
     region Lund_Province
     year_founded 0
     population 1600
     plan_set default_set
     faction_creator denmark
     building
     {
      type core_building wooden_pallisade
     }
    }
    6) Use the console and the "show_cursorstat" command to get the x, y co-ordinates of Lund. Make a note.

    7) Search for "Sighvat Loftsson". This is the rebel leader for the rebel garrison in Stockholm.
    Copy the entry and paste a copy of this army under the first.
    Change the x, y co-ordinates of the copied general to those of Lund.
    Start up to check and you should have something like:




    Effect

    Lund is likely to be taken early but the main effect won't be seen until we increase the length of the tests. I'll test all the faction changes together..

    +++

    Next post, specific case, Portugal.
    Last edited by tupodawg999; January 26, 2010 at 05:57 AM.

  18. #18

    Default Re: AI Expansion

    Post 14: Specific Cases, Portugal-Spain

    This example isn't so much about improving the speed of AI expansion directly but influencing *where* a particular faction expands.

    As an example the vanilla portugal and spain AI factions tend to expand north-west into France in the early part of the game. There are specific reasons they're doing this but the general reason is the campaign AI sets the factions to prioritize rebel regions for x turns at the start of the game and the vanilla portugal and spain factions are close enough to rennes and bordeaux to give them roughly equal priority to the rebel regions in spain.

    So one way to get an AI faction to expand roughly in the direction you want in the early part of the game is to re-arrange rebel regions and use them as bait.

    What we're going to do is split Lisbon into two regions, give portugal the northern one and give Lisbon and Pamplona to the rebels. This will move Portugal away from france and give both Spain and Portugal a total of 4 rebel regions to keep them busy giving France more time to expand. This should make england more fun as France is no challenge at all in vanilla plus help make the moors/spain/portugal conflict more imteresting.

    Modding Details

    There are various tutorials on making a new region but the checklist is:

    1) Go to mods/expansiontest/data/text folder.
    Open the imperial_campaign_regions_and_settlement_names.txt file. (If you don't have the text file then download and copy it from http://www.twcenter.net/forums/downl...do=file&id=951 )

    Search for:

    Code:
    {Lisbon_Province}Lisbon Region
    {Lisbon}Lisbon
    copy and paste underneath and then change all the second set of "Lisbon" to "Portocale" so it looks like this:

    Code:
    {Lisbon_Province}Lisbon Region
    {Lisbon}Lisbon
    {Portocale_Province}Portocale Region
    {Portocale}Portocale
    Delete imperial_campaign_regions_and_settlement_names.txt.strings.bin. The game generates the .bin file from the .txt file at game start but only if the .bin file doesn't already exist. The game will use the unedited version unless you delete it every time you change the .txt file..

    2) Go to mods/expansiontest/data/world/maps/base.
    Open map_regions.tga.
    Pick an unused color and make a note of it.
    Paint a new region out of the north part of Lisbon.
    Add a black and white dot for town and port.
    Delete map.rwn. This needs to be done whenever the map files are edited.

    3) Open descr_regions.txt in the same folder
    Find the entry for Lisbon.
    Make a copy and paste it underneath.
    Change the names and the color to the one used for the new region so it looks like this:

    Code:
     
    Lisbon_Province
     Lisbon
     portugal
     Iberian_Rebels
     13 198 30
     tin, marble, atlantic, explorers_guild
     5
     4
     religions { catholic 55 orthodox 0 islam 35 pagan 5 heretic 5 }
    Portocale_Province
     Portocale
     portugal
     Iberian_Rebels
     200 120 20
     tin, marble, atlantic, explorers_guild
     5
     4
     religions { catholic 55 orthodox 0 islam 35 pagan 5 heretic 5 }
    The other bits can be left for now.

    4) Load the game and see if it works so far.

    You should have the new region with a rebel village as the settlement and no garrison.
    Check to see the port is displayed correctly as there are some map oddities along the coast near there.

    5) Go to mods/expansiontest/data/world/maps/campaign/imperial_campaign.
    Open descr_strat.txt and find the entry for the portugal faction.
    At the top just below

    Code:
     
    denari_kings_purse 2000
    add

    Code:
     
    settlement castle
    {
     level town
     region Portocale_Province
     year_founded 0
     population 1600
     plan_set default_set
     faction_creator portugal
     building
     {
      type core_castle_building wooden_castle
     }
     building
     {
      type castle_barracks garrison_quarters
     }
     building
     {
      type missiles bowyer
     }
     building
     {
      type equestrian stables
     }
    }
    This will be portugal's new starting settlement.

    6) Use the console and the "show_cursorstat" command to get the x, y co-ordinates of Portocale, Pamplona and Lisbon
    Move the portugal armies from Pamplona to Portocale by changing th ex,y co-ordinates of the general.
    Move the portugal armies in and near Lisbon into the Portocale region.
    Start the game and check for errors. Portugal should now start with three regions but both Pamplona and Lisbon should be empty

    7) Cut the entries for Lisbon and Pamplona from the portugal section of the descr_start.tx file.
    Search for "Valencia" and paste the Lisbon and Pamplona settlemts above that. Remove all the excess buildings so they look something like

    Code:
     
    settlement
    {
     level town
     region Lisbon_Province
     year_founded 0
     population 1600
     plan_set default_set
     faction_creator portugal
     building
     {
      type core_building wooden_pallisade
     }
    }
    settlement castle
    {
     level town
     region Pamplona_Province
     year_founded 0
     population 1600
     plan_set default_set
     faction_creator spain
     building
     {
      type core_castle_building wooden_castle
     }
    }
    8) Search for "Saluador Caruallo". This is the rebel leader for the rebel garrison in zaragoza.
    Copy the entry and paste twice under the first entry.
    Change the x, y co-ordinates of the two new copies to the x,y co-ordinates of Lisbon and Pamplona.
    Start up to check and you should have portugal with one castle and Lisbon and Pamplona as two new rebel regions with garrisons.



    Effect

    After testing you should see the spain and portugal AI is kept busy in spain in the early game and doesn't expand into France as much.

    Using rebel regions as bait is a good way to influence the AI.

    ++

    Next post, specific cases, Caffa.
    Last edited by tupodawg999; January 26, 2010 at 05:58 AM.

  19. #19

    Default Re: AI Expansion

    Post 15: Specific Cases, Caffa Region

    This is a very minor but helpful map edit.

    Because of the shape of the land and sea around the crimea the AI has problems pathing to any settlements on the peninsular if it's coming from the south east. They'll often get hung up at the point where the two parts of land are very close together.




    A simple solution is to place a new land-bridge at that point.

    Modding Details

    1) Go to the mods/expansiontest/data/world/maps/base folder.

    2) Open map_regions.tga in whatever image program you use and find the pixel co-ordinates of the three tiles we need, one tile of land from each side of the gap and the sea tile in between. In this case it's 236,67 / 237,67 / 238,67. Make a note.

    3) Open map_features.tga. Land-bridges are created by painting a line of tiles in the specific light green you can see in the file for the land-bridges already in place. Pick the green color and then paint the three tiles with the co-ordinates noted above.

    4) Delete the map.rwn file in the same folder. You need to do this whenever you edit one of the map files.

    5) Start up the game and you should see your new land-bridge.




    Effect

    On the vanilla map this change will only become relevant if an AI faction takes Sarkel.

    +++

    Next post, Conclusion (Part 1).
    Last edited by tupodawg999; January 26, 2010 at 06:01 AM.

  20. #20

    Default Re: AI Expansion

    Post 16, Conclusion (Part 1)

    With the changes specified in posts 3, 4, 6 and 7 plus the changes to Russia, Scotland, Denmark, Portugal and Caffa and the garrison changes mentioned in post 9 rolled back to vanilla status and testing the average number of regions taken by the AI in 11 turns averaged in the 150s compared to the vanilla baseline of 100-ish, similar to the level from before the faction and map changes.

    This was as expected as most of the changes were about where the AI expanded rather than how well, and the change to Russia has a negative effect on short-term expansion because of the loss of the mobile general.

    Testing to 30 turns worked out as hoped:

    1) Russia expanded better.
    2) Scotland-England took all four rebel regions more often.
    3) Denmark was about the same but weighted slightly more to the east and north.
    4) Portugal-Spain were about the same but inside Spain and not in France.

    +++

    There's various baseline changes i want to do to the mod now for my personal preferences which i know will reduce the AI expansion a great deal. If i do them now it will drag my baseline back down which means i can test further improvements still using only short test runs which make it easier.

    Part 2 in a bit.
    Last edited by tupodawg999; January 20, 2010 at 04:05 AM.

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
  •