Results 1 to 30 of 121

Thread: Game AI stuff (1.5)

Threaded View

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

    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