Page 1 of 5 12345 LastLast
Results 1 to 20 of 86

Thread: Campaign AI Project

  1. #1
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Campaign AI Project

    I have been going through the AI decision tree and trying all kinds of stuff. The goal here is an entire rewrite of the AI, not just a few tweaks. I am going to try and radically change the behavior of the default AI tree based upon some things I want the AI to do. I will be basing this on my Barebones mod for Kingdoms, which will make a difference as the Kingdoms.exe has some AI entries that M2 does not. This is going to be a fairly long study, so any help is definitely appreciated.

    First things first, I never knew there was a way to log AI decisions until I actually read the entire AI file. Put this in your cfg file:

    Code:
    [log]
    to=logs/Barebones.system.log.txt
    level = ai.ltgd trace
    [ai] 
    ltgd_logging = true

    This will give us an output like this in our log. This is the Long Term Goal Director, and by evaluating this file, then making changes, then reevaluating we can see how the AI reacts to the exact same situation with different settings applied. This a LONG file, each faction has a decision for every other faction. So for example England has 21 of these sections, then France has 21, etc etc:
    Spoiler Alert, click show to read: 
    01:37:58.921 [ai.ltgd] [info] <6> LTGD: decision parameters 'milan' (ai_label:catholic) vs faction 'slave':
    01:37:58.921 [ai.ltgd] [info] <6> military: frontline_balance 14964, military_balance 0.0632097, military_balance_plus_enemies 0.0632097, alliance_military_balance 0.0632097, free_strength_balance 183
    01:37:58.921 [ai.ltgd] [info] <6> faction standing: faction_standing -1, target_faction_standing 0, global_standing 0, target_global_standing 0
    01:37:58.921 [ai.ltgd] [info] <6> diplomacy: stance AtWar, num_enemies 0, target_num_enemies 17, has_alliance_against 0, num_turns_allied 0, num_turns_ceasefire -1
    01:37:58.921 [ai.ltgd] [info] <6> trusted_allies: trusted_ally 0, trusted_ally_enemy 0, trusted_ally_protectorate 0
    01:37:58.921 [ai.ltgd] [info] <6> protectorate: is_protectorate 0, is_protectorate_of_catholic 0
    01:37:58.921 [ai.ltgd] [info] <6> papal: excommunicated 0, enemy_excommunicated 0, has_ceasehostilities 0
    01:37:58.921 [ai.ltgd] [info] <6> neighbour: is_neighbour 1, target_weakest_neighbour 0, strongest_neighbour 0, borders_all_our_regions 1
    01:37:58.921 [ai.ltgd] [info] <6> win conditions: is_faction_to_outlive_target 0, is_target_faction_to_outlive 0
    01:37:58.921 [ai.ltgd] [info] <6> misc: production_balance 0.126608, target_religion 4, target_faction slave, num_settlements 2
    01:37:58.921 [ai.ltgd] [info] <6> rand 0.572161, difficulty medium, turn_number 0
    01:37:58.921 [ai.ltgd] [info] <6> most_desirable 0, target_human 0, target_is_shadow 0
    01:37:58.921 [ai.ltgd] [info] <6> LTGD: (catholic) defend decision: defend = defend_minimal, defend_priority = -1, at_war = 1, want_peace = 0, want_ally = 0, want_be_protect = 0, alliance_against = 0, pts_alliance = 0


    The first thing to know about the AI decision tree is how its processed. There are two sides to the tree, invade and defend. Inside each of those are the individual decisions. The decisions start at the top, and work their way down until one decision returns a true value. Any other value that also happens to be true will not be implemented unless the continue faction_attitude parameter is included in one of the decisions. This means that the behavior of the AI can be changed simply by changing the order of the decisions. Whenever you see the word "target" this simply refers to the faction the decision is being processed for. In this case Milan is making decisions about the slaves (target).

    A decision is a long term attitude to take towards the target faction. These decisions can change over time, or even over the course of a single turn depending on how we code it, but as faction_standing changes are for the most part gradual, then the changes will also be gradual.


    The first line is self explanatory. Milan using the Catholic AI label to make decisions about the slave faction.

    The second line is the strength of Milan vs the strength of the slaves. Basically I think this says that Milan has a 183:1 ratio in favor of Milan.

    Line 3 is faction standings. The maximum faction standing is 1, the minimum is -1.
    faction_standing -1 = what Milan thinks of the slaves, they hate them
    target_faction_standing 0 = what slaves think of Milan, neutral
    global_standing 0 = Milans global standing
    target_global_standing 0 = Slaves global standing


    Line 4 is Diplomacy
    stance AtWar = AtWar with Slaves - The possibilitied are: Allied, Suspicious, Neutral, Hostile, AtWar)
    num_enemies 0 = The number of enemies Milan has
    target_num_enemies 17 = The number of enemies Slaves have
    has_alliance_against 0 = Do we have an alliance against the slaves, 0 = false 1 = true
    num_turns_allied 0 = Number of turns we have been allied with slaves
    num_turns_ceasefire -1 = Number of turns we have had a ceasefire with slaves, -1 means no agreement

    Line 5 is for trusted allies
    trusted_ally 0 = Is slaves a trusted ally? 0 = false 1 = true
    trusted_ally_enemy 0 = Is slaves a trusted ally of one of our enemies?
    trusted_ally_protectorate 0 = Is slaves a vassal of a trusted ally?


    Line 6 is protectorate status
    is_protectorate 0 = Is slaves protectorate of Milan?
    is_protectorate_of_catholic 0 = Is slaves protectorate of another Catholic faction?


    Line 7 is for the papal states
    excommunicated 0 = Is Milan excommunicated?
    enemy_excommunicated 0 = Is slaves excommunicated?
    has_ceasehostilities 0 = Has Pope told Milan to cease hostilities with slaves?


    Line 7 is for neighbor status
    is_neighbour 1 = Do we share a border with slaves?
    target_weakest_neighbour 0 = Are we the slaves weakest neighbor?
    strongest_neighbour 0 = Are the slaves our strongest neighbor?
    borders_all_our_regions 1 = Do the slaves border all of our regions or groups of regions?


    Line 8 is for win conditions (Kingdoms Only)
    is_faction_to_outlive_target 0 = Is slaves supposed to outlive Milan?
    is_target_faction_to_outlive 0 = Is Milain supposed to outlive slaves?


    Line 9 is misc stuff
    rand 0.572161 = A randomly generated number
    difficulty medium = Setting the player has selected
    turn_number 0 = Turn number
    most_desirable 0 = Is slaves the most desirable target of Milan?
    target_human 0 = Is slaves controlled by the player?
    target_is_shadow 0 = Is slaves the shadow faction of Milan?

    Line 10 is the resulting decisions based on the tree. This one is for the defend_decision but there is a separate entry for invade_decision.
    defend = defend_minimal Milan isnt that worried about slaves invading
    defend_priority = -1 NOT USED
    at_war = 1 Is Milan at war with slaves?
    want_peace = 0 Does Milan want to be at peace with slaves?
    want_ally = 0 Does Milan want to be allies with slaves?
    want_be_protect = 0 Does Milan want to be a protectorate of slaves?
    alliance_against = 0 Does Milan want to have an alliance against slaves?
    pts_alliance = 0 Total points in a cumulative decision about how much we want to ally with slaves.


    The invade section has the same output, except for line 10 which is the decisions on whether or not to invade.
    invade = invade_immediate Invade asap
    invade_priority = 1199 Cumulative number, compare with invade_priority of other factions and invade faction with highest number
    want_offer_protect = 0 Does Milan want to offer slaves protectorate status?
    alliance_against = 0 How much does Milan want to have an alliance against Slaves?
    can_force_invade = 1 Can naval or forced invasion settings overwrite invade parameters
    number of invasion targets: '4 Number of regions that can be invaded


    CA set up all these wonderful conditions, and only uses a fraction of them in the actual decision tree. Looking through the file, less than half of the possible conditions are actually used when making a decision. In fact the defend_decisions are much more complex than the invade decisions, so the AI tends to play a defensive game. We are going to try and change that by setting goals for the AI in a similar way to how a human sets goals.
    Last edited by GrnEyedDvl; June 25, 2012 at 08:19 PM.

  2. #2
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Here I will be compiling a list of invade_decisions and goals to try to implement for the AI. Suggestions are more than welcome.

    Goals:
    Early blitz just like a human player does. First 5-7 turns maybe.
    Last edited by GrnEyedDvl; September 20, 2008 at 03:50 AM.

  3. #3
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Reserved for defend goals.

  4. #4
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Reserved for misc stuff.

  5. #5
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,673

    Default Re: Campaign AI Project

    This thread is a really great idea. I at myself have beginning my session about CAI some days ago, because of the retarded horde-invasion behavior. But in my actually testing about that, seems that the ai_db.xml file, its not the file to work on.
    Look here for stuff about hordes and invasions:
    http://www.twcenter.net/forums/showthread.php?t=184233
    Last edited by Userpro; October 04, 2008 at 04:47 AM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  6. #6
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Campaign AI Project

    Interesting stuff. Out of curiosity, are most of those parameters defined or are the definitions next to the output conjecture based on what they seem to address in the context of where they are in the log? If the former, where is this listed? I can see a lot of them in the .xml files but a few of them looked peculiar on first lookover.

    If you want to put the mod folder with bat/cfg on sendspace that you will be using to do the tests, I'll see about playing along, can't really do anything with my current mod, to alpha.

    Cheers,
    Augustus

  7. #7
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    I am using a Barebones folder, with the campaign_script completely blank right now. I will be updating the first post with any file changes I want people to help test. This will mostly be the AI file but I may script a few events too.

    The definitions I got from the campaign_ai_db file. Some of them are not listed in the M2 file as they only apply to Kingdoms, so you need to get those out of one of the expansion folders.

    An interesting note is that when you totally strip the AI file of any decisions, all decisions become defend_normal and invade_none. I am playing with FoW off and perfect_spy on, and I havent seen an army move yet. Priests and diplomats and merchants still move though.

  8. #8
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Ok here is the first entry to try and get the AI to blitz the slaves.

    Code:
       <decision_entry>
        <!--
         blitz the slave faction for 7 turns
        -->
        <min_entry target_faction="slave"/>
        <max_entry target_faction="slave" turn_number="7"/>
        <faction_attitude invade="invade_immediate" invade_priority="1500" continue="true"/>
       </decision_entry>


    France vs slaves at the end of turn 1:
    Spoiler Alert, click show to read: 
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: decision parameters 'france' (ai_label:default) vs faction 'slave':
    02:26:35.390 [ai.ltgd] [info] <1> military: frontline_balance 29295, military_balance 0.123745, military_balance_plus_enemies 0.123745, alliance_military_balance 0.123745, free_strength_balance 1845
    02:26:35.390 [ai.ltgd] [info] <1> faction standing: faction_standing -1, target_faction_standing 0, global_standing 0, target_global_standing 0
    02:26:35.390 [ai.ltgd] [info] <1> diplomacy: stance AtWar, num_enemies 0, target_num_enemies 17, has_alliance_against 0, num_turns_allied 0, num_turns_ceasefire -1
    02:26:35.390 [ai.ltgd] [info] <1> trusted_allies: trusted_ally 0, trusted_ally_enemy 0, trusted_ally_protectorate 0
    02:26:35.390 [ai.ltgd] [info] <1> protectorate: is_protectorate 0, is_protectorate_of_catholic 0
    02:26:35.390 [ai.ltgd] [info] <1> papal: excommunicated 0, enemy_excommunicated 0, has_ceasehostilities 0
    02:26:35.390 [ai.ltgd] [info] <1> neighbour: is_neighbour 1, target_weakest_neighbour 0, strongest_neighbour 0, borders_all_our_regions 1
    02:26:35.390 [ai.ltgd] [info] <1> win conditions: is_faction_to_outlive_target 0, is_target_faction_to_outlive 0
    02:26:35.390 [ai.ltgd] [info] <1> misc: production_balance 0.133987, target_religion 4, target_faction slave, num_settlements 5
    02:26:35.390 [ai.ltgd] [info] <1> rand 0.425001, difficulty medium, turn_number 0
    02:26:35.390 [ai.ltgd] [info] <1> most_desirable 0, target_human 0, target_is_shadow 0
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: (default) invade decision: invade = invade_none, invade_priority = -1, want_offer_protect = 0, alliance_against = 0, can_force_invade = 1
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: number of invasion targets: '3
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: considering a naval invasion
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 103, rating: 1403
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 102, rating: 754
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 97, rating: 159
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 93, rating: 337
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 80, rating: 477
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 89, rating: 1352
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 85, rating: 1763
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 79, rating: 886
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 73, rating: 1918
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 77, rating: 1637
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 69, rating: 1398
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 103, rating: 1558
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 102, rating: 724
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 97, rating: 394
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 93, rating: 222
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 80, rating: 712
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 89, rating: 1507
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 85, rating: 1653
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 79, rating: 1121
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 73, rating: 1803
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 77, rating: 1887
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: target region for naval invasion: 69, rating: 1648
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: naval invasion planned, from province 60 to province 73 (rating 1918).
    02:26:35.390 [ai.ltgd] [info] <1> LTGD: invasions cancelled this turn.


    Note a few things here. First is num_settlements 5, this is how many slave regions border on France. You can see them in this image, they are:

    Zaragoza region 73
    Bordeaux region 85
    Dijon region 52
    Metz region 36
    Bruges region 34




    number of invasion targets: '3
    I am not sure why it selected 3 targets. I suspect it weighed the strength of each region against the strength of Frances armies, applied a random number and decided that 3 of the 5 regions are valid targets.

    Then it runs through possible naval invasions for 22 regions. I have no idea why it selected 22, there are certainly more than 22 slave regions. Probably there is a distance modifier or something like that.

    It assigned a rating to each of those 22 regions, and picked the highest one for invasion. This is probably based on distance and strength factors. It should be noted that France does not have any ships at this time but decided on a naval invasion anyways.

    naval invasion planned, from province 60 to province 73 (rating 1918).
    Province 60 is Toulouse, the only region that France has a port in to construct ships. Province 73 is Zaragoza, which borders on Toulouse so a land invasion is also possible. It should also be noted that descr_sm_factions the prefers_naval_invasions parameter is set to no for France. Again I have no idea why it picked a naval invasion over a land invasion from regions that border each other, especially when France has no navy. We will see if France builds a navy and sends it there, or it another decision is reached before that happens.

    At the end of the next turn, there are no ships for France, and cogs take only 1 turn to build. The log entry is nearly identical, except the rating for the invasion has changed to 1921. I played all the way past turn 7 which is my max_entry, and still no ships and no invasions.

  9. #9

    Default Re: Campaign AI Project

    keep it coming GED, this are very useful informations.

    TTW GRANDMASTER

  10. #10
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Bumping France's money up to 50k at the start of the game does not work, neither does the entry force_invade = true, for some reason most factions have that "invasions canceled for this turn" line, some do not but I am not seeing the invasions actually happen.

    Code:
       <decision_entry>
        <!--
         blitz the slave faction for 7 turns
        -->
        <min_entry target_faction="slave"/>
        <max_entry target_faction="slave" turn_number="7"/>
        <faction_attitude invade="invade_immediate" invade_priority="1500" force_invade="true"/>
       </decision_entry>

    Looking through the Crusades AI file, there are several entries that it seems are designed to do something similar to what I want, though they have it capped at 30 turns. Pasting those into my blank file produced slightly better resulta. By turn 24 the Turks and Moors had conquered 1 settlement each, Sicily had conquered 2. Better but not nearly good enough. I currently have no defend_decisions so it defaults to defend_normal. With France I can see armies moving around, merging and splitting, and even moving into slave territory, but they never attacked.

    The number of regions owned at the start of the game, I am playing as England so there will be no change there:
    England 3
    France 5
    HRE 6
    Spain 2
    Venice 3
    Sicily 2
    Milan 2
    Scotland 1
    Byzantium 5
    Russia 1
    Moors 4
    Turks 4
    Egypt 3
    Denmark 1
    Portugal 2
    Poland 2
    Hungary 2
    Papal States 1

    I created an entry for defend_minimal against slaves, and bumped the invasion_priority to a minimum of 1200. With the new entries. I played until turn 30:
    Hungary took a region in turn 2
    Sicily took a region in turn 4
    Hungary took a region in turn 4, they have taken 2
    France took a region in turn 12
    HRE took a region in turn 13
    Venice took a region in turn 14
    In turn 16 a Crusade was called which might screw with some things as none of the factions have the catholic AI label.
    HRE took a region in turn 17, they have now taken 2
    Poland took a region in turn 18
    Denmark took a region in turn 21, they now have 3, I didnt catch when they took the 2nd
    Denmark took a region in turn 28, they now have taken 3
    Russia took a region in turn 28
    Poland took a region in turn 28
    Byzantium took a region in turn 28
    Russia took a region in turn 29, they have now taken 2

    As you can see there are more being taken towards the end of the 30 turns than there are in the beginning. I suspect part of this is how long it takes to build armies and then move them. But several factions never took a region at all.


    England:
    I played as England, so no changes are possible.

    Moors:
    In the north they border Spain and Portugal, so nowhere to go. They do border the slave region Valencia, and actually have an army with 16 units right on the border in position to attack. Valencia has a pretty strong garrison, 9 units, so it took some time to build up enough to take it. Spain actually has a 6 unit army inside Valencia and a 5 unit army on the border between Toledo and Valencia. To the south they have two HUGE regions owned by the slaves. They have sent a 3 unit army to Timbuktu, but its barely across the border.

    Portugal:
    Only has two regions, and one of them does not border the slaves. They have an army besieging Zaragoza, and the walls are damaged which means someone has attacked recently but didnt win the battle. They may not win this one either as its 4 units vs 4 units.

    Spain:
    Borders the Moors to the south. They share 2 borders with the slaves, and they have armies in both regions. A stack of 9 units just outside Zaragoza which is currently besieged by Portugal, and a stack of 6 inside Valencia which will never be able to take that city.

    France:
    I dont get this at all. I actually bumped their money up to 100k to start. They have taken Metz, but done nothing else. They have two full stacks plus a few smaller armies standing around Toulouse, and another full stack outside Angiers. They could easily take Rennes, Bordeaux, and Zaragosa. Outside of Metz there are several small armies that would make a stack of 14 units if combined, which could easily take Dijon to the south.

    Scotland:
    I dont think they ever moved out of Edinburgh, though they do have a total of 21 units split among 4 armies. Inverness to the north is fairly strong at the start of the game, as is Dublin to the east. York they probably could have taken.

    HRE:
    They took 2 settlements and only have two other slave settlements they share borders with, Prague and Bern. They have a stack of 7 units inside Bern but will never take that castle with that army. On the border between Vienna and Prague they have a full stack, and another stack of 18 on the border of Magdeburg and Prague. It looks like they will be taking Prague soon.

    Denmark:
    They actually took 3 regions, Hamburg, Stettin, and Thorn. The difference between Denmark and most of the other factions is they start with 1 region but have a decent army. It looks like they might have attacked Antwerp and failed as the units there are not full strength, but that might have been France as well.

    Poland:
    They took Breslau, but it looks like doing so decimated their army. They have only 7 units on the entire eastern side of their empire, and most of them are below half strength. They have a stack of 8 units on the border of Krakow and Thorn that has also taken some losses. I would guess they attacked Thorn and failed, and then Denmark took it instead. They have 9 units spread among 3 armies between Halych and Kiev, but most of them are down to about 20 men per unit. Kievs units have taken a few losses as well, so I would say they attacked and failed. They also have a stack of 3 units outside of Iasi, and the walls of Iasi are damaged.

    Hungary:
    Has taken 1 region, and has a full stack outside their settlement of Bran. This army can go either north to Iasi or south to Sofia. They have a stack of 4 units that have taken damage between Sofia and Bran, and the walls of Sofia are damaged, I would say they attacked and failed. They have a half stack outside Budapest that could easily go into Prague.

    Venice:
    Has taken 1 region, and has a stack of 4 units inside Sofia which has damaged walls and units. I still dont think they can take it. They have a stack of 19 outside Ragusa which they own at the start of the game. The only possible destination for that army is Sofia. Oddly they also have a single damaged unit outside Tripoli and I have no idea how or when it got there.

    Sicily:
    Took Tunis in turn 4, and has two navies off the coast of cagliari, one has no army, the other has 3 units. The walls of Cagliari are damaged and so are all the units. I would say they attacked and failed.

    Byzantium:
    Took Trebizond in turn 28, but has not repaired antyhing yet. To the south is Smyrna, which has damaged walls and units and two stacks of 3 Byzantine units that are damaged. they attacked and failed. They have 7 small armies inside of Thessalonica and Constantinople that could easily move into Sofia. They might even beat Venice to it.

    Turks:
    They have an army of 5 damaged units near Terbizond, I would say they attacked and failed and then Byzantium took it. To the south Adana has damaged walls and units but they have another stack of 8 units close. They also have a stack of 9 units between Yerevan and Tblisi. Edessa and Baghdad are both too strong for them to take. A subnote here, there is a crusading Polish army close to Adana as well headed for Cairo. When I said their armies were decimated earlier I did not know this army existed.

    Egypt:
    They have a stack of 3 units outside of Dongola, but they will never take that settlement. They have a stack of 15 damaged units inside Gaza, and the walls and units of Jerusalem are damaged. I would say they attacked and failed, and are moving those units to Cairo to defend against the Crusade.

    Russia:
    Has taken 2 regions, and has a stack of 5 damaged units between Novgorod and Helsinki, and the walls of Helsinki are damaged. They attacked and failed. They have a stack of 18 units near Ryazan and will probably take that city in 2 or 3 turns.

    Initial Conclusions:
    Tweaking the vanilla AI files has helped, but not enough. There were a total of 15 regions taken by AI factions over 30 turns, and another 10 attacks that failed. Over 30 turns the average human player is orobably going to take 5 or 6 settlements, maybe even more. This will give the player a huge advantage over the AI as he will have more resources at his disposal. I can probably bump the invade_priority from 1200 to 1500 and get a few more invasions out of it, but there is certainly no gaurantee of that, nor can I gaurantee the AI will take the settlements if they do attack. There are also many regions I do not think were explored enough for the AI to even know if it had a chance of winning a battle there.

    Possible solutions:
    Go ahead and bump invade_priority to 1500.
    Use my AISightBonus script to give all AI characters a +5 LineOfSight.
    Break some of the huge regions up into smaller regions.
    Place watchtowers in various spots around the map. I cant do this by script so I would rather not as the player will get the same advantage as the AI.
    Give all AI generals a new trait, Combat_V_Slave +10 so they win a few more of these battles.
    Make all slave settlements really weak in descr_strat, then spawn units in them via script at the start of the game depending on which faction the player selects. This way we can have weak slaves near the AI and strong slaves near the player.
    Give the AI more money, they can always use it.
    Spawn AI armies via script at the end of turn 1. This should reduce the buildup time.

    I will attach the current AI file to the first post.

  11. #11
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Campaign AI Project

    Interesting observations. It definitely seems like the AI are having a sweet spot problem. When you have a number like 7 and the AI comes back as determining the slave regions to strong, it will probably result in them not launching attacks. When you have 30 turns, it's possible that by the time the AI has developed they have other decisions which out-prioritize the decision to attack the slaves based on their level of development. The force invade parameter seems to be entirely ineffective.

    Something I have noticed one time when I let the AI manage all of my settlements in a Turn 130 Portugese campaign, is that the AI decisions can wreck a player economy extremely quickly. I was pulling in 200k solid with improvements everywhere as they popped up and three standing armies. Ten turns later I was almost in the red without much more to show for it and having lost a few regions.

    The biggest culprit is the AI affinity with building a lot of ships. The upkeep on the ships when the AI decided it needed three full stack ship fleets pretty much singlehandedly destroys the economy. This is then coupled with the AI deciding it needs artillery in every settlement and an overabundance of garrison. If the actual AI are performing these things, then it is not any wonder they don't have the money to finance an actual invasion.

    One idea just out of the blue, is scripting a removal of the ship production pool after the ships an AI faction owns reach a certain amount, and refunding them the upkeep costs. Not sure about implementation, just throwing it out there before I hit the snooze, will try and explore it more tomorrow.

    Cheers,
    Augustus

  12. #12
    Lusted's Avatar Look to the stars
    Join Date
    Jan 2005
    Location
    Brighton, Sussex, England.
    Posts
    18,183
    Creator of:
    Lands to Conquer Gold for Medieval II: Kingdoms
    Terrae Expugnandae Gold Open Beta for RTW 1.5
    Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
    Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
    Awarded the Rank of Divus for oustanding work during my times as Administrator.

  13. #13

    Default Re: Campaign AI Project

    GrnEyedDvl could you modify the AI so that it will just garrison its settlements and not send soldiers out for any reason? While this would prevent the AI expanding it would also prevent the player blitzing the AI and make siege battles more difficult.

    Once the AI could properly garrison its settlements attack commands could be added.
    Morning Sun (adds Korea and China to the Shogun 2 map)
    http://www.twcenter.net/forums/forum...28-Morning-Sun

    Expanded Japan mod (97 new regions and 101 new factions)
    http://www.twcenter.net/forums/showt...ew-factions%29

    How to split a region in TWS2
    http://www.twcenter.net/forums/showt...split-a-region

    Eras Total Conquest 2.3 (12 campaigns from 970-1547)

  14. #14

    Default Re: Campaign AI Project

    Nice idea, Good luck with it man!

  15. #15
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    quick question re invade decisions:

    does the AI calculate the distance in MPs?

    If so is there a way of seeing if (for example) the Toulouse - Zaragoza invasion decision by sea is down to it being fewer MPs than overland?

    Re The fact that France doesn't seem keen to invade Rennes (although in other CAIs it seems happy to do so) down to its faction standing with England and therefore decides to defend against possible attack from Caen, rather than risk sending an army to Rennes? (ditto Bruges?)

  16. #16

    Default Re: Campaign AI Project

    GrnEyedDvl
    Wish I spotted this earlier as I have just done all this and could of saved you some time.

    Couple of things
    borders_all_our_regions: seems to be the opposite of what you imagine. I noticed that France gets this for England at the start because it (France) bordered all the land regions of Caen

    want_ally: If you want to stop an alliance happening it must be true on BOTH sides of the Ai, so for instance you can set it so that the Ai will not want to ally with the Human player, but it still will still happen (eg Human France can ally with Ai England), so I believe you need a FactionIsLocal Ai set up.

    The idea of processing things by faction may be quicker, but is daft, as the order of process thereby matters. eg Faction A has a region bordered by an enemy, a human and a slave faction. It processes its defend decisions and gets three different results for how to defend ALL regions, the last of which is Slave, which generally is defend_minimum.

    The map and pathfinding has a huge influence on how the Ai carries out its attacks, as does settlement mechanics.

    What most people do is place all the diplomacy decisions in defend or invade, but I believe they are better split, so that you only use entries which are found in each section ie if want_peace is only found in defend section, it should only be placed there and not in the invasion section.

    Another think is to change the win conditions, as the Ai seems to use these in determining whether to consider taking back a settlement.


    Luck

    To err is human, but to really foul things up you need a computer.
    Paul Ehrlich

  17. #17
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Thanks Lusted, Quark, and everyone else. I have read some of those before, but not all. As CavalryCmdr says in his posts, I completely disagree with how CA used the AI file. For starters they set up for the AI to be defensive in nature.

    Lusted,
    I actually have a copy of your AI files that I will be looking at after I do some testing of my own. I have heard they are pretty good. No offense, but my goal here is to outperform them

    Quark,
    I mostly agree with your assertion about how the AI file is used regarding attack/defend decisions. Because this is an xml file, and therefore extensible by definition, I should be able to do some more creative things with it.



    Rozanov
    Re The fact that France doesn't seem keen to invade Rennes (although in other CAIs it seems happy to do so) down to its faction standing with England and therefore decides to defend against possible attack from Caen, rather than risk sending an army to Rennes? (ditto Bruges?)
    While anything is possible, the are NO Ai entries in my file for anything other than the slave faction, so in essense the AI shouldnt even "think" about other factions. This is as stripped as it can get.


    I am going to do things in baby steps here. I realize that movement and settings in other files can have a drastic effect on how the AI behaves. But for now I am dealing strictly with the AI file. Once I feel that I have taken it as far as I can take it for a particular scenario, I will use that as a baseline and start tweaking other files and see what happens. The problem with the way most people test is that there are far too many variables to account for them all and know exactly what happened. If I can remove most of those variables and get to as base a decision as possible, I think I can do some cool stuff.


    Lusted I know you cant talk about dev stuff for Empire, but I hope you made some suggestions in the AI area.

  18. #18
    Lusted's Avatar Look to the stars
    Join Date
    Jan 2005
    Location
    Brighton, Sussex, England.
    Posts
    18,183

    Default Re: Campaign AI Project

    Lusted,
    I actually have a copy of your AI files that I will be looking at after I do some testing of my own. I have heard they are pretty good. No offense, but my goal here is to outperform them
    None taken, I'm fully aware of the problems with my AI and the areas it could be improved in.

    Lusted I know you cant talk about dev stuff for Empire, but I hope you made some suggestions in the AI area.
    I sit next to the campaign AI programmers so I talk to them about it every now and then, I also help design/test the battle AI.
    Creator of:
    Lands to Conquer Gold for Medieval II: Kingdoms
    Terrae Expugnandae Gold Open Beta for RTW 1.5
    Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
    Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
    Awarded the Rank of Divus for oustanding work during my times as Administrator.

  19. #19
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Tell them there need to be more conditions, and that you need to be able to set real goals. I could write a book on this lol but for starters the AI needs to have specific goals, not generic goals, and they need to be done in stages, baby steps.

    Goal in win_conditions = Outlive England - Long Term Static Goal 1

    Ok so what needs to take place for that to happen. England needs to lose control of SettlementX, SettlementY, and SettlementZ. Which ones of these border us? How strong are they? Who are Englands enemies? Who are their allies?

    At some point it needs to "decide" that it wants SettlementX, as part of its Long Term Static Goal. This becomes Long Term Strategic Goal 1_1.

    Compare all Long Term Strategic Goals for chance of success. Boost chances for as many goals as possible every single turn. Hire a unit here, build a building there, recruit a merc over there. Dont concentrate on a single decision at a time the way its currently done, at turn end. Process every goal every turn.

    Then it also needs Short Term Strategic Goals. Economy less than X new goal to boost economy. Do this through another decision tree for each goal, processed per goal. I doubt if the current engine "knows" that it will be able to build a bank when it reaches settlement size X and has building Y. It seems to clear all variables every turn and process an entirely new decision. There is no "memory" of past decisions.

    Probably more than you wanted to hear, but if you decide you want to hear more let me know lol

  20. #20
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Ok a few changes. I bumped the invade priority from 1200 to 1500 when AI has a 2:1 ratio against slaves.

    I gave a +5 LineOfSight to all AI characters.

    I actually had a few more attacks, but not as many successful ones. I had 13 AI victories, where before I had 15. I think there is some randomness built into the auto-resolve that can account for that.

    But I had another 16 or so attacks that failed, at least there were 16 damaged slave settlements I found by scrolling around the map ane looking. So about 7-8 more attacks total. Decent.

    Along with the AI sight bonus, I then added a +10 Combat vs Slave bonus, and ended up with similar results. The AI doesnt always attack with generals and you cannot give bonuses to captains. We need to get the AI more victories over the slaves.

    So I added a few lines to the slave decision tree, when player_human = true they will defend_deep, and when player_human = false they will defend_minimal. This helped a bit, and got me 16 victories, and another 20 attacks.

    Going into descr_strat I set the slave kings_purse at 0, and bumped all the other factions to at least 2500. This got me 19 AI victories in 30 turns. Here are the list of factions and which turn they took a settlement in.

    poland 2
    hre 3
    venice 4
    sicily 4
    poland 7
    hre 8
    russia 8
    venice 8
    milan 9
    russia 9
    hre 10
    egypt 14
    sicily 16
    poland 17
    sicily 18
    spain 22
    hungary 24
    byzantine 26
    egypt 30

    Hre, Sicily, Egypt, and Poland all had more than 1, and every faction except Scotland made an attempt. Milan actually took Djon after the French failed, and the HRE took two settlements that failed to take. There are many damaged settlements, I quit counting at 25, and several more that are under siege or have armies in the region. I am going to play these settings several more times, as various factions, and see how it goes. I may need to bump faction incomes a bit for the weaker factions like Denmark and Scotland, but not just yet.

    Here is the starting positions of each faction followed by the positions at the end of turn 30:




    Current AI file is attached.
    Last edited by GrnEyedDvl; June 25, 2012 at 08:19 PM.

Page 1 of 5 12345 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
  •