Results 1 to 19 of 19

Thread: can_force_invade = false vs true

  1. #1
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default can_force_invade = false vs true

    I tried it with on and off (ordered or cancelled invasions from within the exe), from memory, it increases the naval invasions. However, today, I noticed markedly different behavior during a test using invade_opportunistic with "can_force_invade" set to false, for that decision.


    I'm curious what other peoples experiences are with this setting as false or true. I noticed XAI used to always set theirs to false, but I never really believed it to be a great idea, now, I feel like it may very well have a good purpose.
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  2. #2

    Default Re: can_force_invade = false vs true

    However, today, I noticed markedly different behavior during a test using invade_opportunistic with "can_force_invade" set to false, for that decision
    This sound like the way its done also in PiterAI.. I was trying to set force_invade true for non-neighbours thinking that it will make naval invasions used more, but I was not successful, in the end I don't understand how this thing works. Maybe works differently with different invade options?

  3. #3
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: can_force_invade = false vs true

    I mean specifically, can_force_invade. Not force_invade. I am not certain what force_invade does specifically, I never noticed as much of an effect; although my early versions prolifically used that for invade_immediate decisions.

    If you want more naval invasions, first set sm_factions to prefer naval invasions, then set invade_immediate, invade_buildup or invade_opportunistic (can be good as invade priority seems to be ignored) as the invade decision and set can_force_invade = true. Those are the main things to encourage more of those.

    But, after some thought today, I believe you only need naval invasions enabled like that for specific factions which need it (e.g. England or whatever island faction you have in your mod). So making a faction AI label specific to England with can_force_invade enabled, and then assigning it in the descr_strat or dynamically via the campaign script; would be better.
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  4. #4
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    I'm using it when I want no interactions between factions. Or when faction is dead and should be excluded from calculations.

    I'd like to see more details about your experience from invade_opportunistic and "false" can_force_invade.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  5. #5
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: can_force_invade = false vs true

    What I observed with invade opportunistic is a very large amount of activity when can_force_invade is false. Settlements were taken significantly more rapidly.

    However, I did not see a single naval invasion. None of my factions usual naval invasion targets (crete, normandy, and cyrene), were invaded.
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  6. #6

    Default Re: can_force_invade = false vs true

    I only use force invade against factions that have no borders to allow naval invasion, and disable it entirely for factions that don't have access to ships. I suspect it ignores the parameters for minimum attack strength from the campaign xml which leads to worse AI performance overall if left on. All this is from observation though and this is hard to quantify so don't take my word for it. One thing you should be aware of is that if force invade is disabled then scripted attacks break, the armies that are told to attack won't commit to it, so you should temporarily turn force invade on if you have a scripted attack on the turns it's happening.

  7. #7
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: can_force_invade = false vs true

    Quote Originally Posted by Fynn Total War View Post
    I only use force invade against factions that have no borders to allow naval invasion, and disable it entirely for factions that don't have access to ships. I suspect it ignores the parameters for minimum attack strength from the campaign xml which leads to worse AI performance overall if left on. All this is from observation though and this is hard to quantify so don't take my word for it. One thing you should be aware of is that if force invade is disabled then scripted attacks break, the armies that are told to attack won't commit to it, so you should temporarily turn force invade on if you have a scripted attack on the turns it's happening.
    Interesting thanks for sharing. Are you referring broadly to can_force_invade, or force_invade and can_force_invade?
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  8. #8

    Default Re: can_force_invade = false vs true

    Quote Originally Posted by z3n View Post
    Interesting thanks for sharing. Are you referring broadly to can_force_invade, or force_invade and can_force_invade?
    I was referring to can_force_invade

  9. #9

    Default Re: can_force_invade = false vs true

    I know a lot has been changed since I did most of my research (way back in v1.2 without kingdoms) but in my experience invade_opportunistic ignores all invade settings except naval invasions if can_force_invade=false. This only seems to apply to direct naval invasions, a great feature of invade_opportunistic is it's the best way to get the AI to utilize mercenaries, I have seen the AI move a general by ship to recruit mercenaries then attack with that army, even with only naval options available to reach the target from any of their regions. It doesn't happen often though I can only assume it's not considered a "naval invasion" because the army didn't have to board a ship to reach the target so can_force_invade=false doesn't stop it.

    Yes, can_force_invade=false does force the AI to obey the invade rules as set which results in better built and utilized frontline armies, however it does limit it's options, personally I don't use it for that reason. For example, if I'm England and at war with France, can_force_invade=false means I'll be fighting stronger armies on the front, can_force_invade=true means France might launch a surprise attack at Whales (for example, because it's happened). This is better, in my opinion, because I can win any battle I'm even remotely prepared for, winning a battle when all I have to work with is a couple militia units is much harder, even against a sub-optimal army. The general principle holds true for AI vs AI, so with this example only with AI England, England is still in a worse situation since France now has a foothold in the British Isles. Still, I do use can_force_invade=false when an AI faction is particularly weak (3 or fewer settlements and is_neighbour in this case) thus had limited option anyway, so using those fewer options better is defiantly preferable.

    Personally I don't like using faction-specific AI's, except some diplomacy settings, for example, England is less likely to ally with France, but will if other factors are great enough. This is, again, because of limiting options available. Let's say England takes over France, but Scotland takes over the British Isles, a short time later England is at war with the HRE, but still fighting like it's an island nation, you basically just crippled this mainland England faction. Or the other way around, France takes the British Isles but looses it's regions in mainland Europe, you now have an island nation trying to fight like a mainland nation. I suppose a good workaround would be to set an AI that is optimal for a faction's starting situation, then change it to a more generalist approach after say 20 or 40 turns, which can either be done within that factions ai_db or with a scripts changing the AI it uses, but I'm too lazy to do that.
    Last edited by CavalryCmdr; March 06, 2023 at 04:16 PM.

  10. #10
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    Thanks in advance, I'll try to fix my CAI for Ironborn with this knowledge.

    It's not so difficult to link between CAI's for one faction as you described. I already did some minor script for linking between regular ai_personality and Crusade one. Also if faction grows bigger I change previous personatity to Empire personality, and back.

    also I have an idea to change personatily every time after FL changed according to his Attributes, and change after he become senile.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  11. #11

    Default Re: can_force_invade = false vs true

    Quote Originally Posted by bitterhowl View Post
    I have an idea to change personatily every time after FL changed according to his Attributes, and change after he become senile.
    Yes, I had intended to do this as new faction leader has a pretty sizeable impact in my mod. Unfortunately, to sound a little repetitive, I'm too lazy to do that. Actually, what happens is I get working on it, then I get distracted when an idea hits that I think might make the base AI better and I end up working on that instead, and think to myself "I'll do it once I get my base AI how I like it" then rinse and repeat. But yes, love the idea.

    A though has occurred to me, I wonder if it might be beneficial to count the number of ports a faction has, then link an AI to that count. So if a faction has say, more than four ports, we'd want to switch to a more seafaring AI, or maybe compare ports to total settlement count.

  12. #12
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    Interesting idea.

    It's offtop here, but just yesterday I thought about index that marks player's recruitment policy to hint AI how to combine armies more complementary.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  13. #13

    Default Re: can_force_invade = false vs true

    If you can manage to make that work it could be revolutionary, though as far as I know it's not possible to influence AI army composition that much.

  14. #14
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    It's absolutely possible, since there's functional negative values of unit pool replenishment in EDB.

    There's a rough way that I use now to limit low tier units via event counter that switch off recruitment for that units for AI (enabling only for 4-5 turns after war declared to simulate people's militia gathering).

    Smoother way is to have negative value's recruit pools that activated by event counter firing after conditions match - if player has cavalry then we prolonging archers recruitment and fastening spearmen. Just as a concert, I meet this idea just yesterday evening.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  15. #15

    Default Re: can_force_invade = false vs true

    Brilliant workaround, that just leaves script length, but that shouldn't cause much trouble with modern machines. Definitely interested in seeing how that works out.

  16. #16
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    I don't think it will be a big script. Just checking if AI is at war with player (I already have this part for another purpose) and also count recruited category and class unit by player and compare amount between them.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  17. #17
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    So, if we speak about invade_opportunistic - this is the common issue for vanilla CAI, the last block for AtWar stance. So opportunistic is default mode for AI at war.

    <decision_entry>
    <!--
    if we're at war,
    then >>> invade opportunistic
    -->
    <min_entry stance="AtWar"/>
    <faction_attitude invade="invade_opportunistic" invade_priority="550" alliance_against="8"/>
    </decision_entry>
    Since opportunistic is rather aggressive, is it optimal for "default" mode? Maybe we should set to invade_start? Or even invade_none?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  18. #18

    Default Re: can_force_invade = false vs true

    Basically anything would be better than invade_opportunistic.

    I personally lean towards invade_none as this allows for the AI to focus more on other actual invade decisions. Also the more invade_none decisions the more the AI will put into developing non military focused aspects of their regions, since invade_anything that isn't none tells the AI it needs more military strength in this area.


    Sorry, misread that, invade_opportunistic when at war is fine for a default. I would assume there are earlier entries for the other invade options, there's nothing wrong with aggressive when you're already at war and can't think of anything else to do. Honestly opportunistic is probably ideal for default. It definately should not be the default when you're not already at war.
    Last edited by CavalryCmdr; March 22, 2023 at 06:11 AM. Reason: read wrong

  19. #19
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: can_force_invade = false vs true

    Quote Originally Posted by CavalryCmdr View Post
    Brilliant workaround, that just leaves script length, but that shouldn't cause much trouble with modern machines. Definitely interested in seeing how that works out.
    Ok, so I've composed a draft, it's really not so big script.

    First we have to see when AI faction is at war with player. We check player's stance with every faction, here's an example for spain (one need to clone it for all factions in the game)
    Code:
    declare_counter faction_wars
    declare_counter spain_war
    
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    and not DiplomaticStanceFromFaction spain = AtWar
       and I_CompareCounter spain_war = 1
       set_counter spain_war 0
       inc_counter faction_wars -1
    end_monitor
       
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    and DiplomaticStanceFromFaction spain = AtWar
       and I_CompareCounter spain_war = 0
       set_counter spain_war 1
       inc_counter faction_wars 1
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType spain
    and IsFactionAIControlled
    and I_CompareCounter spain_war = 1
    set_event_counter at_war_with_player 1
    end_monitor
    
    monitor_event FactionTurnEnd FactionType spain
    and IsFactionAIControlled
    and I_EventCounter at_war_with_player = 1
    set_event_counter at_war_with_player 0
    end_monitor
    If we're at war with spain then during spain turn we set event_counter which marks war with player to 1. We need it for EDB.

    Second part is about matching player's recruitment activity
    Code:
    monitor_event UnitTrained FactionIsLocal
        and ! TrainedUnitClass heavy
        and ! TrainedUnitClass light
        and ! TrainedUnitClass spearmen
        and TrainedUnitCategory cavalry
    
        inc_counter hired_missile_cav 1
        inc_counter hired_ranged 1
    
    end_monitor
    
    monitor_event UnitTrained FactionIsLocal
        and ! TrainedUnitClass heavy
        and ! TrainedUnitClass light
        and ! TrainedUnitClass spearmen
        and TrainedUnitCategory infantry
    
        inc_counter hired_ranged 1
    
    end_monitor
    
    
    monitor_event UnitTrained FactionIsLocal
        and TrainedUnitClass missile
        and TrainedUnitCategory siege
    
        inc_counter hired_ranged 1
    
    end_monitor
    
    
    monitor_event UnitTrained FactionIsLocal
        and ! TrainedUnitClass missile
        and ! TrainedUnitClass spearmen
        and ! TrainedUnitClass skirmish
        and TrainedUnitCategory infantry
    
        inc_counter hired_melee 1
    
    end_monitor
    
    monitor_event UnitTrained FactionIsLocal
            and TrainedUnitClass spearmen
            and TrainedUnitCategory infantry
        inc_counter hired_spearmen 1
    
    end_monitor
    
    
    monitor_event UnitTrained FactionIsLocal
        and ! TrainedUnitClass missile
        and ! TrainedUnitClass skirmish
        and TrainedUnitCategory cavalry
    
        inc_counter hired_cavalry 1
    
    end_monitor
    
    monitor_event FactionTurnEnd FactionType slave
    inc_counter recruitment_monitor 1
    if I_CompareCounter recruitment_monitor < 25
        if I_CompareCounter hired_cavalry > 10
        set_event_counter hired_cavalry 1
        end_if
        if I_CompareCounter hired_melee > 20
        set_event_counter hired_melee 1
        end_if
        if I_CompareCounter hired_missile_cav > 10
        set_event_counter hired_missile_cav 1
        end_if
        if I_CompareCounter hired_ranged > 15
        set_event_counter hired_ranged 1
        end_if
        if I_CompareCounter hired_spearmen > 20
        set_event_counter hired_spearmen 1
        end_if
    end_if
    if I_CompareCounter recruitment_monitor = 25
    set_counter recruitment_monitor 0
    set_event_counter hired_cavalry 0
    set_event_counter hired_melee 0
    set_event_counter hired_missile_cav 0
    set_event_counter hired_ranged 0
    set_event_counter hired_spearmen 0
        if I_CompareCounter hired_cavalry > 20
        set_counter hired_cavalry 5
        
        end_if
        if I_CompareCounter hired_cavalry < 21
        set_counter hired_cavalry 0
        end_if
        if I_CompareCounter hired_melee > 25
        set_counter hired_cavalry 5
        end_if
        if I_CompareCounter hired_melee < 26
        set_counter hired_cavalry 0
        end_if
        if I_CompareCounter hired_missile_cav > 10
        set_counter hired_cavalry 5
        end_if
        if I_CompareCounter hired_missile_cav < 11
        set_counter hired_cavalry 0
        end_if
        if I_CompareCounter hired_ranged > 25
        set_counter hired_cavalry 5
        end_if
        if I_CompareCounter hired_ranged < 26
        set_counter hired_cavalry 0
        end_if
        if I_CompareCounter hired_spearmen > 15
        set_counter hired_cavalry 5
        end_if
        if I_CompareCounter hired_spearmen < 16
        set_counter hired_cavalry 0
        end_if
    end_if
    end_monitor
    I see if player hires melee/ranged/spearmen/cavalry/missile cavalry (quantities I set for first time, need proper testing), and if player has enough units of missile (more than 15) then I set event_counter that says to AI that player has many missile units (set_event_counter hired_ranged 1). This event counter in combination with at_war_with_player 1 set for negative recruit pool for melee infantry/spearmen and with additional speed recruit pool for light cavalry/missile cavalry will give effect that AI will correct it's reruitment policy according to player's one.
    Last edited by bitterhowl; March 22, 2023 at 07:09 AM.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

Posting Permissions

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