Page 2 of 11 FirstFirst 1234567891011 LastLast
Results 21 to 40 of 204

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

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

    Join Date
    Aug 2011
    Posts
    4,640

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

    Quote Originally Posted by CavalryCmdr View Post
    No, I have not tried pre-faction turn start. Changing the diplomatic stance of the rebel faction would only force the AI to re-evaluate the Long Term, which is already done every faction turn start anyway. It would have no effect on the short term as that is only considered at the start of the faction turn, and is only effected by major changes in the long term (ie ceasfire or alliance with a faction that an attack against has already been issued.) This is why stationary armies might move to intercept incoming enemy armies, but armies that have already received orders usually will not.
    What I was hoping with a repeated diplomatic change stemming from the way CharacterTurnStart should work (forcing a re evaluation every time just before the AI moves each of its characters) might change the way it distributes its forces effectively or perhaps ineffectively. Essentially changing the long term goals to have immediate consideration for the short term as well. Of course doing so may have no benefit or there could be safeguards or a limit to how many times the LTGD can reevaluate.




    Yes mostly. I believe the intent was to prevent large armies fromhunting down small armies in it's area, to keep them free for more effective orders such as attacking, defending or intercept larger armies. For example, a human player will not have a full stack army ready to attack use half it's movement in the opposite direction from the intended attack to take out a 1 or 2 unit enemy army, instead it will order the full stack to attack and have a smaller (or separate a small force) attack said one or two units. I believe that is the intended purpose of str_limit_strong, the whole thing was either disabled completely (as I said I've only done limited testing) or they effectively disabled it (99) because it did not work as intended.


    This is interesting, its almost a convincing argument to keep it enabled. I suspected it was a redundant value which acted as an extension of str weak, as str weak already takes into account as to whether the enemy is too strong. Any test to prove that is not really possible though due to how they would invariably be dependant or each other during any test.


    Writing out the equation results in this for me Predicted Attacking Army Ratio > (1.0)(1.01). Anotherwords if the attacking army ratio is less than 1:1 the defenders are far too strong for a fair attack. That's why the value looked redundant to me and why I could not figure out why they originally had 99 there. With the slave garrison having a 999 I assumed that value was what disables a function and that typing 99 was a typo and the intent was to use 999.


    Predicted Attacking Army Ratio > (1.0)(99) may imply it could possibly have been meant to be the maximum ratio an army can outnumber others by when attacking. However it doesn't appear to work that way (in tests). Another suspicion I could not prove was that the value solely applies to the forced/naval invasions via the exe. In any case the fact that results are so inconclusive at all implies the value is probablky on the useless side.
    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. #22

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

    Quote Originally Posted by z3n
    What I was hoping with a repeated diplomatic change stemming from the way CharacterTurnStart should work (forcing a re evaluation every time just before the AI moves each of its characters) might change the way it distributes its forces effectively or perhaps ineffectively.
    This certainly makes logical sense and, if possible, should radically change the AI's capability. Unfortunately, as yet, I have been unable to do so, or at least the LTGD log is still only showing once for each faction, here is the script I was attempting (with variations such as replacing slave with other factions, neutral for allied, and I tried link_faction_ai to see if that would prompt the LTGD log...)
    Spoiler Alert, click show to read: 
    monitor_event FactionTurnStart
    console_command diplomatic_stance england slave neutral
    console_command diplomatic_stance france slave neutral
    console_command diplomatic_stance hre slave neutral
    console_command diplomatic_stance papal_states slave neutral
    console_command diplomatic_stance spain slave neutral
    console_command diplomatic_stance venice slave neutral
    console_command diplomatic_stance sicily slave neutral
    console_command diplomatic_stance milan slave neutral
    console_command diplomatic_stance scotland slave neutral
    console_command diplomatic_stance byzantium slave neutral
    console_command diplomatic_stance russia slave neutral
    console_command diplomatic_stance moors slave neutral
    console_command diplomatic_stance turks slave neutral
    console_command diplomatic_stance egypt slave neutral
    console_command diplomatic_stance denmark slave neutral
    console_command diplomatic_stance portugal slave neutral
    console_command diplomatic_stance poland slave neutral
    console_command diplomatic_stance aztecs slave neutral
    console_command diplomatic_stance seljuk slave neutral
    console_command diplomatic_stance hungary slave neutral
    console_command diplomatic_stance saxons slave neutral
    console_command diplomatic_stance zirids slave neutral
    console_command diplomatic_stance normans slave neutral
    terminate_monitor
    end_monitor
    monitor_event CharacterTurnStart
    console_command diplomatic_stance england slave war
    console_command diplomatic_stance france slave war
    console_command diplomatic_stance hre slave war
    console_command diplomatic_stance slave papal_states war
    console_command diplomatic_stance spain slave war
    console_command diplomatic_stance venice slave war
    console_command diplomatic_stance sicily slave war
    console_command diplomatic_stance milan slave war
    console_command diplomatic_stance scotland slave war
    console_command diplomatic_stance byzantium slave war
    console_command diplomatic_stance russia slave war
    console_command diplomatic_stance moors slave war
    console_command diplomatic_stance turks slave war
    console_command diplomatic_stance egypt slave war
    console_command diplomatic_stance denmark slave war
    console_command diplomatic_stance portugal slave war
    console_command diplomatic_stance poland slave war
    console_command diplomatic_stance aztecs slave war
    console_command diplomatic_stance seljuk slave war
    console_command diplomatic_stance hungary slave war
    console_command diplomatic_stance saxons slave war
    console_command diplomatic_stance zirids slave war
    console_command diplomatic_stance normans slave war
    end_monitor
    monitor_event CharacterTurnEnd
    console_command diplomatic_stance england slave neutral
    console_command diplomatic_stance france slave neutral
    console_command diplomatic_stance hre slave neutral
    console_command diplomatic_stance papal_states slave neutral
    console_command diplomatic_stance spain slave neutral
    console_command diplomatic_stance venice slave neutral
    console_command diplomatic_stance sicily slave neutral
    console_command diplomatic_stance milan slave neutral
    console_command diplomatic_stance scotland slave neutral
    console_command diplomatic_stance byzantium slave neutral
    console_command diplomatic_stance russia slave neutral
    console_command diplomatic_stance moors slave neutral
    console_command diplomatic_stance turks slave neutral
    console_command diplomatic_stance egypt slave neutral
    console_command diplomatic_stance denmark slave neutral
    console_command diplomatic_stance portugal slave neutral
    console_command diplomatic_stance poland slave neutral
    console_command diplomatic_stance aztecs slave neutral
    console_command diplomatic_stance seljuk slave neutral
    console_command diplomatic_stance hungary slave neutral
    console_command diplomatic_stance saxons slave neutral
    console_command diplomatic_stance zirids slave neutral
    console_command diplomatic_stance normans slave neutral
    end_monitor
    It dose change the diplomatic stance which should prompt the LTGD to re-evaluate, but it dose not show in the log.

    On the str_limit point, I have done some further testing and have come to the conclusion (quite definitively) that I was wrong, it dose seem to just be redundant. My new theory (if str_limit_strong actually dose anything,) is
    str_limit_weak = what the minimum strength should be for an attack
    str_limit_strong = what the desired strength is for an attack
    Not really sure how to test this in a controlled scenario, so I'm going to do some broad spectrum runs to see if I can note any behavioral differences.

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

    Join Date
    Aug 2011
    Posts
    4,640

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

    Here's a post from Gigantus (who knows far more than myself about campaign scripting) on the EBII internal forums for which comes first in sequential terms. In fact I'm placing it here for future reference for myself as well, so it doesn't get buried there).

    PreFactionTurnStart
    CharacterTurnStart [..n]
    SettlementTurnStart [..n]
    FactionTurnStart
    (Moves, etc.)
    (For player: end turn button clicked)
    (Buildings constructed, units recruited)
    CharacterTurnEnd [..n]
    CharacterTurnEndInSettlement [..n]
    SettlementTurnEnd [..n]
    FactionTurnEnd



    I suspect from the above is that the reason is due to the sequencing (and although your idea is quite logical and I would have thought the same). It seems to be the placement of FactionTurnStart being before the CharacterTurnStart. Thanks for testing it so rigorously thus far.

    Update:
    Just saw the link he posted it from, seems like he experienced weird behaviour in terms of scripting, so it may give some hope for discovering a way still. http://www.twcenter.net/forums/showthread.php?691274
    Last edited by z3n; February 08, 2016 at 05:25 PM.
    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. #24
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

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

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

    The terminating FactionTurnStart will have messed up the sequencing in the first turn but after that it should be fine again because then only the character monitors will fire. Use PreFactionTurnStart to get the right sequence at the start of the campaign.
    I am wary of using monitors without conditions, I usually use TrueCondition when I am forced to do so - maybe that will help with logging:

    monitor_event CharacterTurnEnd TrueCondition
    console_command diplomatic_stance england slave neutral


    Edit: I have not gone through the thread to find out why you use this particular console command but I woull like to point out that every change of a faction stance generates a historic message event. Seeing that this happens for every faction twice for every character in play that would make the message system redundant if not malfunctioning due to the time it takes to generate those icons that slide down on the left of the screen.

    If someone could summarize what should be achieved I might be able to suggest a more suitable solution.
    Last edited by Gigantus; February 08, 2016 at 08:06 PM.










  5. #25

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

    With this info, I'm thinking orders are given/executed at CharacterTurnEnd, rather then Start, it must be so as different characters will do different things depending on how previous battles end. I wonder if Campaign_wait between diplomatic stance changes done at CharacterTurnEnd will trigger the LTGD so the next character is not using decisions based out outdated info such at frontline balance (which can change significantly between character moves.) Using the trace log:
    Code:
    16:49:41.599 [game.script.exec] [trace] exec <console_command> at line 618 in mods/WorkingCLAIM/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    
    16:49:41.616 [game.script.exec] [trace] exec <console_command> at line 618 in mods/WorkingCLAIM/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    This tells us there is precisely 0.017 seconds between one CharacterTurnEnd and the next (this is a character that did nothing, so theoretically it should only go up from there. So what is the campaign_wait equivalent to 0.016 seconds?

    If this cannot work, next best option I can think of would be to link a neutral change when the AI initiates battle, which would automatically cause a declaration of war at the end of the battle which in theory will trigger the LTGD even if scripted stance changes do not. This would, perhaps not consider basics of troop movements, at least allow consideration of battle outcome on the campaign level (rather then just local as it already dose in some measure.) So I will attempt to use PreBattle. In the Docudemons it says it outputs faction, but not target_faction, but I will try anyway.

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

    Join Date
    Aug 2011
    Posts
    4,640

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

    @Gigantus The goal is getting the engine to evaluate CAI goals every time a character moves.


    Code:
    // At the start of every factions turn (or when diplomacy changes), the LTGD is re-evaluated as follows:
    
    
                // 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
            // the LTGD can be debugged with the preferences '[log] level = ai.ltgd trace' and '[ai] ltgd_logging = true
    The goal is to make the LTGD consider short term goals as well planning long term goals based around short term events. It may cause dynamic reactions to events that just happened (lost battle it expected to win, reinforce army which didn't get reinforced in time for a siege etc).

    It seems two things may be able to trigger this 1) Diplomacy changes 2) A factions AI being frozen/linked in tandem with the CharacterTurnStart.


    @CavalryCmdr Best of luck I look forward to hearing the results. Unfortunately I have had very limited time this week for testing (other than sunday briefly for a couple of hrs in efforts to create custom formations based on scripts/attributes), so I'm really glad you 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)

  7. #27
    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

    For the player all of the moves happen between the end of FactionTurnStart and before the first CharacterTurnEnd (CTE). CTE does not fire after a character has moved, it fires on each character only when the faction has ended its turn. I always assumed that this is the same for the AI, but do not know for sure. If it is so then there's no suitable event to use for those stance changes - there's no e.g. CharacterFinishedMoving event, though CharacterMultiTurnMove comes close.

    I found once that processing descr_campaign_ai_db.xml definitely happens at some point after FactionTurnStart. Exactly when I don't know but surely (?) before any of its characters start moving about ... at the turn start, not the turn end.

    The minimum value for campaign_wait is 0.1. Anything less makes no difference: still treated as 0.1.

  8. #28
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

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

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

    To establish if a character moved use the movement point condition:
    monitor_event CharacterTurnEnd RemainingMPPercenatge < 100
    ; do your stuff, change a counter value, whatever you need to be used for your purpose
    end_monitor

    Edit: I have no idea how the conditional testing works in the AI script - else you could set a counter to 1, test it in the script and after doing the script thingy reset the value. I have to confess I have no idea if that is possible, given the rapid processing of the event. But you used a console command in the original version so I guess it should work:

    declare_counter CharMove
    monitor_event CharacterTurnEnd RemainingMPPercenatge < 100
    wait 0.1
    set_counter CharMove 1
    end_monitor

    AI script principle:
    if I_CompareCounter CharMove > 0
    do the script thingy
    set_counter CharMove 0
    end_if

    Not sure if the wait command won't lead to noticeable delays given the number of characters in an average campaign. It would however add enough delay to allow for script progressing between campaign and AI script.
    Last edited by Gigantus; February 08, 2016 at 11:23 PM.










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

    Join Date
    Aug 2011
    Posts
    4,640

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

    Appreciate the input.
    Hopefully something of this works...

    monitor_event CharacterTurnEnd RemainingMPPercenatge < 100

    inc_counter moves 1

    if I_CompareCounter moves = 1
    console_command diplomatic_stance england slave neutral
    (continues for rest of factions as well)
    end_if

    if I_CompareCounter moves = 2
    console_command diplomatic_stance england slave war
    end_if

    if I_CompareCounter moves = 3
    console_command diplomatic_stance england slave neutral
    end_if

    (etcetc)

    end_monitor

    Although it uses "=" it's really the only way I can think would work effectively for this purpose, disregarding the fact inc_counter is a slightly unstable command in regards to exact numbers. And of course we'd needto to reset the counter at turn end, simple enough.
    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)

  10. #30
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

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

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

    You are still left with the console command creating a historic event message for every instance (monitor) it fires. What is so important about the command that you are required to use it this excessively?

    You may not have seen the script principle I added at the bottom of my previous post.










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

    Join Date
    Aug 2011
    Posts
    4,640

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

    Yes I didn't see it at the time.

    This part is most important

    Code:
    At the start of every factions turn (or when diplomacy changes), the LTGD is re-evaluated
    If we can get the LTGD to re-evaluate the situation not just at turn start but instead according to character moves it would likely make a tremendous difference as that may change the LTGD from what it is, (a long term, per turn goal director/depending on random diplomatic interactions) into a short term goal director as well which actively recognizes the game state in relation to every characters move.


    I should explain more, LTGD = the engines high level CAI which controls when the exe uses the low level CAI. (for the rest it is mostly dependent on the low level AI in the descr_campaign_ai_db)
    Last edited by z3n; February 09, 2016 at 12:04 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)

  12. #32

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

    Quote Originally Posted by Withwnar
    For the player all of the moves happen between the end of FactionTurnStart and before the first CharacterTurnEnd (CTE). CTE does not fire after a character has moved, it fires on each character only when the faction has ended its turn. I always assumed that this is the same for the AI,
    Characters actions are logged in between CharacterTurnEnds, including battles/battle results. Unless the game notes these results then posts them later in the log (which is entirely possible) orders must be issued at that time. As I've had no success so far I will set up a log system to confirm one way or the other insomuch as it's possible. If you are correct (and when it comes to scripting it seems most likely) then further efforts down this road are pointless.

    @Gigantus ; for further explanation I will give you an example:
    Spoiler Alert, click show to read: 
    With the continue=true function we have an AI that gathers all pertinent information and uses it to asses it's most pressing concerns, by use of invade_priority, higher invade_priority vs a given faction means that faction gets most or all the AI's attention.

    Currently the AI can evaluate the local actions per character based on the current situation. For example if France is at war with HRE and England and both border say Paris region, if the AI defeats an army from HRE it is able to use another (or even the same if MP permits) army in the Paris region to turn on the now bigger threat of England, even though the current 'Grand Strategy' (ie LTGD) still views the HRE as the bigger threat. That's 'local' and is great, as far as it goes.

    Now let's say England is at war with France and Scotland and France is the bigger threat. Now, England defeats a large French army on the mainland, making Scotland the bigger threat. An army leaving London will still set sail (if possible) toward France because there is no 'local' contradiction and the LTGD still considers France the bigger threat. The next turn, when England re-evaluates it's LTGD the army will either turn around and head back towards Scotland, or even still move toward the border of the now harmless French until it completes it's current orders. If we can force the AI to re-evaluate the LTGD before issuing orders to the army leaving London we can either send it straight toward Scotland, or if the Modder prefers, have it launch an attack straight at the French to kick them while their down (rather then going to the border first because it doesn't know there is no threat at the border.) Either way, in the current state, the army leaving London looses one or two full turns doing nothing useful.

    Now we could change the scenario slightly and say the Human player is France and AI England just lost a large army to a defending French force. Following pre-battle LTGD lets say the army leaving London heads straight for the Scotland border because it didn't think it would need it to face the French at this time. Now we have one less army for the human player to deal with while kicking AI England off the mainland.

    This is just a basic example, I'm sure z3n has more ideas how to use this effectively but the base philosophy is most likely the same.

    @z3n ; I've had no luck with a controlled test of str_limit_weak / str_limit_strong
    Here is the test I set up:
    Spoiler Alert, click show to read: 
    HRE's only settlement between Saxons (Same as HRE in my mod representing the Great Saxon Rebellion) only settlement and Venice also only settlement. Set up HRE with an army bordering Saxons equal to the Saxon army in the settlement, surrounded by 3 captains with one unit each. Just the Faction Leader in the HRE and Venice settlements and a small army in the Saxon settlement. Set up the campaign_ai_db so no-one did anything except HRE invade_immediate Saxons and Venice 6000 and 3000 invade_priority respectively. I tested
    str_limit_weak 0.1
    str_limit_strong 0.2

    str_limit_weak 0.99
    str_limit_strong 99.9

    str_limit_weak 10.5
    str_limit_strong 0.5 (yes intentional)

    str_limit_weak 5.5
    str_limit_strong 10.5

    I deleted map.rwm between tests, just-in-case.
    With all the settings, HRE did exactly the same thing, gathered all but one unit on the saxon border and besieged their settlement. Spawned a general took the one remaining unit and recruited all available Mercenaries and marched for Venice (to besiege it the following turn because it couldn't reach the first turn.) Swiched to invade_opportunistic just because and ran all settings again, yet again HRE did exactly the same thing.

    If you can come up with a better controlled scenario, let me know please, I will test it out.
    Last edited by CavalryCmdr; February 09, 2016 at 01:42 AM.

  13. #33
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

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

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

    Looking at Cmdr's example it would seem that the constant change of faction stances during a faction's turn has a good chance to utterly scramble any cohesive actions as the decisions would be based on that changed stance while all you are looking for is a re-evaluation of a prior situation.

    'diplomacy' in my scripting experience includes faction standing as well. As does bribing. Both actions that can be done on a small scale (can't recall if bribing is possible script wise) without triggering a deluge of messages and radically altering basic game mechanisms at high speed. If you really have to go through all faction variations (why doesn't one command suffice?) then I would suggest a circle of adding and subtracting versus the slave faction:
    Code:
    declare_counter CharMove
    monitor_event CharacterTurnEnd TrueCondition
        if I_CompareCounter CharMove < 1
            set_faction_standing england slave -0.1
            set_counter CharMove 1
            wait 0.1
        end_if
        if I_CompareCounter CharMove > 0
            set_faction_standing england slave 0.1
            set_counter CharMove 0
            wait 0.1
        end_if
    end_monitor
    You can replace TrueConditon with the prior MPPercentage condition if you only want moved characters to trigger.

    Let me know if there is something else that can be considered by LTDG or if a stance change is the only condition available.

    Edit: if withwnar's observation about the triggering of CTE is applicable to LTDG as well then it's pointless anyhow.
    Last edited by Gigantus; February 09, 2016 at 02:09 AM.










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

    Join Date
    Aug 2011
    Posts
    4,640

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

    @CavalryCmdr My own testing situation is far different I suppose in terms of AI decisions/setup for it and so on, here's a video showing the comparison between a 0.01 setting and 0.99. Sorry about the length but it shows the entire test process I ran, except for the settings I was using at the time, I attached them to the post here.

    https://vid.me/mXXb


    It could be based on 1) Position 2) Priority modifications for individual stacks/armies.
    What I'm saying is that it's all tied together, I'm not really sure if I mentioned that before or not but the way I think of it is that the very first modifier att_str_modifier, is like the basic modifier which then has additional modifications applied to it from str_limit_weak (same goes for siege_att_modifier).

    Code:
    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)
    Code:
    modifies the effective sieging attackers strength when determining the priority of making attack decision
    Again, my test results may differ for yours but there could be other very good reasons for why that is. For example the border differences, various attack decisions, the way my low level AI was coded etc...


    @Withwnar/Gigantus
    About the CTE event, I am not entirely sure about this and of course only direct tests will verify this. From what I recall the Battle AI starts directly after the PreBattle event, during start deployment. I assume it would be a similar case with the Campaign AI, the AI files are actively loaded into the game during the campaign start/load at 95%-100% and during battle load as well. Anotherwords during PreFactionTurnStart. I could be wrong of course and it is just my opinion, as I have not tested it, if you have well you know better. And of course both of you are very good at campaign scripting.

    I'll start a couple of tests soon, hopefully I get it done in time before going to bed.

    Update
    Also something worth noting is the different AI behaviour for the slave faction, ship movement on turn 1 with str_limit_weak 0.01 where they move next to my ship compared to 0.99 where they do not move next to the ship. The ratio for that battle is very close to 1:1. At first I thought I saw different carthage behaviour for the family member but I was mistaken.


    A little off topic but have you ever thought of updating your tutorial a little @CavalryCmdr ,I've learnt a lot myself and to be honest my tutorial could do with a few touch ups here and there. Just been too busy, but I am sure you've learnt a lot more than I did over the course of the years. In fact I only came up with the idea for the continue functions repetitive applications a few months back.
    Attached Files Attached Files
    Last edited by z3n; February 09, 2016 at 09:43 PM.
    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)

  15. #35

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

    Quote Originally Posted by Gigantus
    'diplomacy' in my scripting experience includes faction standing as well. As does bribing.
    I have not done dedicated studies of the LTGD log since it first became available (v 1.02 I think) so it could be out-dated, but I've only ever seen the LTGD re-evaluate with stance changes (allied/neutral/war.) That said, even scripting in the stance change dose not seem to prompt the LTGD (at least, it dose not appear in the log.)

    @ z3n : Yes, I forgot to mention that I set all modifiers to 1.0 except the str_limit changes. I think my problem was simply that the HRE had nothing else to do so it simply used all available forces regardless of the settings. Split based on invade_priority 2/3 to attack Saxons 1/3 against Venice (I do not have the actual numbers available but it would seem that was about how the forces were split (if you count the mercs.)
    Quote Originally Posted by z3n
    A little off topic but have you ever thought of updating your tutorial a little @CavalryCmdr ,I've learnt a lot myself and to be honest my tutorial could do with a few touch ups here and there. Just been too busy, but I am sure you've learnt a lot more than I did over the course of the years.
    I wrote that tut in 07 I think, updating it now kind of seems odd. Although some of the info is off/outdated that is only to be expected at this point. I really have not learned much as far as actual facts go, just implementation, also, I lost all my work due to HardDrive crash in 09 or 10, so I really have not done much since then until this past year. Since xeryx left there has not really been anyone with in-depth knowledge and interest in the CAI until you came along. Sure there are several knowledgeable CAI modders, but none with the passion (for lack of a better term) to push the limits. So most of my work has been on my mod it's self, putting the AI aside until I get it to the point where I can really work with it.
    Last edited by CavalryCmdr; February 09, 2016 at 10:22 PM.

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

    Join Date
    Aug 2011
    Posts
    4,640

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

    This is just a quick post as I'm already having to go out again unfortunately. (family)
    So this is a screenshot from the vid.me video up there without a script.
    http://i.imgur.com/B4u6P01.jpg

    Now in this test using the script note that instead of going north, the second captain heads south towards the epeirote border.
    http://i.imgur.com/avIj4nG.jpg


    To be clear- this is just a preliminary test and I already have to go out, unfortunately. So I'll finish this up later, it does look promising but we'll have to verify everything still.


    (Note this is a slightly modified script, as event wasn't working for me so I had to use conditions instead)
    Code:
    declare_counter moves
    
    
    monitor_conditions CharacterTurnEnd RemainingMPPercenatge < 100
    
    
    inc_counter moves 1
    
    
    if I_CompareCounter moves = 1
    console_command diplomatic_stance f_rome slave neutral
    end_if
    
    
    if I_CompareCounter moves = 2
    console_command diplomatic_stance f_rome slave war
    end_if
    
    
    if I_CompareCounter moves = 3
    console_command diplomatic_stance f_rome slave neutral
    end_if
    
    
    end_monitor
    
    
    
    
    monitor_event FactionTurnEnd f_carthage
    
    
    set_counter moves 0
    
    
    end_monitor
    So the script did execute, and the Romans ended up neutral with the Epeiros (checked on turn 2), but more importantly in between moves (!) the stances were affected and the LTGD did reevaluate their moves (!!) as seen by the screenshot comparison. Of course, we can't get too excited with a third exclamation mark just yet as we won't know the full effects until until later but I thought it was a promising first result.

    Lastly, I did not get a relations update for whatever reason, in regards to the Romans changing from atwar > neutral > atwar > neutral. So there's that concern fixed as well.
    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)

  17. #37

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

    Is the LTGD log showing the re-evaluate?
    There is, unfortunately, one slight problem with this, switching from atwar to neutral will cancel any ongoing sieges, in this example, if the Romans currently have a minor faction settlement under siege and another roman character moves, it will cancel the siege. Of course I had not considered this and didn't pick up on the problem until I tried running a similar script long-term and found my AI was broken. So, we need something other then diplomatic stance change to force LTGD to re-evaluate for this to be of use, I suppose we could try a not factionisbesieging condition.

    edit: Maybe try the same script with Gigantus' idea of adjusting faction standing up and down instead, see if the results are the same. It may require a significant change so I'd just go straight to 1.0 if 0.1 dose not work.
    Last edited by CavalryCmdr; February 10, 2016 at 07:23 PM.

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

    Join Date
    Aug 2011
    Posts
    4,640

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

    For some reason the AI LTGD won't generate at all, trying to figure out what's going on with that. I tried to figure out why before I went out but instead since it seemed that it did work from the results, never seen the AI change the first moves before in such a drastic way without any descr campaign ai db entry changes, I assumed it was working as intended. If I can get the AI logs working that'd be nice to have either a denying or confirmation that its working, and possibly an alternative explanation as to why the AI changed its moves in such a drastic way.

    I suppose for mods with a scripting faction set aside for scripting purposes like this won't have to worry, it's a good idea though to have something to prevent sieges from being broken. Maybe this instead would also work?

    not I_FactionBesieged slave
    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. #39
    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

    Code:
    monitor_conditions CharacterTurnEnd RemainingMPPercenatge < 100
    That is incorrect syntax for monitor_conditions and the log should be complaining about it. The result is that those 'conditions' are ignored, treated as true, so the body of this monitor will be executed all of the time, every ~50ms. i.e. Those three stance changes all took place within the first 150ms of the campaign start and never happened again until a FactionTurnEnd...

    Code:
    monitor_event FactionTurnEnd f_carthage
    ...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.


    monitor_conditions takes only conditions as arguments, and ones that have no so-called "trigger requirements". i.e. I_xxx conditions, plus a couple of others, only. RemainingMPPercenatge, for example, requires a character_record which is exported by an event. monitor_conditions have nothing to do with events so it can't be used for character conditions such as this.

  20. #40
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

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

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

    Re code in post #36:
    Using monitor_conditions (which fires\tests about 200 times per second until terminated ) for an event (CharacterTurnEnd) that happens only once per character per turn seems rather a waste of processor resources.

    Edit: Ninja'ed about the rest of the code stuff by my good friend.

    Edit2: It seems I incorrectly assumed that the event would work with the condition monitor.
    Last edited by Gigantus; February 10, 2016 at 09:58 PM.










Posting Permissions

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