Page 3 of 11 FirstFirst 1234567891011 LastLast
Results 41 to 60 of 204

Thread: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

  1. #41

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    z3n is correct in that the AI dose not drastically change it's first few moves without major changes, most generally in campaign_ai_db or desc_strat, it just doesn't.

    Given this behavior difference I would assume his campaign_ai_db dose not specify actions against the 'slave' faction, and instead just assumes they will be at war, so by being Neutral instead the AI is moving on to it's next target. If that's the case, the errors in the script are unimportant as it still proves the LTGD was re-evaluated and that forcing the re-evaluation at CharacterTurnEnd would indeed get the desired results.

    However, if that is not the case with the campaign_ai_db, I think he may have just proven Gigantus' concern that rapidly changing the game state in that manner will confuse the heck out of the AI.
    Last edited by CavalryCmdr; February 10, 2016 at 11:35 PM.

  2. #42
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Quote Originally Posted by CavalryCmdr View Post
    forcing the re-evaluation at CharacterTurnEnd
    I'm not sure I'm following all of this but just to be clear: I'm saying that z3n's latest script is not doing that.

  3. #43

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Thought of another possibility, the script is failing altogether and there is something else that would normally be in the script (such as spawned armies) that changes the starting game state enough to account for the change in behavior.

    @Withwnar ; sorry I did misread you're comment, had characterturnstart in my head so didn't register campaign start. So this test did no good regardless of the cause since they were already neutral when the AI initially did it's LTGD evaluation.
    Last edited by CavalryCmdr; February 11, 2016 at 12:14 AM.

  4. #44
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Wrote this over the course of the hours I tested after getting back.

    The log actually complained about the opposite hence the reason for changing it in the first place. It was saying monitor_event in conjunction with RemainingMPPercenatge was a parsing error but it doesn't with monitor_conditions. I assume this is because its a condition, not an event hence using it with an event is incorrect? Of course I am not very good at campaign scripting.

    ...which is wrong too, missing the FactionType condition. So this will instead execute on every faction's FactionTurnEnd, resetting the counter, thus allowing those three stance changes to happen again on each faction's turn end.
    Also amusingly enough that's exactly what I would like.

    AI LTGD is working I forgot to put this part in

    [ai]
    ltgd_logging = true

    In any case, further test results in a couple of different ways (so as to circumvent the AI LTGD being loaded >before< FactionTurnStart according to the logs I've read), however you were right about CharacterTurnStart/CharacterTurnEnd being executed before the AI LTGD, the change in screenshots stemmed from the LTGD reading AtWar for the first (without the script) and Neutral for the second with the script. Not an active reevaluation- rather a simple evaluation based on a change beforehand.

    What that means is that there isn't a way (yet) to get it working exactly how we want it. I am testing something further now based on the above information.

    I tried a couple different scripts, doesn't really seem to be any form that gets exactly what we want.
    It would seem the console_command for diplomatic changes won't cause a reevaluation unless it is before the LTGD evaluates the descr campaign ai db decisions, only a deliberate AI overture seems to make the AI re evaluate things. This might be some sort of safeguard or simply the way the LTGD was coded, to look for a very specific diplomatic interaction involving the exe, rather than console_commands.

    Notwithstanding the fact that the stance will be interpreted by the LTGD regardless of whether it was a console command or game driven change. I have a feeling it's because of something I only just seem to have understood about the LTGD and how things are re-evaluated...

    There is a "parent" LTGD evaluation and a "child" re-evaluation.

    Note this

    1 = Carthage
    20 = Numidia

    It was Carthages turn, they initiated a diplomatic interaction with Numidia, presumably trade rights.

    Code:
    01:04:17.785 [ai.ltgd] [info] <1> LTGD: invasions cancelled this turn.
    01:04:17.785 [ai.ltgd] [info] <20> LTGD: decision parameters 'f_numidia' (ai_label:f_numidia) vs faction 'f_rome':


    Compared to this (0 = rome)

    Code:
    01:04:18.402 [ai.ltgd] [info] <0> LTGD: invasions cancelled this turn.
    01:04:18.403 [game.script] [always] f_rome: Faction turn start
    01:04:18.684 [game.script] [always] f_rome: Faction turn end
    01:04:18.685 [game.script] [always] f_epeiros: Faction turn pre-start
    01:04:18.726 [ai.ltgd] [info] <3> LTGD: decision parameters 'f_epeiros' (ai_label:f_epeiros) vs faction 'f_rome':

    Anyway, what this all means is that the LTGD doesn't 'actively' reevaluate the game state. It reevaluates the game state for the child during a parents own turn. The reevaluation is based on the diplomatic action initiated by the parent factions LTGD driven decisions then creates updated 'child' decisions. So yes, the LTGD for the 'child' is updated based on game state before it's own turn or even after but not in the sense we were hoping and further, I don't think we can get a 'parent' LTGD evaluation to update twice in a row.

    In short it's a bit of a lost cause due to a misunderstanding of the exact workings of the LTGD.
    Unless that is, somebody else can make better sense of how the LTGD works than I can.
    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)

  5. #45
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    I assume this is because its a condition, not an event hence using it with an event is incorrect?
    monitor_event needs an event. Conditions are optional. This is correct syntax...

    Code:
    monitor_event CharacterTurnEnd RemainingMPPercenatge < 100
    red = event
    blue = condition

    So is this...

    Code:
    monitor_event CharacterTurnEnd 
    This is not...

    Code:
    monitor_event RemainingMPPercenatge < 100
    Unless that is, somebody else can make better sense of how the LTGD works than I can.
    Not me, I'm afraid. I had trouble following most of what has been said here.

  6. #46
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Ok thanks for clearing that up, I always have a hard time scripting as I get easily confused by the syntax and possibilities.

    Also do you think you'd be able to explain what's going on here exactly? Is it just an unmentioned possibility that CA omitted/forgot to add into the docudemons for that command or possibly some sort of rule where you can potentially tack on additional parameters to script commands in battle scripting?

    I've been trying to puzzle that out, and I'm hoping you or Gigantus have an idea about whats going on.

    Code:
    unit_immediate_place HRE_general -114.259, -297.340, 172, formation_type square, formation_width 27.724
    It's located in vanilla data/world/maps/battle/custom/pavia/pavia_script if you want to take a look at it.
    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)

  7. #47
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    It appears to be a valid command - it's in the kingdoms executable and some error messages are related to it - see pic. I would assume that it has the same effect as the move_character command which instantly moves the character to a designated co-ordinate as opposed to 'walk' it there.

    Edit: it's in the docudemons, line 96 in the 'command' tab of the spreadsheet version.


    Last edited by Gigantus; February 11, 2016 at 02:50 AM.










  8. #48
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    I am just curious about the format/additional parameters tacked on to the end

    Code:
    unit_immediate_place HRE_general -114.259, -297.340, 172, formation_type square, formation_width 27.724
    According to the docudemons, only adding parameters for label, location, angle in degrees and width are possible. Though the formation type/formation width are there as well. Perhaps that is what they were referencing to with width?

    Identifier: unit_immediate_place
    Parameters: unit_label location angle_in_degrees width(optional)
    Description: Immediately positions the unit at the given location
    Sample use: unit_immediate_place archers1 big_hill 0 20
    Class: UNIT_IMMEDIATE_PLACE

    So I now wonder if the docudemons mentioned that events could be used together with conditions, or did people have to figure that out themselves? Would it be reasonable to think the same perhaps be true with battle scripting, with several parameters being able to be used with commands even if not in the description?
    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)

  9. #49
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    There is the odd occasion where the demons aren't quite correct or up to date in their descriptions or parameters. This one I'm not familiar with ... never really got into battle scripting.

    The demons don't really explain how to do stuff, they're more just a reference of "what", not "how". No idea how the events/conditions workings were discovered. Maybe someone from CA explained it at some point, or maybe it was all deduction from vanilla script and trial and error.

  10. #50
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    So I now wonder if the docudemons mentioned that events could be used together with conditions, or did people have to figure that out themselves? Would it be reasonable to think the same perhaps be true with battle scripting, with several parameters being able to be used with commands even if not in the description?
    A lot of scripting rules have been established through trial and error, especially so as some of the coding changed (nothing major) from RTW to M2TW.










  11. #51
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    @CavalryCmdr

    Minor comment here, during a test I decided to use these values, they do seem to have an effect on the ratio the AI will attack with. It aims for 1:1 ratios with these values. Of course this is just a minor comparison & observation based on a single test (not large scale), between the attack decisions the AI made between a value of 1.0 and a value of 0.9.

    With siege_att_str set to 1.0, I have seen 2:1 sieges, though when on VH (did not test on medium) the attacking AI will still easily win the autoresolve despite this 'ratio' (although I do note other armies lost on the battle map). Perhaps the AI internally calculates things differently rather than the ratio we see, though this idea does not make sense. In any case, I am intrigued by the test results, it could mean that the priority for an attack (for a single army) fluctuates according to it's strength modifier. Perhaps the LTGD coordinates the attack/invasion decision with current and future priority, all based on the modifiers. Anotherwords it will only send decide on an invasion once it meets the requirements given by the modifiers.

    In any case I'm definitely going to do some more testing and try to find some 'confirmations' with these and try to find some suitable values when I have more time tomorrow.

    <!-- modifies the effective sieging attackers strength when determining the priority of making attack decision -->

    I am mostly going on those words, and the test result. During earlier tests I did not have these results at first, which is curious, in fact I only lifted the restrictions on forced invasions via the exe (or more likely the LTGD) before the test. I'm really wondering now if these values generally apply to the 'forced' invasions/naval invasions.

    Code:
          <att_str_modifier float = "1.0"/>            <!-- modifies the effective attackers strength when determining the priority of making attack decision (i.e. att_def_strength_ratio = ((att_str*att_str_modifier)/def_str) -->
          <siege_att_str_modifier float="0.9"/>      <!-- modifies the effective sieging attackers strength when determining the priority of making attack decision -->
          <crusade_att_str_modifier float = "1.0"/><!--modifies the effective crusading sieging attackers strength when determining the priority of making attack decision -->
          <sally_att_str_modifier float="1.0"/>      <!-- modifies the effective sallying attackers strength when determining the priority of making attack decision -->
          <ambush_att_str_modifier float = "1.2"/><!--modifies the effective ambushing attackers strength when determining the priority of making attack decision -->
          <str_limit_weak float = "0.99"/>              <!-- min ideal strength ratio modifier for determining when an army is far too weak for an attack ( att_def_strength_ratio < (ideal_str_ratio*str_limit_weak) ) -->
          <str_limit_strong float = "1.01"/>            <!-- max ideal strength ratio modifier for determining when an army is far too strong for a fair attack ( att_def_strength_ratio > (ideal_str_ratio*str_limit_strong) ) -->
    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)

  12. #52

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Kind of random input.

    This is a multi-stage AI, the LTGD (modded by the campaign_ai_db) is like the commander-in-chief, it dose not issue orders directly to the armies, it simply defines the goal, not how to achieve that goal. That's why invade_opportunistic mostly ignores invade_priority. Basically the commander-in-chief says 'attack whoever you want or can.' to his generals. For example, if they had said that to Patton in WWII, he would have marched straight for the USSR regardless of what the overall goal of his commander-in-chief was, which obviously was not to invade Russia. It is also why 'defend_priority' dose nothing/was removed. Defending is not a long-term solution, it's a short-term fix so a long-term solution can be found/achieved.

    The unit AI, mostly un-moddable, aside from those options in campaign_db, is what actually determines how the AI achieves those goals defined by the LTGD. Basically it will do what it considers best now to accomplish it's orders. If it's strong enough to accomplish the mission, it will attack, if it's not it will hold position (determined by 'defense=') and await reinforcements. For sending reinforcements it simply looks at the highest invade_priority, this is why I was hoping we could force a re-evaluate after character move, since invade_priority can be changed based on frontline balance, but changes made during the current turn are not considered. As far as I can determine, this is what creates the major difficulties the AI has with multi-front wars.

    The commander-in-chief receives messages from his general about what they are doing, but it dose not actually do anything with them since he knows the loyal general will be attempting to achieve his overall command. This is where your 'child' re-evaluation comes in, on a major political event, the commander-in-chief quickly scans all these messages about what the generals are doing, if they are not doing anything they now should not it ignores them, if they are, it becomes necessary to change their orders.

    I have tried to find a direct relation between 'invade_priority,' 'invade_priority_min,' 'invade_priority_max' and the actual chances the AI will attack, the only thing I've been able to determine so far is:
    If invade_priority < invade_priority_min : invade_priority = 0
    If invade_priority > invade_priority_max : invade_priority = invade_priority_max (ie if 'max' is 5000 and the AI has one target at 5001 and one at 8000, they are both considered equal at 5000.)
    invade_priority actually has no direct effect on likelihood of an attack, only a relative effect compared to other invade_priorities.
    By this I mean invade_priority 15000 is no more likely to launch an invasion then invade_priority 2000, if they are still the same relative to other invade_priorities in that decision process. So, 'invade_priority toward England = 15000 ; invade_priority toward France = 10000' means exactly the same thing as 'invade_priority toward England = 1500 ; invade_priority toward France = 1000'

    Let me know your take on these statements, especially if you disagree and can offer a counter.

  13. #53
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    If only we didn't have to guess and test these things, modding the CAI would become exponentially easier.
    I am not entirely sure this is what you're asking (whether you speak of a generalized attack which is also likely, or an army/unit based attack). In regards to armies however, the first way I looked at it was invade_priority_min/max using vanilla's values is 50/1500 which equals 3%. (50/1500=0.03). I felt it followed that this would result in a minimum amount of force distribution before invading, faction wide. As such, I increased it to 33%, 10 times vanilla's value. There wasn't any noticeable or drastic effect (only ever experienced that in regards to armies when changing descr_campaign_db values), currently I test with the min/max values on the same spectrum as vanilla but far larger in range. 1000 min - 30000 max vs vanilla's 50 min - 1500 max, still a 3% scale.

    I don't think the min/max has many effects outside of the faction wide priority in the LTGD, although the modifiers are perhaps applied directly to the army based upon the current faction wide priority. So if there is a max priority invasion the army despite being under strength will immediately try to invade unless modifiers are applied to it telling it directly that it does not need to invade at that very moment. Or anotherwords the priority for a specific army to invade would be directly affected by the modifiers in the descr_campaign_db.


    As for determining the chance a faction will attack, it would seem we're already of the same mind based on a percentage scale (if maxed) it will be 100% regardless of the actual value.



    Update
    I just thought of something else as well, that could be why they have 'invasions cancelled this turn', I believe this makes sense, the modifier dictates whether the invasion is possible. If not, there is no invasion and it is cancelled. Of course invasion orders (by LTGD via descr_campaign_ai_db) are still viewed as the overall command of where to invade or consider invading.
    Last edited by z3n; February 16, 2016 at 03:43 PM. Reason: clarification for the equation
    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)

  14. #54

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Quote Originally Posted by z3n
    I just thought of something else as well, that could be why they have 'invasions cancelled this turn', I believe this makes sense, the modifier dictates whether the invasion is possible. If not, there is no invasion and it is cancelled. Of course invasion orders (by LTGD via descr_campaign_ai_db) are still viewed as the overall command of where to invade or consider invading.
    So your saying an invasion is ordered by the 'commander in chief' (LTGD) but canceled by the General because he dose not believe he's strong enough (based on str modifiers in campaign_db?) That actually makes a lot of sense, unfortunately it is nearly impossible to confirm.
    I've also noticed 'invasions cancelled this turn' happens when the AI is attempting a navel invasion on a neighboring region. It sometimes also refers only to navel invasions if a ship is not available for a planned navel attack, but they will still sometimes launch a normal attack.

    Quote Originally Posted by z3n
    priority for a specific army to invade would be directly affected by the modifiers in the descr_campaign_db.
    Yes, this is what I was trying to say, invade_priority modified by the strength modifiers determines attack priority for the army. I also believe, regardless of the settings, the AI will attempt to have a 50/50 ish chance of victory in autocalc.

    Quote Originally Posted by z3n
    currently I test with the min/max values on the same spectrum as vanilla but far larger in range. 1000 min - 30000 max vs vanilla's 50 min - 1500 max, still a 3% scale.
    What I was getting at is the actual number you use are mostly irrelevant, the percentage and relative (to other potential targets) is all that really matters.
    I am also planning to test a theory I just came up with regarding 'invade_priority_max' I'm wondering if this is the max invade priority the AI will consider. By this I mean, if you have an 'invade_priority_max' at 30000, the highest single target with an invade_priority 18000 and one with 12000 if the AI will consider any further potential targets as 0. Where as if their highest target is only 16000 and then a 12000 if it will consider the next highest as an invade_priority of 2000 (if it's actually higher then that,) and any remaining as 0. However it may be a little while before I can test this. In my test earlier with HRE, Saxons and Venice I had Saxons at 6000 and Venice at 3000 with an 'invade_prority_max' of 9000, they attacked as I expected, with approximately 2/3 available forces at the Saxons and 1/3 at Venice. It just occurred to me that I should have tested it with invade_priority_max at 6000 to see if they still attacked Venice, unfortunately I have deleated that test setup.

  15. #55
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Rather late, don't know why I'm up still.

    What I was getting at is the actual number you use are mostly irrelevant, the percentage and relative (to other potential targets) is all that really matters.
    Agreed.

    Yes, this is what I was trying to say, invade_priority modified by the strength modifiers determines attack priority for the army. I also believe, regardless of the settings, the AI will attempt to have a 50/50 ish chance of victory in autocalc.
    As long as you're not talking about the str_weak setting and just the invade_priority settings we agree, as I found that str_weak does have a drastic effect in terms of what army it sends to attack. And that the siege modifier does have an effect as well (it will completely avoid battle it otherwise wouldn't with a normalized setting of 1.0).

    So your saying an invasion is ordered by the 'commander in chief' (LTGD) but canceled by the General because he dose not believe he's strong enough (based on str modifiers in campaign_db?) That actually makes a lot of sense, unfortunately it is nearly impossible to confirm.
    Yeah, I think invasions may be considered on a case by case basis. Anotherwords the invasion order goes out via the LTGD (it decides it wants to use x decision), then afterwords the generals are checked. If they can't do an invasion based on the settings, it cycles to the next general, then the next and if none of them can do it then it cancels the invasions. I might be able to test the theory with 'real' evidence from the logs and AI actions sometime.


    I am also planning to test a theory I just came up with regarding 'invade_priority_max' I'm wondering if this is the max invade priority the AI will consider. By this I mean, if you have an 'invade_priority_max' at 30000, the highest single target with an invade_priority 18000 and one with 12000 if the AI will consider any further potential targets as 0. Where as if their highest target is only 16000 and then a 12000 if it will consider the next highest as an invade_priority of 2000 (if it's actually higher then that,) and any remaining as 0. However it may be a little while before I can test this. In my test earlier with HRE, Saxons and Venice I had Saxons at 6000 and Venice at 3000 with an 'invade_prority_max' of 9000, they attacked as I expected, with approximately 2/3 available forces at the Saxons and 1/3 at Venice. It just occurred to me that I should have tested it with invade_priority_max at 6000 to see if they still attacked Venice, unfortunately I have deleated that test setup.
    This is a reasonable theory and it may be the case. However I'd like to propose another, just based on a recent test I vaguely recall, that the invade_min/max is cumulative and counted for all armies in the AI LTGD log readout (for invade_priority vs a faction). I am saying it is dependent on the amount of armies that have an invade priority towards the faction. Anotherwords, all the invade priorities for the armies get added up towards the faction however they can fluctuate (per army) according to the min/max invade_priority alongside the values in the descr_campaign_db which control whether the army actually has enough of a priority to invade. Or to rephrase it yet again, the invade_priority we read in the logs towards a faction may be the sum of these armies priorities.

    Either way, I have a feeling we really need to study/present our ideas about the meaning of each part of the LTGD log. I have never done so and I think it would be a really good idea so as to get a grasp on what exactly is going on with the units/army as well as the faction. Especially if we come to a consensus together about the functions as I find discussing it with you really helps me understand what I wouldn't have otherwise.


    Update
    Just looked through the CA file again and read this over, while not necessarily direct evidence and it could be a misinterpretation

    "min clamp for final invade priorities calculated"
    "modifies the final invade priority for new faction targets"
    "any invasion priorities are modified by the faction standing (relationship) towards the target"

    It seems like there are 'priorities' (plural) against a single target. And 'targets' could mean settlements/armies that it attacks. Of course this is basically interpreting things just to match my own guess, it could easily be something else.

    As this seems to argue against that idea at the same time while simultaneously supporting it.

    " // for every target faction (all other factions), evaluate the defend decisions // for every target faction, evaluate the invasion decisions
    // any invasion priorities are modified by the faction standing (relationship) towards the target
    // depending on current game state, a new target with a high invasion priority may be selected to invade"

    Or it may be a function serving a dual purpose. I am fairly certain that I encountered this within the pathfinding files already, with priority in that file seeming to have two functions, one towards how unit movement works and another towards army movement. At least that is what I found in my custom battle test setups which I knew the behaviour of rather well.

    Further, we have invade_priority being used in concert with invade_orders, what this could mean I am not entirely sure perhaps it boosts all armies invade priorities towards a faction by that specific amount. Then that priority is modified by the descr_campaign_db modifiers. If it is not strong enough the army will continue to refer to the order it has from the LTGD.

    So looking at vanilla code, here's the AI starting to plan an invasion. All the armies (probably) now have a base priority of 150 or 10%. I'd assume that each army has an individual priority which is scaled upwards somehow, not just downwards, based on their current strength, perhaps by the att_str_modifier.
    Code:
                <decision_entry>
                    <!--
                        if we're not at war && we're not at war with anyone else && we outproduce him && he is most desireable, 
                        then >>> plan future invasion
                    -->
                    <min_entry    production_balance="1.0" most_desirable="true"/>
                    <max_entry    num_enemies="0"/>
                    <faction_attitude    invade="invade_start" invade_priority="150" alliance_against="1"/>
                </decision_entry>

    Also just a final note here about our idea of it being a scale.
    It would seem from the file this part confirms it, here are the original values they used in a comment

    " <invade_priority_min int="50"/> // min clamp for final invade priorities calculated <invade_priority_max int="1000"/> // max clamp for final invade priorities calculated"

    While these are the values that are values that are actually used
    " <invade_priority_min int="50"/>
    <invade_priority_max int="1500"/>"

    So it does seem to be based on a percentage/scale.
    Last edited by z3n; February 17, 2016 at 03:38 AM.
    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)

  16. #56

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Quote Originally Posted by z3n
    I am fairly certain that I encountered this within the pathfinding files already, with priority in that file seeming to have two functions, one towards how unit movement works and another towards army movement
    This would definitely make sense since I am quite certain 'distance' plays a major role in final invade_priority. This would also seem to support your 'invasions cancelled this turn' to mean the 'generals' (meaning all armies, not just ones with actual 'named_character') could not / would not attack right now.

    Quote Originally Posted by z3n
    Either way, I have a feeling we really need to study/present our ideas about the meaning of each part of the LTGD log. I have never done so and I think it would be a really good idea so as to get a grasp on what exactly is going on with the units/army as well as the faction. Especially if we come to a consensus together about the functions as I find discussing it with you really helps me understand what I wouldn't have otherwise
    This is rather what I was saying earlier about there not being other serious CAI modders, without alternate ideas being put out it becomes a subconscious 'I think, therefore it is' rather then actively seeking a confirmed answer.

    Quote Originally Posted by z3n
    It seems like there are 'priorities' (plural) against a single target. And 'targets' could mean settlements/armies that it attacks. Of course this is basically interpreting things just to match my own guess, it could easily be something else.
    A reasonable conclusion. With an AI set up to only invade slave_faction
    Code:
    5:13:33.121 [ai.ltgd] [info] <19> LTGD: number of invasion targets: '2
    Where the considering faction in question is cornered with only 2 neighboring settlements, both slave_faction. However there is some concern I have about the armies determining the final target. If you have an army set up it will target a specific settlement, doing nothing else except moving that army to be within range of an alternate target, it will ignore the target you had in mind and move the army toward it's original target. Even if the 'alternate target' you had in mind was within movement range and the original target it goes after is several turns away. I have not yet been able to determine what makes the one target more tempting, even making the alternate target more 'valuable' (more trade goods, higher population, more buildings present, higher agriculture, etc) will not sway the AI to go after the new target. However, changing the strength of the armies in question (both attacker and/or defenders) will, which seems to support the idea of the generals making the final decision based their own strength.

    Quote Originally Posted by z3n
    So looking at vanilla code, here's the AI starting to plan an invasion. All the armies (probably) now have a base priority of 150 or 10%. I'd assume that each army has an individual priority which is scaled upwards somehow, not just downwards, based on their current strength, perhaps by the att_str_modifier
    A reasonable conclusion, however I would caution against using the vanilla code for reference:
    A) Vanilla AI is stupid.
    B) The guy who developed the CAI left long before the game was completed which means either the vanilla code was his initial 'test AI' or it was written/modified by people who had no more idea of how the CAI works then we do (and probably did less testing on those ideas.)

  17. #57
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    This would definitely make sense since I am quite certain 'distance' plays a major role in final invade_priority. This would also seem to support your 'invasions cancelled this turn' to mean the 'generals' (meaning all armies, not just ones with actual 'named_character') could not / would not attack right now.
    Distance, agreed, as I can't recall armies ever seeing marching right through enemy territory to attack another enemy factions territory, the only exception being a crusade/jihad (where that restriction is probably lifted). There is one definite factor I have noticed, whether the city is a win condition city and I assume the crusade target is just a highly prioritized win condition city for the duration of the event. (Vaguely recall a flag as well which tells the exe whether it is a crusade target) As for normal targets I am not sure other than distance. I have noticed armies going out of their way to attack targets which have no walls, though that may just be coincidence. And as a side note, I was speaking of the pathfinding file for the BAI just in case you're a little confused as to which priority I meant.


    B) The guy who developed the CAI left long before the game was completed which means either the vanilla code was his initial 'test AI' or it was written/modified by people who had no more idea of how the CAI works then we do (and probably did less testing on those ideas.)

    That explains a lot, sounds like their AI devs must not be treated very well I recall reading about that happening during empires development as well. As for why I use it for reference sometimes, I mainly use it to understand what's going on in the LTGD when we use the command so that I can apply that to the AI. I agree vanilla has problems, especially with building up its forces.


    Where the considering faction in question is cornered with only 2 neighboring settlements, both slave_faction.

    Something of a confirmation and evidence for us, thanks for testing that.
    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)

  18. #58
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Just came across some info from the modding summit, something of a confirmation from CA (reported by a modder who went there in 2012) "AI cares about its victory conditions (in Barbarian Invasion, and all games from Empire onwards, no idea about M2)"

    I'd like to believe that this applies to MTW2 and really I do not see why it would not. There was a test where I took Athens the sequentially highest prioritized city (based on the theory of the the first listed city, then second listed city, etc being the highest prioritized) from the faction. They then launched repetitive naval invasions every 3 turns in an attempt to reclaim it. Further there's also some evidence I've come across in other tests, in addition to public feedback saying the AI changed its behaviour after changing a victory condition for some factions. So I am leaning towards it being a possibility, especially as RTW modders/players themselves have repeatedly noticed this does have an effect over the course of the years.
    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)

  19. #59

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    I don't know, I've tried putting different regions in their victory conditions to try to get the 'first moves' the way I wanted. In this situation I was trying to get England to take York before Scotland had the chance. Now that I'm thinking about it though, I think I only put it in for their 'short campaign' victory, though it did not matter if I was playing long or short type. Maybe I'll try again and make sure I put it in both long and short.
    I do not have a lot of time right now, but should be able to test this out next week.

  20. #60
    z3n's Avatar State of Mind
    Moderator Emeritus

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Understanding MTW2/Kingdoms.exe Pathfinding, XML and the AI

    Okay, hopefully your test can confirm.

    Also here is a continuing theory about how the priority scales, all invasion decisions have build up code by default except for invade none. This means the invade priority doesn't really change for armies in an upwards direction via some sort of upward scaling modifier. There is no need for that as any invade order will be building up an army which increases it's invasion priority by default towards the base/faction wide priority. And of course the downward scaling modifiers will not be applied so long as the modifier requirements are not met.
    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)

Posting Permissions

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