Results 1 to 30 of 121

Thread: Game AI stuff (1.5)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Game AI stuff (1.5)

    Bit of a recap/update.

    Brigands/Pirates

    I've seen posts elsewhere about what value in the strat file stops brigands/pirates. My testing shows:

    0 = most
    50 = rare
    99 = still get some

    It may be related to region size (number of fertile tiles?), hence why lower values may seem to work for some people. On the simple map my 15x15 tile regions still get them occasionally with a spawn value of 99. The 5x5 tile island regions never get them.


    Pirates

    Pirates are critical to ai naval expansion as the ai only seems to target overseas regions if they have no available land targets. (Availability includes ceasefires/alliances making adjacent land regions temporarily unavailable.) There is usually only a short window where the peace holds and naval expansion is an option. The ai,

    1) Often builds ships specifically for naval expansion and often only one ship.
    2) Once built moves the ship to its waiting-for-an-army spot (outside the safety of a harbour).

    This means they are often attacked and retreated by pirates and often sunk with the invading army on board. So basically, because of pirates, new wars usually break out between factions faster than they can mount a successful naval attack and so the faction drops the naval expansion option and goes back to land expansion.


    Slave faction building units

    I said above that in my simple map the only rebel regions that built units were the ones adjacent to a faction region at the start. This was a coincidence. What happens on my simple map is the slave faction only builds units in the regions with romans as the faction creator. Possibly unit size/cost? (edit: on my simple map the faction creator in the regions file is either romans or britons.)


    Name bug.

    Pretty sure now there are two separate problems.

    What definitely happens in my testing setups is if a faction can't find its target region then the first stack they produce will not move once it moves out of the city to that settlement's sentry spot. If the captain of that stack then gets promoted you get the name bug (where the console says "error name not found" when trying to use move-character) but this won't happen if every region on a map can path-find to the settlements of each of its adjacent regions. Or at least the settlement it picks as its first target. Another faction taking the settlement breaks this stall.

    Separate to this there is definitely a stall that can happen after fighting a battle. After looking for this specifically on my simple map it can happen to a stack that is general-led and not only to captains i.e it is not a man-of-the hour version of the name problem, not always anyway. (There may be a problem with names as well as some other after-battle bug as very occasionally you get the name error when trying to move a stack stalled by a battle.) Otherwise this stall seems to be broken by any kind of movement, including using move_character or an advance/retreat from a subsequent battle.

    It is only critical to the ai faction when the stack involved has been given a settlement to target as the ai designates one stack as the primary attacker and will not siege the settlement while the primary attacker is stuck. Also the ai only targets adjacent regions so if the targeted region is the only target available the whole faction stalls apart from chasing brigands. They won't target available naval expansion regions either when stuck like this.

    There may be a way to fix some of this but it will not be easy as the stalls happen too inconsistently to find out what might be the common elements.

    On my simple map, starting the britons/romans in the same region, the britons do consistently get more of these stalls. Without me moving the stuck armies the britons usually fail to get all the land regions (on average they get stuck on 1-3) whereas the romans only occasionally fail to get all of them and usually the most they are stuck on is one region. So maybe some clue in that.


    Edges

    The ai seems to have problems with map edges, at least the right hand and bottom edges. If enemies (brigands) are close to the edge the ai will send stacks that seem to get stuck as they approach. Sometimes the enemy stack will be far enough away from the edge to be attacked once but when it retreats the ai army can't seem to follow. In an extreme case a brigand army retreated right back to the right hand edge and the ai army stalled. I moved the ai army to the tile directly to the left of the brigands and the ai army didn't attack. However when i moved the ai army also to the map edge, one tile below the brigands, they did attack and then carried on. Will test whether having some impassable terrain on the edges cures this.

    Region size may effect this.


    Region Boundaries

    I had chunks of the vanilla map working well with the ai expanding without any hitchs until i accidentally messed it up completely. I thought originally it was because of all the woodland i scattered around out of boredom but i don't think it was now. I'd changed some region boundaries not thinking they would effect the path-finding but they do, sometimes in very weird ways. The strangest was armies moving to Tingi suddenly deciding to not cross one of the bridges any more and instead to make a V shapped detour around the river source back to the road on the other side of the bridge. Will need more testing but two things to look out for specifically are:

    1) Parts of a region that can't be reached from that region i.e an army needs to move into another region first then back into unreachable part.

    2) Shared boundaries over impassable terrain e.g mountains. if you have two regions whose border is mountains then the path-finding seems to change depending on whether one region has all of it inside its region, the other does, or they share it.

    The first in particular seems to be able to mess up path-finding between regions. Will try and create a clear example with my simple map if i can do it deliberately (very easy to do accidentally :) )
    Last edited by nikolai1962; 05-01-2006 at 23:22.
    It's not a map.

  2. #2
    Chief Biscuit Monitor Member professorspatula's Avatar
    Join Date
    Oct 2004
    Location
    Inside a shoe.
    Posts
    1,158

    Default Re: Game AI stuff (1.5)

    Very fascinating and indepth research. Well done. How you have the patience, I don't know, but we're all grateful for your efforts for sure!

    The thing that bugs me is that all this research is the work of one person. Now surely CA had a whole load of people doing the same kind of tedious testing? I assume they also had a bunch of extra console commands which could tell the programmer/tester the current status/goal of a stack, so if the stack was stuck, they'd have an indication why. With such resources how did some of these AI problems make it into the game, and still not be resolved? You don't even need to go into the depth you did to notice how the AI never targets some settlements (Tribus Sakae) and gets stuck in the desert with stacks it doesn't know what to do with. Obviously the AI will never be perfect, but obvious problems have been around with every version of RTW.

    I've long been a believer of adjusting the campaign map to provide 'stepping-stones' for the AI armies by adjusting the position of settlements and adding/removing regions to increase their expansion potential, but I never really put much effort into it, and with the 1.5 patch assumed many of the existing problems were long gone, and to be fair, some are. I think realistically, unless CA decide to release another patch to improve the AI to something resembling acceptable, spending hours and hours tweaking maps hoping it will make all the difference could in some cases just not be worth it. The player's own actions will affect how some of the AI factions expand, and even though say Carthage expands well, there's still a lack of sea invasion from other factions in the maps you show. The AI is too rigid in structure and it clearly needs a kick up the toga. It's inability to deal will multiple threats and targets is probably why, in part, CA separated the Romans into 3 competing factions (and the Senate) so collectively the Roman empire would expand in all directions and not just get stuck in Gaul for the next 100 years.

    Good luck with your continuing research.

    Lets hope CA have improved things greatly with MTW2, or it'll be another reminder to us all that the AI isn't up to the job of coping with a non-Risk style map.
    Improving the TW Series one step at a time:

    BI Extra Hordes & Unlocked Factions Mod: Available here.

  3. #3

    Default Re: Game AI stuff (1.5)

    Ty,

    I don't really have the patience unfortunately. I get totally sick of it very fast but i have developed a "need to know" whether the campaign ai is capable of dramatic improvement by following some simple map rules and maybe a bit of minor modding. I think it is but working out specifically what those rules are rather than my current vague ones keeps bugging me to come back to this. I'd much rather be playing

    I think the reason CA didn't pick up a lot of these is partly because they are really hard to spot on a normal map if you are actually play-testing instead of sitting on an island clicking end turn and watching other factions move. On the other hand it seems to me they badly need to have a very simple test map and people doing what i did. I bet a lot of these bugs are very minor rounding error type things.

    With the vast improvement in battle ai of 1.5, the battle and immersion improvements of various mod teams, that only leaves good campaign ai as the big hurdle to a scary immersive strategy game.

    It is very tedious though.
    It's not a map.

  4. #4

    Default Re: Game AI stuff (1.5)

    dont want to teach a good modder to suck eggs but you know about the -ai command dont you. In your shortcut properties add -ai at the end of the line to have the game play itself. makes it easier to just sit back and watch the game unfold.

  5. #5

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by shaggy1973
    dont want to teach a good modder to suck eggs but you know about the -ai command dont you. In your shortcut properties add -ai at the end of the line to have the game play itself. makes it easier to just sit back and watch the game unfold.
    I'm not a good modder at all I just randomly change stuff to see what happens. If anything works it is sheer luck So ty for that, i will try it (had heard of the -ai switch once but forgot)


    have you tested wether lots of movement points (MP) decreases pathfinding problems? If so you might want to test giving AI characters a movement bonus trait when they have not used any MP for a few turns and are not in a settlement; they are stuck. The sudden increase in MP might open a different path
    Comment from duke john i just re-read. Originally i wanted to see what caused the stalls so i didn't want to just increase movement distances in case it worked (if that makes sense). However now i know for sure that some ai stacks stall for some reason after some battles and that the ai stacks should nearly always be moving if they are at war with anyone then messing somehow with the traits of generals who are outside a settlement with full MP for a number of consecutive turns might very well prove to be a solution somehow. Hmmm
    It's not a map.

  6. #6

    Default Re: Game AI stuff (1.5)

    Hands Duke john a balloon


    Update in a bit when i have worked out how to make a new trait
    It's not a map.

  7. #7

    Default Re: Game AI stuff (1.5)

    A partial solution to the post-battle stall that effects the AI so badly and some other stuff. A lot of the images are unneccessary to the conclusions but they are useful to me to look back on to remind myself of things to look into more.

    Post-Battle Stall

    I wanted to clear up a few of the things I'd been noticing to reduce the size of the list of things that need further investigation. The post-battle stall was the most confusing so i started with that. On my simple map I set the romans up in Tarentum where they had just one available adjacent target region. This time i gave them a small starting stack as i wanted them to attack on the first turn a small stack of rebels i placed just to the west. The idea being to see how often they stalled and if it was just after losing or if it also happened when they won and if there were any common elements on the occasions when they stalled. The idea for setting them up with just one available target was to (hopefully) ensure their first stack had orders to attack Rome as it seemed to be only stacks with orders to attack settlements that stalled if they got into a battle before reaching their target.



    The consistent pattern over a few test runs was the starting hastati would attack and win.



    On the end turn their captain would be promoted.



    And then they'd stall. The original stack would remain stationary while the roman ai produced a few more units. Those units would move to Tarentum's sentry spot.



    On the next end turn the second stack's captain was promoted.



    The turn after the second stack was *ready* the stalled stack moved to Rome.



    This happened consistently 3-4 times and wasn't what i'd been expecting. Neither the always stalling, stalling after a win or captain's stalling. I wish i'd thought of testing it like this before instead of trying to guess what was happening when dozens of stacks were on the move making it too confusing.

    This led me to thinking (wrongly) that maybe the stall was something to do with the ai re-assessing all it's stacks movement orders when a new stack was formed and that the permanent stalls i'd seen were some side-effect of that going wrong sometimes

    I moved the starting rebels left into the rebel region to see if things were different if the romans had a general led army (because if the rebels were outside roman terriotory the roman ai wouldn't attack first turn and instead would move their starting hastati out of the city and then promote the captain before moving). This didn't work as the romans bypassed the rebels on the way to rome and then attacked afterwards.

    Next step was to try to set up the starting armies so the romans would lose the first battle a lot to see if that made a difference. So the rebel stack got a general and 9 exp warbands.



    This made the romans lose a lot and retreat to rome but they never stalled here. They just attacked and won the next turn in a second battle.



    The next end turn the captain was promoted.



    On the first test of this setup the same thing happened as before. After their victory the fist stack stalled until a second stack had been built.



    The turn after they moved to Rome.



    Except on the next test it wasn't the turn after the new stack had been built (note dates).



    Ran it a few times and got a semi-random number of turns before the first stack moved (between 1-4).

    Then thanks to Duke John making me think about movement points instead of focusing on names i spotted the common element that made both this setup and the previous one make sense. The first stack moved after its stall the turn after the slave faction built roads in the rome region. It was just coincidence that this mostly coincided with the roman ai building its second stack.

    To double-check i made basic roads cost 40000. The slave faction didn't build roads in the rome region and the roman ai never got unstalled. (Which may explain why the ai problems were more pronounced when i was first trying out building mods that included much more expensive roads.)



    Following Duke John's suggestion I added a trigger for a trait that gave extra movement points (Energetic it think) that fired if a general ended his turn outside a settlement with full MP.



    This unblocked the stall (in this case). I wanted to check if it was somehow the change in their movement potential that unstalled them or something else so I then changed the base MP in the descr-character.txt from 80 to 100. This stopped them stalling too (in this case).

    Lastly, as this seemed a bit weird, I added a load of swamp between rome and tarentum to increase the movement cost. In this test the stack remained stalled even with the extra base movement points plus the added 10% when the trait was triggered. They only unstalled when the rome region built roads (i'd changed the cost back to 400).



    So i think this post-battle stall gets unblocked when the stack can reach its target in one turn's worth of MP If it takes multiple turns they stall. So if any combination of factors, roads, extra MP, advancing one tile after a second battle etc, brings the stack within one turn of its target then they get unstalled.

    Increasing MP overall may be a good thing in itself and help a lot of these problems but regardless of whether you want to do that in your mod or not i think to greatly reduce the number of post-battle stalls all mods need something like:

    A trait (preferably AI only) with incremental levels all giving +10% MP, so the first level they get +10%. The second level they get +20% etc and it keeps going up until they get unstuck. (nb I don't think i've ever seen this happen a long way from a target settlement. The way you can tell which is the stalled attacking stack for an untaken settlement is that it is the one that is close by but not moving.) The trigger being an ai stack ending its turn outside a settlement with 100% MP firong evry turn they are still stationary and increasing the trait every turn. (May be better if slave faction was excluded as otherwise brigands might be retreating for ten minutes.)

    Then, and this is the bit i don't know how to do, preferably the trait is reset to zero when they end their turn with less than 100% MP.

    There are some cases when the ai has a reason for being outside a settlement and stationary (like guard mode or waiting for a ship) but i don't think them getting a few extra MP in those situations will unbalance things.

    This MP solution also explained why the britons stalled on up to 3 (of the 18) land regions on my simple map whereas the romans on average only stalled on 1, if any. Nothing to do with names but to do with the fact that the roman faction gets more traits with extra MP.

    I don't think this will stop all stalls, especially the path-finding type ones from retreating behind mountains etc, and i *think* there may be other types of glitch related to battles too but i'll finish my incremental MP trait and see if the britons can consistently take all the land regions in my simple map with that trait in place.


    Brigand spawns.

    While i had my swamp there i wanted to test another idea.

    Brigands only spawn on faction owned terriotory and a spawn "event" only occurs on the rebel turn if there aren't any rebel stacks in that region. (An event may include multiple spawns in the same region though.) i wanted to see if it was related to the number of fertile tiles. I set the brigand spawn rate to 0. None spawned until the roman ai killed the placed stack. (Otherwise brigands always spawn the first rebel turn if the rate is et to 0.)



    When the roman ai killed that stack the tarentum region got 3 spawns. It was consistently 3-4 spawns every "event" after the romans had cleared the previous stacks.



    When eventually they took the mostly swampless rome region it was consistently 6-7 spawns per event. (Something I'd noticed previously when testing the effect of different spawn rates on the ai expansion speed.)



    So I'm pretty convinced brigand spawning is related to a combination of the spawn rate and the quantity of fertile tiles in a region.

    What i was actually hoping was that brigands would only spawn on or near fertile tiles in the hope that i could use that in large desert/steppe regions to make them spawn closer to roads/settlements and therefore make it easier for the ai to chase them but they seemed to spawn in the middle of the swamp just as much.


    Minor map glitch.

    In one of the earlier posts i mentioned a stall that happened on completely diagonal paths from attacker to settlement (possibly just a side-effect of square regions). Attacking the region SW of capua, from capua, a stack will head diagonally until it hits the forest.



    Then the next turn it will move only one tile (west) then carry on normally. I just mention it as if you watch your map and ever see a stack only move one tile on its path it is a sign that the path-finding ai is almost stuck and in some cases there might be something you can do to fix it. Not all.


    New river bug

    This illustrates a stall that won't be solved by an extra MP trait. Originally the ai had a problem crossing the bridge to attack the settlement of my mega-region. I fixed it by adding some dense forest to the tile it kept moving back and forth onto instead of moving onto the bridge. However in the case shown below a brigand stack had spawned in the mega region in a spot that made the roman army chasing it need to move in a sharp upside-down V path with the apex at the bridge. The roman stack looped between the position shown, up to the tile west of the bridge, onto the bridge, and then back down to the original position.



    You see this occasionally where an ai stack is looping between 2 or 3 positions. I don't know if a general increase in MP would help this sort of thing in all cases but the triggered trait would never fire as stacks like this aren't stationary.

    Now i know more about path-finding i'll have to see if i can find a better solution than the dense forest.

    Odd naval thing.

    I've seen this a few times in games where a faction would land a small stack by sea and then not attack.



    The Iberians do it on palma a lot. I'm not sure if it is an explorer stack or a supporting army stack that somehow got to the island first before the designated attacking stack arrived.



    Just an odd thing i may look at again sometime.

    ~~~

    The main thing is the post-battle stall. After fixing path-finding between settlements and reducing rebellions this is the third biggest cause of the ai under-performing I've seen in my testing.

    ~~~

    Finally, a complete pointless thing but it made me happy lol. From before i messed up the path-finding changes I'd made on the vanilla map.



    (It took them a while though)
    Last edited by nikolai1962; 05-03-2006 at 03:06.
    It's not a map.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO