Page 4 of 11 FirstFirst 1234567891011 LastLast
Results 61 to 80 of 204

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

  1. #61

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

    Quote Originally Posted by z3n
    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.
    Sorry, not quite sure what your getting at here. Are you talking about consecutive (continue="true") conditions in campaign_ai_db? Or are you saying invade="" type dose not matter, which is true to an extent.

  2. #62
    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 meant the invade orders primarily but also with the continue function, invasion decisions do seem to have a sort of buildup by default (invade_start/buildup especially). As long as the modifiers tell the AI it can't invade, it won't invade but will continue to build up its troops until it can invade (based on the priority).

    Anotherwords, the order for the build up exists in all situations, it is depending on the current modifiers (which tell it when the priority is high enough for an army to invade), as long as the overall invade order in the LTGD is active against the target(s). If there is an invade_none order for example, the AI won't bother building up because there is no order for that.
    The AI will build up if it isn't strong enough to invade yet (according to the modifiers) if the generalized order (as seen in the LTGD as the invasion decision against a faction) is one of the invade orders other than invade_none. Hopefully that convoluted explanation of my thoughts and excessive use of brackets makes a modicum of sense.
    Last edited by z3n; February 19, 2016 at 10:40 PM. Reason: clarifications, clarifications everywhere
    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)

  3. #63

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

    Yes, that's what I thought you were getting at, ofcourse the other way is true too, any invade decision except invade="none" will result in an attack if the AI believes the army is strong enough. Presumably based on "str_limit_strong" though I have not attempted to test that yet. However, the actual process of 'build up' is different depending on the invade decision. invade_start works something like a 'probe' effect I think, where the AI will maneuver more without attacking. invade_buildup the AI will attempt to build more in military buildings (try to strengthen the army with better units actually, though the AI's opinion of 'better' really means more 'cost-effective' therefore to get the AI to really build higher end troop production buildings, you want to make the units available more 'cost effective' then the lower end buildings. How, exactly, the AI determines cost efficiency is a bit of a mystery.) Invade_immediate basically the AI will attempt to get all the units 'immidately' available, this dose not mean the AI will not build up military buildings, just that they are just at their 'normal' priority where 'buildup' the military buildings have a higher priority then they normally would.
    In some (very rare) instances the AI will attack even with 'invade_none' and a -1 priority, though I have no idea at all what circumstances will lead to that.

  4. #64
    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

    That's interesting I had not realized there was a direct correlation in recruitment behavior.To clarify however are you saying that is the main effect or a secondary one alongside the main effect of the invasion types?


    As for the rare almost inexplicable invasion, this may be to do with forced invasions, as they can overwrite and override decision iterations with their own invasion. Further I recall CA painstakingly turning the ability to do so on and off. In relation to the above do you believe there is also a connection between invade immediate and merc recruitment?
    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. #65

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

    Minor side effect of invade type, rather worded poorly, all AI towns are managed in the same way as player towns that are auto-managed. Invade_buildup simply means the AI is more likely to assign towns to 'military' build behavior (to achieve it's invasion orders.) 'Buildup' will also tend to wait for siege equipment and try to form more balanced armies (influenced by their recruitment profile in descry_strat.) So, if a town has one recruitment slot, invade_immediate will recruit the first unit available in the recruitment pool, while invade_buildup will recruit the unit it needs or the 'best' unit available in it's recruitment pool. In short, if you set the AI to use buildup as it's primary invasion type, it will build 'better' armies, but do less with them. Switching from 'buildup' to 'immediate' is the best setup, but is tricky to manage unless they are only assigned to attack one enemy and only border one region so frontline_balance is more fluid and meaningful. Switching from 'buildup' to 'opportunistic' can be a good option, but 'opportunistic' is too unreliable and tends to be either awesome or passive without notable cause.

    Code:
        <faction_attitude invade="invade_none" can_force_invade="false" want_ally="false" want_offer_protect="false" want_be_protect="false" continue="false"/>
    An inactive profile, so I can test one faction at a time. However with these settings Portugal will still take 5 or 6 regions in 20 turns, no other faction dose anything, all with the same profile. I've noticed a couple times here or there with experiments, but never really paid that much attention.

    Invade_immediate, I believe, will recruit mercs if they will get the army to the strength needed and are immediately available. By that I mean, they will recruit mercs in the region they are in if it means they can attack immediately, however, they will not specifically recruit mercs as part of a prolonged recruitment 'plan' and generally will not recruit them in the region they move to. The best mercenary recruitment I've seen is invade_opportunistic, I've had a 'desperate' Portugal send it's faction Heir around southern France up through German territory and down through Italy recruiting mercs all the way, and take a merc ship to northern Africa to attack the Moors (who by this time had Portugal's last town under sige) in the rear with a massive merc force. This, however, is an extreame example, though I've also seen Milan march through Germany into France in a similar manner, recruiting mercs as possible, to attack Paris. I've only seen this sort of thing with 'opportunistic' while it's not 'common' by any means, it is not so rare as to cause excitement.

  6. #66
    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

    An inactive profile, so I can test one faction at a time. However with these settings Portugal will still take 5 or 6 regions in 20 turns, no other faction dose anything, all with the same profile. I've noticed a couple times here or there with experiments, but never really paid that much attention.
    Assuming that there is a min entry of a settlement of one, this is rather confusing.

    This is the default setting, as far as I understand it the default setting for each modifier is shown in the comment section.
    can_force_invade="true" :: can naval or forced invasion settings overwrite invade parameters

    Hence, unless a decision also has a can_force_invade = false modifier, it will happen infrequently I suppose. However yours does have this. I had at first believed that force_invade and can_force_invade were interchangeable yet connected. Perhaps there are two types of forced invasions. One a 'force_invade' which can be used for very specific settings which will literally force an invasion if the decision entry allows for it (and the descr_campaign modifiers themselves), whereas 'can_force_invade' can turn these off depending on the situation if the decision entry is met.

    Using force_invade as 'true' and can_force_invade 'true' seems like it would be redundant, as the setting is by default 'on' and only turned off in specific circumstances. To complicate things and throw my idea about them being the defaults on its head here's another,

    force_invade="false" :: must we invade now

    What this suggests, is that false is the default. However it might be worth putting that in as well just to be absolutely certain no forced invasions are 'overwriting' things.

    Invade_immediate, I believe, will recruit mercs if they will get the army to the strength needed and are immediately available
    This I can partially confirm, I never went out of my way to test it but the AI has recruited mercs on a starting turn (using invade_immediate), then attacked the very next if the army isn't moved while playing one of my test factions. Note my testing faction has two armies directly inside of their territory while the opposing general is nearby, the opposing general will attack both armies with the mercs he recruited, easily outnumbering both but only on the second turn due to the way the LTGD works. I truly wish that the AI did make an effort to run it's decision entries a second time during its turn, instead of only doing it on the next turn, the AI would have been better all round in my opinion. Though that's more of a hypothesis as we don't 'know' that it would truly be better if it did so.

    In any case, I am surprised invade_opportunistic is that effective in terms of merc recruitment/invasion decisions in general. I had suspected it could also play a large role in naval invasions but I didn't think it would have its hands in merc recruitment as well. Rather I leaned towards the immediate strategy having that effect, in any case, it does make sense even if it seems more of a 'hidden' function in the wording. That the strategy would call for opportunistically recruiting mercs isn't necessarily a surprise once you put it together but it was at first. As I generally tended to think of it as 'Ah, see there, he has a weak town! We must invade now.'

    I should add, perhaps there is some sort of 'default' code, tied to the default label itself within the exe as a leftover from RTW which overwrites things unless the AI label is specifically frozen via the campaign script.
    Last edited by z3n; February 20, 2016 at 11:28 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)

  7. #67

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

    invade_opportunistic is very hit or miss. When it works, the AI will amaze, however, as a rule, it's quite lame. After seeing some actions my AI did while under 'invade_opportunistic' (particularly the one I noted with Portugal) I decided it would be awesome to make that the default... the results were not great, in-fact the AI was particularly passive, worse then any other 'invade' setting, with the possible exception of 'none.'

  8. #68
    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

    The AI definitely seems to enjoy using assassins with that strategy, which gives an amusing take to your words 'hit and miss'.
    I wanted to also bring up the fact that using can_force_invade false does seem to have a drastic effect on whether the AI attacks other ships, in addition to naval invasions, though naval invasions seem to be ordered regardless via certain strategies.
    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. #69
    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



    Just being encouraged about the vigorous exchange of ideas.










  10. #70

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

    Quote Originally Posted by z3n
    can_force_invade false does seem to have a drastic effect on whether the AI attacks other ships, in addition to naval invasions, though naval invasions seem to be ordered regardless via certain strategies
    I had not noticed this at all, though I stopped trying can_force_invade="false" quite some time ago, due to limiting AI actions. My theory is an unpredictable AI, even if it dose some stupid things, is better then a 'good' AI, for the simple fact that you cannot make an AI as 'good' as even a decent human player. Although, TBH, I don't really think that's true, per-say, however, and AI that good is simply too predictable, and a decent human player will find and use exploits, with the end result being that the AI is not as good as the human. If that makes sense.

    Do you know particular's about when the AI will use navel invasions with can_force_invade="false" or is it one of those 'for some reason I have not figured out yet' sort of things?

  11. #71
    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

    Do you know particular's about when the AI will use navel invasions with can_force_invade="false" or is it one of those 'for some reason I have not figured out yet' sort of things?
    I am fairly certain invasions flagged as 'is_neighbour = false' allow for this.

    Here's some vanilla code that I just noticed after you asked, never thought to look for a place in their file for it before as it was always just more of a "I think therefore it is" thing for me. However this does seem to confirm it, especially as we know that the sea is considered a region, and thus a region like the sea would automatically mean the target province is not a neighbour. Although I never specifically tested it in a closed environment/test setting.

    Code:
    			<decision_entry>
    				<!--
    					Not interested in factions that are not our neighbour, use defaults, may be overridden by forced/naval attacks
    				-->
    				<max_entry	is_neighbour="false"/>
    			</decision_entry>
    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. #72

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

    Couple things here though, most relevant, when I read that it just confirms that naval invasions are a type of 'forced' invasion, which we already know, therefore 'can_force_invade=false' should disable it regardless.
    Code:
    can_force_invade="true"   :: can naval or forced invasion settings overwrite invade parameters
    That said, it is possible that giving the AI an invasion order (even a 'none') would basically over-ride the 'can_force_invade=false' because that only stops orders that are not specifically in the campaign_ai_db. However, even still, most naval invasions that are issued via campaign_ai_db will be stopped with 'can_force_invade=false' (as with crusades they will approach the target and simply stand there rather then attack.)

    Another little note, pay attention to the LTGD log, on rare occasion there are some regions separated by the sea that are in-fact considered 'neighbour' regions. I have no idea why, but the vanilla map has like 3 such, and they are not always considered 'neighbour' from the other way. This is not restricted to the vanilla map, some fully custom maps had the same thing. I don't know, this is from years ago ('07) and may have been fixed since then, it's just an old memory your comment brought up.

  13. #73
    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

    Couple things here though, most relevant, when I read that it just confirms that naval invasions are a type of 'forced' invasion, which we already know, therefore 'can_force_invade=false' should disable it regardless.


    That said, it is possible that giving the AI an invasion order (even a 'none') would basically over-ride the 'can_force_invade=false' because that only stops orders that are not specifically in the campaign_ai_db. However, even still, most naval invasions that are issued via campaign_ai_db will be stopped with 'can_force_invade=false' (as with crusades they will approach the target and simply stand there rather then attack.)

    Building on that idea (as I too have observed this) most probably run into that problem (even in the naval invasion still happens) due to naval/forced invasions being reliant on several things that are hardcoded


    1) ships (as ship movement/pathfinding is hardcoded and they seem to have their own invasion orders)
    2) the attack after or even before disembarkment (probably a forced invade_immediate strategy)

    The last part may explain why not all of the attacks always follow through regardless of the naval invasion being executed via the LTGD. However with it turned on they will 99% of the time (unless they simply can't via the strength modifier in the descr_campaign).


    Although it's also worth noting, as seen with can_force_invade turned on, there are different naval invasions that happen in areas not seen without the function turned on. Which does suggest that some other part of the exe for the CAI controls certain invasions, perhaps it really is just a leftover from the RTW era.


    Or perhaps it just refers to the LTGD itself (and not the descr_campaign_ai_db) being able to force an invasion on a certain 'target'. Instead of discarding the naval invasion/cancelling due to other factors like current priority of the army for another target.


    Another little note, pay attention to the LTGD log, on rare occasion there are some regions separated by the sea that are in-fact considered 'neighbour' regions. I have no idea why, but the vanilla map has like 3 such, and they are not always considered 'neighbour' from the other way. This is not restricted to the vanilla map, some fully custom maps had the same thing. I don't know, this is from years ago ('07) and may have been fixed since then, it's just an old memory your comment brought up.

    This is strange, perhaps it is due in part to the mapping rules. I vaguely recall that they fixed a bug where fighting on the edge of the map would cause a crash, assuming that the regions in question were like that perhaps that is why. Do you recall where the regions were exactly on the map? It may help explain this phenomenon.
    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. #74
    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
    Recently started wondering whether there is some sort of hardcoded decision into the LTGD for seeking peace in extreme circumstances. What do you think?

    Also can you present your thoughts as to the building strategies for each invasion decision. I understand you are saying millitary/financial/growth and so on policies are used (auto management), however I am not very familiar with what each does. I always micromanaged my cities.

    I have a feeling that invade_immediate might either put it to financial or military. Though I lean towards financial as it may just allow for the AI to recruit mercenaries more easily with that strategy + the finances. Agreed that invade_buildup gives a military policy, and I suspect invade_none means growth build policy. I am not sure about opportunistic though.
    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. #75

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

    I've just started wondering about that myself. I've put the Great Saxon Revolt into my mod, so obviously I do not want them and the HRE to make peace under any circumstances.
    Code:
        <min_entry is_target_faction_to_outlive="true"/>
        <max_entry is_target_faction_to_outlive="true"/>
        <faction_attitude want_ally="false" pts_alliance="-20" want_peace="false" want_be_protect="false" want_offer_protect="false" pts_desire="10" continue="false"/>
    Yet they will still make peace and (granted very rarely) even ally, so I've started wondering if there is a hardcoded behavior for AI factions towards each other. Also, I am lost as to how 'most_desirable' is calculated, because they are rarely 'most_desirable' toward eachother even with what should be a +10.

    I've been studying effects of recruitment personalities (smith, mao, Genghis, etc) and will next be working on building personalities (balanced, religious, trader, etc.) but these are taking quite some time as I'm running 3, 100 turn runs for each. Unlimited money and town growth so most regions will be 'large city' by turn 80. Anyway, when I've got a solid handle on what the build personalities do, I will work with what invade type really effects. I am quite sure my comment on 'buildup' is accurate, with 'none' and 'opportunistic' not effecting the build policy at all. Other then those, I have not even got a guess, although 'immediate' would logically be geared toward 'financial' for the reasons you said, plus, theoretically, 'immediate' should mean 'ready to attack' so they should be more worried about keeping the income with increased upkeep and to be ready to build more if needed. However, I've got no real idea if the LTGD 'thinks' that far ahead. I am quite certain, however, that they do not focus on 'military' on 'immediate' as that was my default and the did not get upgraded troops very well, where now 'buildup' is my default and they are pretty much upgrading recruitment buildings as soon as the town upgrades.

  16. #76
    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

    will next be working on building personalities (balanced, religious, trader, etc.)
    Looking forward to reading your findings, please let me know what you find out. I know how recruitment personalities/AI recruitment choices in regards to units work. If you need to know anything about that I can definitely write up my thoughts about that. As a side note, if I didn't mention it yet I found your input about the building decisions very helpful.

    I've just started wondering about that myself. I've put the Great Saxon Revolt into my mod, so obviously I do not want them and the HRE to make peace under any circumstances.
    I've experimented with this to some extent, trying to stop peace.
    It seems to be some sort of special case directly coded into the LTGD. This I suspect remains in the LTGD even after removing all the peace decisions.

    Code:
                <!--
                <decision_entry>
                        SPECIAL CASE EXISTS HERE IN CODE FOR FORCING want_peace WITH A FACTION UNDER CERTAIN CONDITIONS.  CONTINUES CHECKS FOR SUBSEQUENT DECISIONS
                </decision_entry>
                -->
    The only thing that seems to directly affect alliance/peace treaties and circumvent this is the use of the descr_diplomacy xml file. Placing offer_ceasefire entries at 0 for example does seem to completely reduce their tendency to sign/offer ceasefires to each other as well as the player. Note however it directly affects everyone not just the player.

    Also, I am lost as to how 'most_desirable' is calculated, because they are rarely 'most_desirable' toward eachother even with what should be a +10.
    I'm no help here either, I've seen every single faction listed as most_desirable in the AI LTGD logs while Romes decision entries were being evaluated.
    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. #77

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

    Quote Originally Posted by z3n
    I know how recruitment personalities/AI recruitment choices in regards to units work. If you need to know anything about that I can definitely write up my thoughts about that. As a side note, if I didn't mention it yet I found your input about the building decisions very helpful.
    I would certainly welcome any input you have.
    I know recruitment depends primarily on how the AI determines cost-efficiency of the units and is only 'influenced' by the AI personality. I know what each personality is 'supposed' to do. However, it dose not always work that way. For quick example (I'm about a third of the way through) my Milan faction dose a horrendous recruitment job under 'smith,' not even building anything beyond basic stables in one or two towns. However, 'mao - biased towards mass troops, light infantry' and suddenly they are fielding some of the best, most well balanced armies on the entire map. Some make much more sense, for example my Hungarian faction is almost scary with 'genghis.' On the other hand that really dose not make sense because they recruit so much light and missile cavalry under 'smith' that 'biased towards missile cavalry and light cavalry' should cause them to have too much cavalry, instead they do a better job with support infantry and heavy cavalry. I would assume I was reading the description wrong and it meant 'for rosters that are biased toward...' But that dose not work either. My Rus roster is set up so the infantry are just there to support their superior light and missile cavalry and are not meant to be a fighting force on their own. However, under 'smith,' they recruit almost exclusively melee infantry, but 'genghis' dose what I would have expected from the description and brings their light/missile cavalry up to almost acceptable levels, with some few missile infantry thrown in for good measure.

    I'm quite certain, at this point, how the influence actually affects the outcome depends entirely on the unit roster to the factions, and can be unpredictable. It is also possible that my entire recruitment system confuses the game to the point where none of this information is actually applicable to or from my mod.

    Edit: A thought just occurred to me, is it possible that the 'personalities' do not work as intended and that is why they were basically removed (everyone is 'balanced smith') in vanilla? I've only experimented on these before using vanilla, way back when I did that initial tut on campaign AI, and I've also noticed many mods still just use vanilla's everyone is 'balanced smith.'
    Last edited by CavalryCmdr; February 29, 2016 at 04:06 AM.

  18. #78
    GRANTO's Avatar Domesticus
    Join Date
    Dec 2010
    Location
    glastonbury uk
    Posts
    2,207

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

    Hi guys , just wanted to chip in a bit about something i noticed,
    in the mtw2 pack files {i think it was 0_pack} there is CAI and BAI formations the lot ...., i was pretty sure these files were causing some conflicts with files in mods . {via the engine}
    i think you should have your files in that pack file {unpacked and packed up again} as well as in the mod itself.

  19. #79
    GRANTO's Avatar Domesticus
    Join Date
    Dec 2010
    Location
    glastonbury uk
    Posts
    2,207

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

    Quote Originally Posted by CavalryCmdr View Post
    I would certainly welcome any input you have.
    I know recruitment depends primarily on how the AI determines cost-efficiency of the units and is only 'influenced' by the AI personality. I know what each personality is 'supposed' to do. However, it dose not always work that way. For quick example (I'm about a third of the way through) my Milan faction dose a horrendous recruitment job under 'smith,' not even building anything beyond basic stables in one or two towns. However, 'mao - biased towards mass troops, light infantry' and suddenly they are fielding some of the best, most well balanced armies on the entire map. Some make much more sense, for example my Hungarian faction is almost scary with 'genghis.' On the other hand that really dose not make sense because they recruit so much light and missile cavalry under 'smith' that 'biased towards missile cavalry and light cavalry' should cause them to have too much cavalry, instead they do a better job with support infantry and heavy cavalry. I would assume I was reading the description wrong and it meant 'for rosters that are biased toward...' But that dose not work either. My Rus roster is set up so the infantry are just there to support their superior light and missile cavalry and are not meant to be a fighting force on their own. However, under 'smith,' they recruit almost exclusively melee infantry, but 'genghis' dose what I would have expected from the description and brings their light/missile cavalry up to almost acceptable levels, with some few missile infantry thrown in for good measure.

    I'm quite certain, at this point, how the influence actually affects the outcome depends entirely on the unit roster to the factions, and can be unpredictable. It is also possible that my entire recruitment system confuses the game to the point where none of this information is actually applicable to or from my mod.

    Edit: A thought just occurred to me, is it possible that the 'personalities' do not work as intended and that is why they were basically removed (everyone is 'balanced smith') in vanilla? I've only experimented on these before using vanilla, way back when I did that initial tut on campaign AI, and I've also noticed many mods still just use vanilla's everyone is 'balanced smith.'
    you can remove personalities all together and have nothing, for me it makes the the AI more adaptable to evolving situations.

  20. #80
    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

    Hi guys , just wanted to chip in a bit about something i noticed,in the mtw2 pack files {i think it was 0_pack} there is CAI and BAI formations the lot ...., i was pretty sure these files were causing some conflicts with files in mods . {via the engine}
    i think you should have your files in that pack file {unpacked and packed up again} as well as in the mod itself.
    It could be that but in theory as the game reads the files first if set to do so in the CFG, not the packed files, it will load the file if it exists (and it does) while ignoring the one in the pack as redundant. I do recall some research by some modders (Tajii and Argantanio) suggesting that the packed config ai battle file is not read, regardless of whether a file exists or not as the info is already mirrored in the exe. That doesn't really make complete sense to me as we know already that M2TW files are packed by default and that the exe will look for packed files if it cannot find a 'file' first. Perhaps it is due to the nature of how file first works, though I doubt it and that could only be proven using a process monitor tool, while easy enough I am modding my SS 6.4 installation right now.

    I will test it soon and we may be able to come up with a definite answer, unless @Granto you already tested it like that?


    I know recruitment depends primarily on how the AI determines cost-efficiency of the units and is only 'influenced' by the AI personality
    Right, upkeep/efficiency of a unit plays an important role. From what I can tell, AI personality affects the recruit priority scale on a generic basis. For example +25 recruitment priority to the class and category of unit defined as light/heavy cavalry as the genghis personality, that's just a simple guess, I'm not absolutely certain which class and category gets the generic bonus in recruit priority.

    Anyway, the most important values were brought in from kingdoms. There is now an optional value in the EDU listed as 'recruit_priority_offset'. The description is 'Optional prioritization by the AI of recruitment of a give unit. 0 is neutral; negative is less desirable, positive more desirable'.
    I don't really have kingdoms unpacked at the moment, but I recall looking through them and seeing the values they used as roughly -50~ to +75. This implies the scale is on a -100 to 100. Perhaps some sort of 'percent', i.e. the priority to recruit one unit is 75% greater than another at all times if the other unit has a priority of 0 and the personalities are smith/balanced. These priorities themselves are quite likely modified by the AI's current financial state and as you noted the upkeep/cost efficiency.

    I was going to suggest following a sort of balanced formula (10-25 for levies, higher priority for lower refreshing professionals/elites and so on), but I am sure you'd be able to think of something just as good yourself if not better.

    Also I suggest checking out that link, it gives a small amount of insight as to what the developers might have been thinking at the time. As I recognize that the BAI does have a very limited form of randomness. Not particularly sure about the extent of this randomness in the CAI, as it seems rather predictable from watching many test campaigns and the moves.
    CA seems to follow the random number principle (randomness in AI behaviour and otherwise) to an extent.

    What this means is that not everything can be perfectly/accurately predicted as to the exact behaviour the AI will take during a battle. This is both good and bad, personally I wish to control unit based actions/decisions to a very great degree.


    I'd be willing to believe they also have certain thresholds/adopted behaviours with random factors for adoption, construction and recruitment based on the information about Rome II's AI. Even though it's important to note that the AI has a preference for units which have a larger recruitment priority than another. I'll state again that the recruit priority seems to scale on a range of negative 100 to positive 100. With other factors being the financial situation and recruitment pool options alongside its current orders/priorities within the CAI decision file. It could very well be that there are other inherent factors I am missing like a hidden preference towards siege and naval units.

    If AI adoptions happen in a similar way compared to the player, and they seem too as some factions die out via stagnation. The adoptions for the AI probably have an age threshold (for which the AI will not 'adopt' characters) and perhaps a preference for command stars.
    Also here's some findings by Argantonio while he explored the info contained in the memory. (Excuse his english, it was not his first language)
    Quote Originally Posted by Argantonio View Post
    The time of study, offers his results:
    I present to you the "random numbers generators" of MTWII.
    I have identified four, I will show in this post who works , one of them.
    First a bit of theory:
    All the events of the game they seem to be associate to variability.
    The composition of every soldier of a unit, The animation action of every individual soldier, the decisions in campaign-mode , the own AI of the game.


    These variabilities are produced by computation algorithms , and determine all the aspects of game.
    subroutine 01127EA0 , and controls between other many things, the assign the different mesh groups of a individual soldier , for to the soldiers seem to be different.
    True .... remenber
    Unit_Model file mesh
    mesh type example Head
    mesh groups ex. Head_12 Head_13 Head_14


    The mechanisms of generation of random numbers that are in use in the majority of the Informatic systems are actually pseudo-random processes
    http://en.wikipedia.org/wiki/Random_number_generation
    http://en.wikipedia.org/wiki/Pseudor...mber_generator
    http://en.wikipedia.org/wiki/Linear_...tial_generator
    http://en.wikipedia.org/wiki/Pseudorandom_numbers


    A pseudo-random number is a number generated in a process that seems to produce numbers at random, but it does not do it really. The sequences of pseudo-random numbers do not show any regularity from a statistical point of view, in spite of having being generated by a completely deterministic algorithm, in which the same initial conditions produce always the same result.




    I present to you a small precious.


    01127EA0 / 8B01 MOV EAX,DWORD PTR DS:[ECX] (guessed Arg1,Arg2)
    01127EA2 69C0 FD430300 IMUL EAX,EAX,343FD
    01127EA8 05 C39E2600 ADD EAX,269EC3
    01127EAD |. 8901 MOV DWORD PTR DS:[ECX],EAX
    01127EAF |. 8B4C24 08 MOV ECX,DWORD PTR SS:[ARG.2]
    01127EB3 |. C1F8 10 SAR EAX,10
    01127EB6 |. 56 PUSH ESI
    01127EB7 |. 8B7424 08 MOV ESI,DWORD PTR SS:[ARG.1]
    01127EBB |. 25 FF7F0000 AND EAX,00007FFF
    01127EC0 |. 2BCE SUB ECX,ESI
    01127EC2 |. 83C1 01 ADD ECX,1
    01127EC5 |. 0FAFC8 IMUL ECX,EAX
    01127EC8 |. 83E9 01 SUB ECX,1
    01127ECB |. B8 03000180 MOV EAX,80010003
    01127ED0 |. F7E9 IMUL ECX
    01127ED2 |. 03D1 ADD EDX,ECX
    01127ED4 |. C1FA 0E SAR EDX,0E
    01127ED7 |. 8BC2 MOV EAX,EDX
    01127ED9 |. C1E8 1F SHR EAX,1F
    01127EDC |. 03C2 ADD EAX,EDX
    01127EDE |. 03C6 ADD EAX,ESI
    01127EE0 |. 5E POP ESI
    01127EE1 \. C2 0800 RETN 8




    From a seed, it realizes a multiplication and a sum, and there assigns an entire positive number, that this in the range that we determine. ( 3 Heads 0,1,2 Arg1, 0 Arg2, 2)
    In the memory the mesh groups are placed arranged in mesh type position, since the drawing shows, the subroutine generates a number, and this will be the chosen mesh groups of a model.
    Attachment 103709
    By means of a Debuger ( Ollydebug ) I can see the assignation process step to step and assign the mesh groups that I wish for every individual soldier.


    I propose a simple exercise , we modify the algorithm so that it multiplies for 0 and adds 0, the result of generated number will be always 0.
    Attachment 103710Attachment 103711Attachment 103713
    The individual soldiers are equal composed on mesh groups that first appears in the file mesh of every mesh type
    The composition of trebizond_archers_ug1_lod0.mesh are
    Hands Hands01 Arms Arms 1 Body Body_04 Legs Legs_06 Head Head_08
    Helmet helmet_06Helmet Object01Hands Hands 2Head Head_12
    Head Head_13Head Head_14Arms Arms 02 Arms Arms 03Legs Legs_09
    Legs Legs_10Body Body_15 Body Body_16secondaryactive0 sword secondary_3 sword
    secondary_4 sword secondary_5secondaryactive1 sword secondary_9 sword secondary_10
    sword secondary_11shield0 small round plain_18 round plain_19 small round plain_20
    small round plain_21 small round plain_22 small round plain_23 small round plain_24
    small round plain_25 small round plain_26 small round plain_27primaryactive0
    composite bow_40 composite bow_41 composite bow_42equipment0 quiver_67
    quiver_68 quiver_69


    with random number 0 , all soldier are
    Hands Hands01 Arms Arms 1 Body Body_04
    Legs Legs_06 Head Head_08 Helmet helmet_06
    secondaryactive0 sword secondary_3 shield0 small round plain_18
    primaryactive0 composite bow_40 equipment0 quiver_67


    Attachment 103714


    But that's not all, also controls the Non-Combat animations (stand, taunt) all soldiers do the same.
    His control is subroutine 01127EA0
    Attachment 103717
    All soldiers animated by MTW2_Musket_taunt_1.cas


    I'm sure that the success or failure in combat, the effectiveness of an arrow impact are guided by these or similar mechanisms, do you find interesting?

    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
  •