Page 1 of 5 12345 LastLast
Results 1 to 30 of 121

Thread: Game AI stuff (1.5)

  1. #1

    Default Game AI stuff (1.5)

    10th anniversary update post

    A lot of my earlier posts are only semi-correct as they mostly revolve around observed symptoms of the problem rather than the root cause. I don't want to delete them but to avoid confusion it's best to skip to the most recent update post which is currently post #97, link below.

    https://forums.totalwar.org/vb/showt...post2053771349


    ######

    (Edit: This thread gets gradually more accurate as it goes on. Condensed the map path-finding results so far here: https://forums.totalwar.org/vb/showt...51#post1485851 Will make a seperate condensed post for the non-map related stuff later.)

    ######

    Tested out with a slightly modded vanilla 1.5 and then seemingly confirmed (as much as is possible) in an un-modded vanilla 1.5


    At the start of the game the AI will target one or more regions adjacent to one of its starting provinces. The number of targets depends on its starting armies and positions.

    It will always go for a rebel target first even if you set the faction's core_attitude to rebels to be lower than to a neighbouring faction (maybe not true if it is really far away and has a much larger garrison than best available faction region but very heavily weighted towards preferring rebel regions). In some cases if a faction starts at war with an adjacent faction it may *also* target a faction-held city but it's first target seems to be always rebel and usually the second target also if there is one. Generally, if a faction has a land border with a rebel region and isn't at war with another faction it will always go for the rebel region regardless of core attitudes and starting neutral to rebels.

    The initial target selection seems to be based on the number of ai stacks that have spare units after leaving behind a garrison. So each large enough stack will move to a target. If the moving units are deemed too small for a target then they move towards one of the settlements that has been targeted by a big enough stack (even if on other side of faction terriotory). The original targets are *always* the same for the same starting conditions. If none of the starting moveable stacks are deemed big enough the faction waits while it builds units. The ai rarely seems to join existing armies first and then attack. If a bunch of starting stacks move towards a target they will stop and re-assess the situation when the first one reachs and besieges it.

    If another faction targets the same province and reachs and besieges it first then if the moving faction is hostile they will often attack the besieger and start a faction war. If they are allied/non-hostile they usually sit and wait for the outcome of the siege. Sometimes the whole faction stalls at this point. Mostly the faction doesn't stall but often/usually the stack that moved to the target will stall, even if the the other faction loses its assault and the target becomes free to attack later. The stack will eventually unstick but it may take many turns. This can cripple a faction if it is a small faction's main force.

    Also if the attacking stack reaches its target and loses its assault then that stack will often stall until something else happens to unstick it. Small factions with only one initial moving army will then be stuck until they build a new force or another force that was already moving to the target sieges it. Small factions can be completely stalled by this too.


    The determinants of target regions:

    1) Size of ai stack after leaving behind a garrison
    2) Distance
    3) Target garrison
    4) AI attitude to faction_creator specified in descr_strat e.g can make ai switch choice between intiial target if faction is allied to faction-creator of one target and hostile to faction_creator of a another.
    5) Clear line of sight between settlement/stack and target settlement. This doesn't mean FOW, spies etc *seeing* the settlement. It seems to require an unblocked straight line between stack/settlement and settlement. Hills, mountains, wonders block this, maybe woodland too.

    How the determinants balance against each other is too hard to work out i.e how important faction_creator is compared to garrison size etc. All i can be sure of is one ai faction would always go for the closer of two rebel settlements (with the exact same garrison) if both targets had the same faction_creator but would always target the further one if i made the faction_creator of that city a faction they were more hostile to.


    The factor that outwieghs all the others is LOS. If there are low hills etc between a target city and all the adjacent faction regions/stacks then they will ignore it completely at game start. This is not surprising when you consider that unconquerable settlement mods do it by surrounding the settlement with hills. (Didn't occur to me until i saw it though.)


    Palmyra on the vanilla map is an example of this. Factions don't seem to target it unless they already have arabia or bostra. The hills between palmyra and the starting positions in the other adjacent regions seem to prevent it being targeted.

    The vanilla seleucids are a good example of how this effects the game. They don't attack the obvious targets of Halicarnasus or Palmyra early on. Halicarnasus because the nearby stack isn't big enough, Palmyra because they don't have a clear LOS (placing spies at start does't help this). So the region they select as their first target is dumatha/arabia because it is closest (in a straight line not in the amount of time it takes to reach) from their stack in seleucia. Because it is so far away from the start location of the seleucid units by the time they get a stack close to attacking it Parthia has usually already got there and egypt, pontus and armenia have already expanded and started to look for new targets.

    This initial target selection cripples the seleucids from the start and makes the big yellow steamroller almost certain every game. Re-arranging the initial seleucid start location to either make the garrison at sardis big enough to move against halicarnasus or placing some seleucid units on the other side of the hills so they see and target palmyra makes sure the seleucids have a good chance of grabbing those two regions before the inevitable multiple attacks start. Usually you still get a big yellow steam roller but it takes a lot longer and isn't a foregone conclusion.


    Anyway, from a general modding point of view some suggestions.

    1) Always have an island or remote faction somewhere for testing how the ai performs.
    2) Run the game with FOW off and find each factions starting targets, then watch for:

    a) Factions picking a target very far away because of LOS issues.
    b) Starting stack just big enough to target a rebel city but too small to consistently win the siege. Small factions may stall here.
    c) Small starting stacks that set off for a target city regularly hitting rebel stacks that are too big to defeat or which cause too many casualties. Sometimes the ai stack will stall here, sometimes it may go on to lose the siege (cos of casualties from rebel battle) and then bounce off and stall.
    d) Two factions picking the same initial target and then getting into an early war because of it.
    e) Generally, small (and possibly all) factions will start off better if set up with one main army and several small garrisons rather than lots of small armies as they seem to decide what to do on a per stack basis and lots of small armies will assault, lose and stall a lot.

    The other big ai problem is path-finding.

    After fixing any problems with the ai faction's initial targeting run some long games with your island test faction where you just click end turn a lot and watch for those regions the AI has trouble reaching. Any kind of impassable terrain can cause the ai problems often depending on what direction they are expanding from, river crossings, mountains, hills, wonders etc. Sometimes it will be fine from the region to the west of a target but not the south etc. Simple map tweaks can often fix these. Eventually you'll get a situation where the AI stalls far less often which will make the game a lot more challenging i think.

    A seemingly surefire way to know a faction has a path-finding problem is if you see a large cluster of single-unit stacks not moving over a number of turns. Working out why it is stuck is another question :) Sometimes it is obvious though.

    Core-attitudes, "prefers naval invasion" etc

    These seem to have limited (or very limited) effect. The reason seems to be that initially the ai will target rebel regions. Eventually they'll run out (though you can deliberately make them ignore some regions by moving the settlement far away) and then they'll decide to attack somewhere else. Core attitudes etc may play a part here although the main determinant seems to be relative strength/weakness. However once a war starts between two factions both sides seem to give massive weight to any adjacent enemy region until the war ends. At that point core-attitudes etc may briefly come back into play again until the next war starts. (Maybe if a core-attitude is set to be 600 i.e the same as being at war it will have more effect).

    In other words the core attitudes have an effect but only really when the ai faction is at peace and thinking about its next move.

    The ai will mostly make naval invasions when it doesn't have an available land target. This happens mostly when they are blocked in by allies/protectorates that they don't want to attack. In this case they'll land quite far away if neccessary. Some landings never seem to take place from certain directions (LOS again i think) e.g factions holding greece never seem to land on crete, though they will on cyrene occasionally, whereas egypt will land on crete sometimes if they get blocked in by alliances. Again, i *think* it is to do with the hills/mountains from different angles. One settlement will have a clear LOS to a region while another won't so only a faction holding the right regions will consider it. There does seem to be a distinction here between whether the region is rebel-held or faction-held. Rebel regions with no clear LOS from anywhere (like the original iberian capital if it goes rebel) can remain rebel the rest of the game, whereas if it is faction-held it is less likely.

    The presence of the senate over-rides some of these problems in the vanilla game. Also the 3-family split makes the romans consider naval landings more because the scipii and brutii are blocked in from the start by their roman allies. A unified roman faction has more problems because it is not blocked in unless it makes an ally/protectorate of the gauls.

    (I haven't got BI as none of my fave mods use it yet but i wonder if they've simplified the LOS between regions and that is what improves the ai.)


    Some simple regions/settlements modding stuff that works.

    1) Make a huge sahara that touchs the sea between egypt and carthage terriotory so their border region lies along the sahara edge. Then move the sahara settlement so that it is a long way west but close to its northern border with the coastal african regions. The distance between settlements east/west makes carthage/egypt ignore each other completely but the settlement is still close enough to the coast for any faction that holds one of the coastal regions to target sahara (or move it to bottom left corner so both carthage and egypt ignore it and let it stay rebel).

    2) Have long vertical steppe regions with the settlements in the far north. The short distance between settlements east/west makes the steppe factions fight over them but the large distance north/south makes the armenians (for example) ignore them and expand south instead. The steppe factions will still come south when they run out of targets and the settled factions will still come north if they conquer all the southern regions but not until they have no closer alternative targets. Otherwise factions like the armenians waste their time (imo) sending infantry armies (very very slowly) way up north instead of fighting over richer southern terriotory.

    3) After watching where the ai gets stuck with rivers, add a ford.


    General things:
    Read somewhere the ai never moves its capital. It does in 1.5

    The settlements of regions specified in the victory conditions are visible when playing that faction (which is neat imo).
    Last edited by nikolai1962; 01-03-2018 at 19:22.
    It's not a map.

  2. #2
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Game AI stuff (1.5)

    Great research, thanks for this.

    Hadn't realised importance of faction_creator, will have to re-look at our descr_strat!

    Re: pathfinding, do you know if there tend to be more problems with large blocks of impassable terrain or with scattered obstacles?

    Re: BI, unforunately can't remember vanilla results but have since been playing with adapted Icetorques/Bare Bones map (which is much larger than vanilla) map and AI factions don't seem to target rebel provinces in Norway/Sweden peninsula or Ireland (200 turns plus & all other provinces occupied).
    Not used mods before? Looking for something small and fun?!
    Download the:

  3. #3

    Default Re: Game AI stuff (1.5)

    faction creator is in the descr_regions - the faction creator in the strat just takes care of the way the province looks on the strat map/battle map - i have been using a combination of victory conditions and region creator yo guide the ai into where i want it to attack from the start. it works very well (i dont have any rebel provinces in at the moment to make things complicated)

    works well :)

  4. #4

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by Makanyane
    Great research, thanks for this.

    Hadn't realised importance of faction_creator, will have to re-look at our descr_strat!

    Re: pathfinding, do you know if there tend to be more problems with large blocks of impassable terrain or with scattered obstacles?

    Re: BI, unforunately can't remember vanilla results but have since been playing with adapted Icetorques/Bare Bones map (which is much larger than vanilla) map and AI factions don't seem to target rebel provinces in Norway/Sweden peninsula or Ireland (200 turns plus & all other provinces occupied).
    I'm going to experiment more both with the path-finding and the target selection but at the moment it seems like the ai tries to figure a straight line path and doesn't like situations where they have to move away from a target to reach it e.g going round a big block of dense forest or moving along a river to a ford if it means getting further from the target.

    Some rebel regions can stay rebel for sure. All the ones I've seen so far are either islands or have some other path-finding issue. Garrison size and distance must be (?) taken into account too but i think the anti-rebel priority is quite high so the distance/garrison need to be large to outweigh this.
    It's not a map.

  5. #5

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by shaggy1973
    faction creator is in the descr_regions - the faction creator in the strat just takes care of the way the province looks on the strat map/battle map - i have been using a combination of victory conditions and region creator yo guide the ai into where i want it to attack from the start. it works very well (i dont have any rebel provinces in at the moment to make things complicated)

    works well :)

    I'll check this again as i have a habit of changing the creator in both regions and strat so they match.
    It's not a map.

  6. #6

    Default Re: Game AI stuff (1.5)

    Great research!
    This will be very useful:)
    Thaanks


    The Fourth Age: Total War - Map Manager, Editor and Coder

  7. #7

    Default Re: Game AI stuff (1.5)

    the ai isnt obsessed with rebels. ive put alot of rebel factions along the border of gaul and they still come for italy. need to use province owner/creator and victory stats and they still go where you want them to. oh and the rebel garrisons are all really strong.

  8. #8

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by shaggy1973
    the ai isnt obsessed with rebels. ive put alot of rebel factions along the border of gaul and they still come for italy. need to use province owner/creator and victory stats and they still go where you want them to. oh and the rebel garrisons are all really strong.
    I was wrong in the first post saying the ai *always* goes for rebels first. It is more complicated than that but at the start the rebel garrison needs to be really strong (stronger than the entire starting army of the faction they are at war with?) or very far away/on an island/in a region the ai has a problem path-finding to, for the ai to ignore them. In some cases if the ai has only one choice between a very strong rebel region and starting a war they sit and build troops then eventually their stacks start moving to the rebel region.

    ~~~

    This is turning into more of a WIP than a guide as i keep seeing new things. For now I'll add stuff that was wrong in new posts and then edit the first post when it is all confirmed.

    Update:

    Forgeting islands for a bit (I'll go back to them later) the problem between two adjacent land regions isn't that they have no clear LOS exactly. Roads are the clue. The game picks a route for a road between any two regions that share a border. The exceptions are when they only connect at a corner or when the entire border is impassable e.g river with no ford. The game seems to pick the route with the least movement cost from A to B. Hence why hills are avoided where possible. The path of least movement cost is rarely a straight line between the two settlements. The problem seems to be when the path of least movement cost doubles back on itself to some degree so that an army moving along that path would at one point on its journey be moving away from its target.

    The mods I'd made when i first noticed how often the ai got stuck included much more expensive roads which is why it wasn't as obvious but if you look at the roads to palmyra from damascus, antioch and hatra they all have a 90 degree bend at one point. I think having a "least movement cost" path between two settlements with a 90 degree bend or more causes the ai to glitch. You can alter the path in various ways: changing the ground type, moving fords, moving settlements, rivers etc.

    My updated tip for any new map (or vanilla map for that matter) is to test by adding roads to every region in the strat file. Then look over the map for any roads between two regions that have a sharp bend between two settlements and try to make the path between each pair of adjacent regions go roughly in the right direction along its whole length. The road layout isn't 100% the same as the path the ai would choose without roads as the network tries to link up with other nearby roads going to different regions but it is a good start. When you do edit the paths this way the ai gets stuck much less often and wastes far less time. I've only changed part of the eastern vanilla map so far but you can see when watching the ai how nearly all their armies are moving with some kind of purpose now when fighting in that area.

    Main thing is core attitudes and diplomatic stance aren't enough on their own to stop the ai prioritizing rebels.

    ~~~

    Other factors that influence initial ai moves.

    The ai likes to leave a larger garrison in settlements with no barracks.
    The ai likes to have stronger garrisons in regions with a lot of adjacent regions.

    So if you had an initial setup with mostly garrions and one large army that you thought was big enough to target a nearby region the ai may leave more of that army behind than you thought it would.

    ~~~

    Previous post mentioned Cyrene as a consistent naval landing, it was rebellions not landings.
    It's not a map.

  9. #9
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: Game AI stuff (1.5)

    Nice research work, nikolai.

    As this is WIP thread, perhaps you will be interested in our own experience.

    Our main problem in ITW campaign was to simulate the historical situation before the second punic war, and we focused on romans.
    We wanted that they forget the gauls and try to land in Iberia (of course with naval_invasions yes). We wanted also that the carthaginians tried to expand towards north Iberia, and even trying to reach Italy.

    These are some of our observations:

    - We observed the attraction for the rebel regions... even if the first senate mission was an enemy region. The two regions (rebel and enemy) were in the limit of the roman territories. The mission was canceled in the second turn, and substituted by the conquest of the rebel region.

    - Considering important the LOS of the faction, we put from the beginning a roman fort in Iberia, with a full stack garrison.
    The owner of the region was neutral, but there were rebel regions near there. However, the AI didn't make any movement with that powerful army during 50 turns.
    But the owner of the region didn't attack either the roman garrison. Only garrisoned the settlement with also a full stack army (just in case, I suppose).

    - The situation changed dramatically if romans are the owner of an Iberian region. In that case, they send naval invasions. Thus it is not only the LOS, but it is necessary that the faction owns the corresponding region.

    - Another attempt was to surround the faction with allies. This method was not useful, as sometimes the allies became enemies in the second turn and sometimes the faction stayed peaceful for many turns.

    - We also tried the idea of "super-alliances", including the option of superfaction. This system gave some unexpected results.
    First, two superalliances were built, one with romans as superfaction and the other with the carthaginians. Instead of a more agressive behaviour, both factions remained peaceful, with impressive large garrisons and full stack armies in fields.
    After the first surprise, this behavior is not so strange, as the superfaction takes the role of senate in the vanilla campaign, without expansionist behaviour.
    The other way round seems to be better . If the gauls are the superfaction, then the romans are surrounded by their superfaction, and they try to expand by sea.


    These are not final conclusions (we are also working on this aspect), but they can help to future research (I hope).

  10. #10

    Default Re: Game AI stuff (1.5)

    Monkwarrior,

    Very interesting stuff. The situation you are working toward is similar to me wanting the roman ai (on whatever map) to at least sometimes expand against carthage and spain. As your post says it needs two things, first to make the gauls and romans less likely to fight and second to make the romans look toward carthage/spain and carthage to look towards spain. Somehow i'm sure it is possible and some of the stuff at the end of this post may be relevant to you :)

    ~~~

    I worked out how to take screenshots so this new update may get messy as i work out how to insert them.



    Ok, images work.

    As working this all out on a standard map was too tricky with so many things going on at once i decided to make a simplified test map to get more definite answers (thanks to Myrdaal's great map-making guide). The idea being to create a setup for testing more definitively the effect of core attitudes, distance garrison etc with the ai targeting. As before though, when trying to test this with the vanilla map, it soon becomes apparent that map path-finding glitchs > all.

    The strat file was et up with britons (on an island) and the romans with one city and a very simple layout of square regions with a settlement in the centre, all flat, fertile terrain etc. The first image shows the first path-finding glitch. In this setup what the roman ai does is first build a spy, who sets off, then start building units. When they have 2-3 they target an adjacent city. Rome keeps producing small stacks and sending them off to new targets while the original stacks move on once they've taken their target. What you see is a path-finding glitch that happens when the shortest route to a target is a direct diagonal line. Just past halfway to the target the stack stops and stalls permanently. Not only does that stack stall but the ai doesn't send another stack to the same target (at least not against rebel cities with no garrison, it does under some other other circumstances) so in this test the romans stalled entirely at this point as the only adjacent land regions were targeted by stuck armies.



    The second image shows exactly the same thing on a different test and is posintless but i linked it anyway :)

    Now obviously this is a very weird map but i bet most modded maps have at least one pair of settlements where the least-movement-cost path (gonna call it the LMC path from now on) is a diagonal line. This might even be the effect i saw on the vanilla map with palmyra. The seleucid ai *had* sent an army against it but they'd got stuck and therefore not only did the seleucids not send another army to palmyra they also didn't target any others. Either way it shows how the ai can stall when stacks get stuck on the way to thir targets and how, if there are only a few targets available, the whole faction can stall.

    Just to emphasise the problem even more



    Even if the ai ends up with another army right next to an empty rebel city (for example through chasing rebels) that stack won't attack because that city already has a stack supposedly on its way. The roman stack left of the city stayed there until the next random rebel spawn when it went off to chase. (The swamp was my first attempt to make the ai pick a different route, failed attempt obviously).


    Next thing.



    This shows two things, first is how those blocks of dense forest got round the diagonal bug. I'm guessing this may be something to do with roads not being able to go diagonally while units can so the LMC path for a stack is maybe calculated differently than from the settlement, if the settlments are somehow used to claculate valid targets through calculating the distance between settlements. Who knows, either way it is hard-coded so only thing is to find the spots where it happens and fiddle with the map until it is fixed. Another thing is i noticed when trying to figure this out with the vanilla map that stacks often seemed to stall after fighting rebels but not always. The diagonal thing may be at play here too as they advance/retreat to tiles after the battle and that messes up their path. It may be something completely different though. We shall see.

    The second thing the image shows is another (less serious?) stalling issue. In this case the romans have targeted ariminum but the rebels keep building units there so the romans keep adding more units to the stack waiting to attack it even though they have other adjacent regions that could be attacked easily. This stall gets broken when they have a full stack and produce one more unit. The ai must re-assess at that point because both the big and small stacks move off (not neccessarily at ariminum either). Main thing here i think is if a mod had very expensive units/buildings and started a faction off next to a single adjacent region that had a large rebel garrison or a rebel city that the rebel ai picked to build units in. The ai faction might keep building units until they bankrupted themselves. The original reb garrison might have been small but just coincidentally that city is picked by the rebels to produce units in.

    note: In this setup I had all except the roman and briton starting cities unspecified in the strat file which made them all rebel villages. There were no starting rebel armies. The rebel ai in this setup *only* built units in the regions that started off adjacent to faction cities i.e the four regions adjacent to rome. I've played mods where this didn't seem to be true but maybe it was because they gave the rebs so much money they ended up having built everything possible and therefore built units? Dunno, but in this setup, whether initially garrioned or not the rebels only built units in those four regions adjacent to rome at the start.



    ~~~

    After the big diagonal glitch the next thing was the bridge to the mega region. Obviosly this is a silly and unrealistic map but the solution will maybe be relevant to people with a similar problem on a more sensible map.







    Another (?) case of the problem when there is a 90 degree angle between starting settlement and target settlement (maybe). Either way what happened every test was the romans would send out an army to tribus sakae soon after they took the region with the bridge. It would reach the bridge but not cross and instead would move one tile south one turn then back up again to the tile just west of the bridge on the next and repeat indefinitely. I tried various things but the thing that worked is in image below. Basically you isolate the tile the stuck army moves to in a situation like this and put some impassable terrain on it. After this the romans would move to tribus sakae without a hitch.



    note: Once they'd taken the region roman stacks chasing rebels that spawned on that side of the river crossed the bridge with no problems. It seems to be only when the path is a 90 degree angle exactly. (I know this because for a while i just used the move_character command to get the tribus sakae stack over the river before i thought of using forest.)

    ~~~

    Islands.

    There were some other (more random) glitchs i'll come to in a bit but the next big thing was the islands. Once the roman ai had all the land regions it stopped. They never even built a ship. oddly though the britons ai (when i played the roman side to compare how fast i could get the land regions compared to the roman ai) would take the two islands but not invade the mainland. The original map was like this:



    I tried a lot of things but what worked was this:



    I have no idea why that little bump of land made the difference but it did. The britons would take the north island first then land on the mainland. Once on the mainland with adjacent land regions they didn't go for the second island until it was the last region left (had to move romans there temporarily to check this). Why the ai didn't go for the shortest distance region first is a mystery. I think the ai is a bit odd on the first turn sometimes.

    The romans would take all the adjacent land regions first. Then the middle island closest to the bump, then north and finally south.




    Note: The romans only ever build ships in the port on the bump. Maybe the ai only builds ships in a region that can *see* a potential naval target region?


    Semi-related topic. Before i temporarily gave up tinkering with the vanilla map i got the britons (starting with just one province on britain) to finally land on hibernia by moving the port location. They'd take rebel deva and Eburacum, then Hibernia, then finally when no reb targets left they'd invade the mainland.



    This is just another example of how some regions just aren't *seen*, in some sense, by the ai but when you tweak the map in some way they suddenly become visiable. It seems to me that most of the naval invasion problems are caused by this. Although the ai always seems to prefer adjacent land regions under some circumstances they will mount a naval invasion but it still won't happen unless the map is right.

    ~~~

    After this experience with my simple map i think the way to test your map (as a modder) is...

    Make a dummy strat file with one faction on a remote island (or sealed off with a river) and a second faction with one decent-sized city (no population/unrest problems to confuse things) and leave all other settlements unspecified so they are all rebel villages with no garrisons.

    Reduce brigands/pirates as much as possible ( i set it to 200 but still got a few)

    Start your testing faction in different locations or start each faction one at a time in their capital region and watch it expand.

    Spot the places where it gets stuck. (This will be easy with all rebel villages as the ai only sends one stack for each settlement.)

    Work out how to fix where it gets stuck. Some places will only be a problem from certain directions so best to start the testing faction in various places.

    You can test whether it can *see* naval landing targets by sealing off a set of regions with fordless rivers so that it quickly takes all the available land regions. If it doesn't mount a naval invasion after doing that it means it can't see an available target. Some islands may only be targets from certain regions and not others because of the layout. i am pretty sure now you can tweak the map to make the romans island hop from italy-sicily-carthage and italy-sardinia-palma-spain without any land bridges. Just a question of figuring out what the map glitch is for each step. The ai will still follow adjacent land regions if they're rebel or if they get in a war with a neighbour faction but if somehow the core-attitudes/relative strenghts are set right it seems likely that, at least sometimes, factions will expand more like players.

    One way to test if the romans can path-find their way to carthage or spain would be to use this test strat file method but with a test version of your map with a fordless river between the romans and gauls. If the romans don't land on sicily/sardinia then you know their is a map problem. Once they get past that obstacle see if they find their way to the next stop etc.

    ~~~

    There was a bunch of ai strategy related stuff i saw that i have forgotten now. No doubt it will show again when i finally get to test what i originally started which was how core attitudes affected things.

    Anyway, apart from path-finding problems the ai has a number of other big disadvantages vis a vis the player.

    1) Unrest. When i compared my speed (in game turns) with the romans the biggest difference was caused by how many rebellions they had. The ai doesn't destroy buildings so it couldn't reduce the culture penalty in the way i did (all the regions except rome and the four around it was faction creator britons) so it had lots of rebellions and had to take the settlement two or three times. Seems to me one way to even that handicap out would be if it was possible to mod a happiness bonus that only the ai got as most human players will very rarely get a rebellion. Not sure how though.

    2) Brigands.





    Basically, the ai stacks are always moving with a few exceptions (mostly cos they're stuck but a couple of other cases too). When they have no settlement target all spare stacks go chasing after rebels or enemy armies even if they are far away or if there are other closer stacks chasing the same guys. They even break off sieges sometimes to chase rebs on the other side of their empire. On the one hand brigands seem to be a major cause of the randomness in the game (which is good) but they handicap the ai a lot too. Dunno. Will compare the ai expansion on my simple map with brigands at a higher level and see how much it effects the time it takes for the romans to fill the map.

    3) There seems to be another case where an ai stack gets stuck that doesn't seem to be map related. Normally when i saw an untaken region and a non-moving stack i could use the move_character command and then the stack would carry on to its target. Some stacks still wouldn't move after this. It seems random and will have to check it out more now the map glitchs seem to be fixed. i assumed it was due to losing battles with brigands but not sure now. Current theory is it *might* have something to do with names and epithets. We shall see.

    Anyway, modding map path-finding, unrest and brigands will make the ai a lot more scary imo especially with the improved battle ai.


    That was tiring.
    Last edited by nikolai1962; 04-20-2006 at 06:48.
    It's not a map.

  11. #11
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: Game AI stuff (1.5)

    Woh!
    Impressive work.

    Keep this thread alive and probably the campaign AI will be improved in many mods.

  12. #12

    Default Re: Game AI stuff (1.5)

    Thanks :)

    It is quite tedious in some ways but the end results could be worth the effort i think.
    It's not a map.

  13. #13

    Default Re: Game AI stuff (1.5)

    Awesome stuff Nicolai, keep up the excellent job! Really impressive.

  14. #14

    Default Re: Game AI stuff (1.5)

    Ty

    ~~~

    One of the other places stalls happen semi-often because of how the simple map is set up is shown here.



    A stack seems to head off from Rome with Damme as its target while Ariminum is under siege. The stack sieging Ariminum assaults, loses and retreats but it fine. However the moving stack changes its orders and sieges the now open Ariminum. *If* that stack then later assaults and loses it will retreat to the spot shown in the image. If no-one else sieges Ariminum i think it just goes back (doesn't happen every time so hard to be sure) but if another stack takes over the siege then the original Damme stack goes back to trying to get to Damme from the retreated spot but stalls.

    The second image (despite my poor graphical skills) is an attempt to show my theory of why it might stall here. If the game tries to path find by comparing the distance from target from the tile the stack is on to the distance from one of the tiles the stack could move to, and *if* the path is sort of sideways like it is here then the distance will only be reduced a tiny amount. Maybe there is some kind of rounding error that makes the distances equal so the stack can't find a tile to move to that reduces the distance?

    Path-finding will be hard-coded so doesn't really matter much why it happens but anyway :)



    So anytime an ai stack has a target settlement but breaks off on the way to fight a battle or take over a siege it then has to find a new path to its original target. This is probably what i noticed before while watching the vanilla map. Only occcasionally would an ai stack seem to stall after fighting a battle. The ones that were on rebel/enemy chasing duty are generally fine but the ones that have a specific target can occasionally be messed up. On a normal map there may be other things happen that clear the stall but i'm sure in some situations it causes the faction to stall as it does with this map. Damme is targeted but unreachable by the stack ordered to take it so the ai doesn't send another stack.

    Third image was meant to be something else but just shows my current attempt to get past this by making the blocking terrain more rounded with woods instead of forest at the corners.



    I think i saw this happen on the vanilla map when ai stacks lost an assault against halicarnasus and retreated east but hard to be sure as so many thinhs happening at once on a normal map. Now i know what to look for when i go back to it maybe it will be easier.

    This "retreat" stall (happens mostly with long retreats) is the biggest cause of the ai getting stuck once the general path-finding problems between settlements are fixed.

    The preceding image was meant to show the other semi-regular type of stall that happens. I have no real idea what causes this one. Here a stack moves out of a city to the "sentry" position. Usually the stack then either moves off next turn or waits while it gets more units from the city but in some cases they just stall. If you use move_character the stacks goes off to a target settlement (didn't work here as there were two Captain Aulus) which seems to imply that stack was given a target settlement to attack and it is a path-finding bug again but it happens when there is almost a straight line to the target (Damme again in this case).

    Maybe it is waiting for a unit from the city but the city is too far down the queue for unit-building so it never gets built? Dunno.

    There's a 3rd type that happens too inconsistently to have much clue what causes it. In that case the stack doesn't seem to have a target settlement it just stalls. move_character doesn't unstick armies like this. Only current theory is that it is somehow caused by man-of the-hour events as the ai gets a ton of those with all its captain-led armies? These don't stall the faction though as the stacks don't seem to have a target settlement.

    Next step is to add more rebel garrisons so the ai loses more sieges so i can see a consistent way to fix the "retreat" stall and then go back to the other two afterwards.

    ~~~

    Brigands

    Image shows what happens on first turn when you have brigand spawn rate set to zero :)



    Ai never expands more than one region with that many brigands. Obviously this is an extreme case though.

    As the brigands are so random you'd need to test a lot of times to be sure and i only did it three times with brigands set to 28 and 99. The roman ai fills the land part of the map a bit faster with brigands on 99 but not as much as i thought. That makes unrest move up to the 2nd spot after path-finding as the biggest AI handicap (imo).

    Playing on other maps I got the feeling there were more brigands with the same setting but higher difficulty levels but watching this smaller, simpler map that doesn't seem to be true so the extra cash the ai gets on hard and very hard makes it fill the map slightly faster too. (i'm guessing that is the reason.) So i think hard and very hard counter-balances the brigand handicap (on this map).

    As the ai consistently only uses one ship to transport their armies, and pirate fleets can be so strong, the speed of getting the islands varies massively. I gave up on that and only tested the land expansion speed. AI naval expansion needs less or weaker pirates imo because the AI doesn't build proper fleets often enough.

    ~~~

    I think CA needs to move to hexagons :)
    Last edited by nikolai1962; 04-21-2006 at 06:35.
    It's not a map.

  15. #15

    Default Re: Game AI stuff (1.5)

    Monkwarrior,

    I started looking at the carth-roman thing on the vanilla map before i got side-tracked onto my simple one. There were a bunch of things i thought needed to be done to the map to make it work right (from the carth side) which i'll point out here. Your map is probably different but it may have some of the same problems. I only changed the first one (sahara) as i didn't know how to edit the other map files then.

    1) The AI prioritizes adjacent land regions. For carth this means they spend a lot of time in the desert both south and east and especially if they get into a war with egypt, which they nearly always do. This is a big waste of time imo and stops carthage ever seeming like the regional superpower it is supposed to be. My solution as shown in the image was to make a huge sahara that touched the sea so it was the border region with egypt. Siwa and nepte were too far away from each other for egypt and carthage to ever fight whereas nepte was close to the coastal regions so carthage could take it without a long trak into the desert. I also made nepte low population/fertility and made desert regions (hidden-resource) unable to build lots of pop growth stuff like farm upgrades. This meant it wouldn't keep rebelling, as that was another distraction for the carthage ai.



    With the carthage ai undistracted to the east and south all it needs to do to become land-locked and therefore naval-orientated is to finish expanding west along the coast.


    On the vanilla map it seemed the cartage ai sometimes (not always) had a problem getting to Tingi. The bends in the road shown in the second image are the reason (i think).



    I added a region between Tingi and Cirta because at first i thought it was a distance problem but it still happened some of the time so now i think it is a path-finding glitch related to bends. You need Carthage to take Tingi as Tingi-Corduba works as a naval expansion path to Iberia. I know now that moving Tingi, that ford to the east or something else should clear the path-finding glitch and let carthage target Tingi properly every game without stalling

    With Tingi taken, and the huge sahara blocking expansion eastwards, Carthage becomes a naval expansion faction (ignore sicily for a minute). Its closest naval expansion target is Iberia and so once these things are done Carthage should always fight hard to expand in iberia.

    There is another map glitch here though. When carthage has been pushed out of iberia and is re-invading from Tingi they sometimes land near where i placed the carthage army in the picture. These stacks sometimes seemed to get stalled. After my tinkering with the simple map I'd bet it is because of those mountains between the landing zone and corduba.

    So I'd say to make carthage act like carthage on any map you'd need:

    1) A huge sahara (or something) blocking egypt and carthage
    2) Smaller/closer desert regions to let carthage take them without long slow journeys.
    3) Make sure those inland desert regions don't rebel too much by fixing the pop growth.
    4) Make sure there is clear path-finding along the coast.
    5) Make sure there is clear path-finding between the African and Iberian regions that are closest together.

    Lastly i saw a glitch on Siclily once where carthage had lilybeum and syracuse and got stalled moving to messana. I think it is the bendy road shown in picture below.



    When i get back to tinkering with the vanilla map i think i'll make sicily more triangle shaped with the mountains in the centre so there are three straight-ish roads between lillybeum-syracuse, lilybeum-messana and messana-syracuse. I think this will make sure the ai doesn't glitch here.

    Apart from making messana-italy have a clear naval expansion path (or a land-bridge) i think fixing these things (or the equivalent on other maps) will make the carthage ai much better.

    I think it will be much trickier to get the roman ai acting like historical romans though.
    Last edited by nikolai1962; 04-21-2006 at 08:33.
    It's not a map.

  16. #16
    Senior Member Senior Member Duke John's Avatar
    Join Date
    May 2003
    Location
    Netherlands
    Posts
    2,917

    Default Re: Game AI stuff (1.5)

    Good stuff!

    Months ago I also looked at the strategic AI and particularly at how it didn't merge its armies. I found that a small amount of movement points was bad as it meant that an army could not reach its target friendly army. Increasing the movement points greatly reduced the amount of armies as the AI armies could reach each other within a single turn. I would advise to give AI character a standard increase in MP by the use traits.

    There is also the problem of armies not merging when the total of 2 armies is greater than 20. So complete stacks are rare.

    All of this was tested on 1.2 so things might have changed.

    nikolai,
    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.

  17. #17
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: Game AI stuff (1.5)

    Hi again.

    Fortunately we are working in complementary aspects of the AI, so I think we will advance faster sharing our experiences.

    This post is to illustrate the findings reported before.

    1- Behavior of a superfaction (different from the senate)

    In this experiment, julii were superfaction of other factions, such as greek_cities and this is the result.


    I had never seen so large concentration of armies, and julii were unable to attack the gauls on the north. Their only expansion was Liguria, that started as rebel region.

    In the next experiments we changed the system, and dacia (cisalpine gauls) were the superfaction of julii. In this way the romans have no room for expansion by land, and they are more prone to sail.

    2- The need for a strong motivation

    As I said before, the presence of a roman fort with a full stack army was completely useless to attract the romans to Iberia.
    But we tried to make the same giving the romans a single settlement in Iberia.
    In that case, romans are able to send troops by sea.


    Then, the romans begin a war against the surrounding faction (illergetes), which is at the same time the creator and the culture tag of that region.
    This is complemented with expeditions by land, as some roman army was able to cross the gauls territory, including the Alps, without attacking or being attacked, just to arrive to Iberia to fight against the illergetes.

    3- The expansion

    Once that faction has disappeared, romans turn south, to the zone controlled by carthaginians (probably due to path finding questions), and they meet in Saguntum (as it happened historically).


    However, the expansion of turdetani (white) was too far, in comparison with the historical behavior. They are included as allies of the carthaginians, and limit their expansion to the coast (which is also correct).

    In the last experiment (for the moment), the turdetani were considered as the superfactions of carthaginians. The starting position served as shield against lusitanians, and at the same time drove the carthaginian expansion to the coast.
    The result was nearly the same, but with the limitation in the turdetani expansion.


    In some days, I will post the new experiments with superfactions, alliances and "motivations".

    @Duke John
    In those experiments MP are 95, but they are increased by large amounts for admirals, spies, diplomats and generals through traits.
    I knew some days ago that the limit of 100 is no more working in RTW 1.5, and I will try with higher MP also for captains, just to see if there is any difference.

    Cheers.

  18. #18

    Default Re: Game AI stuff (1.5)

    Impresive Work ! nikolai1962

    I think you need an award for all your help given here on these forums

    Can you upload that mod please ? I like it alot !! especially the removing of the britons from the mainland...and Sahara as a single region

    Again.NICE WORK

    p.s. What are the Thracians doing in the Alps mate ? But I'm guessing that Is just a temporary "training" map
    Last edited by Coldfish; 04-21-2006 at 16:16.

  19. #19

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by Duke John
    Good stuff!

    Months ago I also looked at the strategic AI and particularly at how it didn't merge its armies. I found that a small amount of movement points was bad as it meant that an army could not reach its target friendly army. Increasing the movement points greatly reduced the amount of armies as the AI armies could reach each other within a single turn. I would advise to give AI character a standard increase in MP by the use traits.

    There is also the problem of armies not merging when the total of 2 armies is greater than 20. So complete stacks are rare.

    All of this was tested on 1.2 so things might have changed.

    nikolai,
    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.
    That sounds like a good idea :)
    It's not a map.

  20. #20

    Default Re: Game AI stuff (1.5)

    Monkwarrior,

    Using superfactions is definitely something i wouldn't have thought of. Seems likely it could work well in the right circumstances.

    The AI always seems to prioritize adjacent land regions so it is hard to make it go to sea. One thing i tried once was make a saguntum equivalent town in iberia have romans as the faction creator so it sometimes rebelled to the romans. I want them to sail there though :)

    The other thing you could try to control expansion is tweak the regions to make sure the closest one is the one is in the direction you want the AI to move or have a starting army on the border of where you want them to move. Once they are at war with someone they will follow that route mostly so if there was historically a coastal tribe and you made them closest to the carthies then that might work out. Doesn't help with the romans though.


    edit: looking at your images again i'd say the first one would work best if the map was tweaked so rome could path-find to sardinia/corsica then on to palma then spain. I'm sure that is possible after my experiments. Big problem (apart from finding which tweak worked) would be making it so they saw palma but not carthage itself as carthage is closer.


    I couldn't resist trying out the idea of a stripped down strat file on the vanilla map to test path-finding for carthage. I'll post the results once I've uploaded all the images. Some of it may be useful.
    Last edited by nikolai1962; 04-21-2006 at 22:39.
    It's not a map.

  21. #21

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by Coldfish
    Impresive Work ! nikolai1962

    I think you need an award for all your help given here on these forums

    Can you upload that mod please ? I like it alot !! especially the removing of the britons from the mainland...and Sahara as a single region

    Again.NICE WORK

    p.s. What are the Thracians doing in the Alps mate ? But I'm guessing that Is just a temporary "training" map
    Ty. The map files are in a permanent state of experimenting at the moment but if i ever get all the pathing right i'll probably upload for sure :)

    Lol, the thracians are being the arverni as i was originally trying out variations for extending the government idea in EB so i'd started to make the factions match the EB ones. As i was testing with FOW off instead of playing i started to notice all this weird AI stuff.

    Deep breath, long post coming up.
    It's not a map.

  22. #22

    Default Re: Game AI stuff (1.5)

    I see..well thanks! I can't wait

  23. #23

    Default Re: Game AI stuff (1.5)

    After getting the idea of a stripped down strat file to test path-finding i had to try it out on the vanilla map.

    Made a provincial campaign.
    Removed senate, scipii, brutii and numidia (as i was going to look at carthage path-finding first).
    Gave each faction their original capital as their only settlement, same size, buildings etc.
    Starting leader with thier cavalry as only army.
    Brigands and pirates set to 99.
    10 happiness bonus on governor buildings to stop distractions caused by rebellions.
    Resources, landmarks, diplomatic attitudes etc all gone.

    Might be a better way to set this up to test the path-finding but the above was what i tried this time.

    Only changes i made to the base map at first were extending sahara to the west and moving the briton port as i'd sort of tested them before.

    The result was this.



    Running it for just a few turns you start to see some places that probably have problems straight away.



    The AI likes to go for the closest adjacent land target (modified by garrison, owner etc) which should have meant Chersonesus, Bordesholm and one of the two near the armenian capital would have gone pretty quick but they didn't. This was a consistent thing when i ran the first few turns a few times. The armenians always went south to hatra. The germans never found their way to bordesholm from south or west, only from the east. Chersonesus is generally messed up from all directions.



    I'll go back to them another time as this was mostly about carthage.

    The carthage AI starts fine, build a small army, sends it to nearest target (Thapsus), takes it. That army leaves a garrison behind and heads for next nearest (not neccessarily nearest to thapsus). Depending on how i'd changed the map over the course of this testing it either went to lepcis or Cirta. Meanwhile carthage has build a second army that goes to whichever of lepcis or cirta hasn't been targeted by the first. After those first 4 are taken it all goes wrong.

    The pathing from carthage to dimmidi and nepte goes a very weird way round with stacks getting lost on the way.



    (nb those two carth stacks had been stuck there since near the beginning.)

    All the time it takes is time the iberians have (in the normal game) to kick carthage out of iberia. Some stacks seem to get lost during this journey too and end up wandering around lepcis permanently. They get constantly re-inforced from lepcis but do nothing. Ai stacks are nearly always doing something unless they or the faction is stuck in some way. If they're not moving or if they're moving back and forth in a repeating loop then they are usually messed up. Not always but if you watch it enough you learn to see when it isn't so.

    When the small starting stacks finally reach dimmidi they assault and lose a lot and bounce off. Most of them seem to not be able to find their path back anywhere so when dimmidi is finally taken they sit around dimmidi getting re-inforced from there and the stacks will get bigger but don't do anything. They'll attack nearby rebels but won't chase them if they are outside the dimmidi region.



    This shows the same thing but earlier before the stacks got huge but i drew pretty lines on it so i uploaded it anyway.




    Not all of this will apply to the normal game, though the pathing to dimmidi and nepte will be, in the normal setup the ai may send bigger initial stacks and so end up with less lost ones. Really meant as an illustration of how the path-finding can be so critical to the ai, especially compared to a human player who has zero path-finding problems unless they're playing with their eyes shut.

    This was all too painful to watch and also i found out the distance from siwa to nepte didn't stop the egyptians targeting it when it was still rebel, only if the carthies had it. Which they didn't as they kept getting lost.

    So time to mess with the map :)

    (I wasnt going for realism or aesthetics here just trying to see if simple map changes would make the ai perform to its best (which i actually think could be pretty scary with path-finding fixed)

    So i lost gaetulia/dimmidi and extended the sahara over their old terriotory and moved nepte close to cirta hoping the ai would target it from there and not go the long way round. Also moved cirta/thapsus a bit to smooth out bendy roads, moved a ford etc, added some hills to push roads in certain directions to make them more rounded with less sharp bends etc. All of this is trial and error and often makes things worse but eventually it works.





    Once this worked the land expansion went smoothly. A human player would still do it faster but not by as big a margin (imo)

    As you can see on the minimap of one of those they then landed on sardinia.

    Note. It seems that the ai doesn't build ships unless one of its regions can see a naval expansion target. It also doesn't seem to build them *until* it needs a new expansion target. None of the ai factions who weren't land-blocked (sort of) built a ship apart from the iberians who built one and landed a small army by tingi during a brief cease-fire. The ceasefire broke soon after and they never built another. They may not actually land an army but they never built a ship unless they had a target for a moment when they were temporarily blocked.

    Carthage can *see* sardinia and built a ship and off they went. One of the images also shows one of the times the ai will have a lot of stacks hanging around. I thought it was because they were stuck because of either path-finding round that mountain (as the ai will move stacks to the capital when they have nothing to do) or the carthage ai couldn't see another naval expansion target and were therefore stalled.



    What it actually was was them waiting for a ship. An odd place to wait admittedly (probably because of my mountains, might be better to have a path through them to thapsus). The holdup was the ****ing pirate fleets. Carthage would build a ship every turn and move it to its "waiting for an army" spot and they'd be constantly wiped out or retreated by the swarms of pirates. Again, the pirates wouldn't have been such a big problem if all the factions had their starting fleets but it still shows how important they are at messing up the ai naval expansion. This stage of the testing got too annoying as 10-20 turns went by before carthage managed to get a ship off to next target. The pirates get too strong even set at 99 because the ai uses small fleets and loses a lot.

    I went and changed the EDU so carth ships started out as exp 9 but even then it took a while before they cleared a space (mainly because carthage got big enough to build the bigger ships i think). AI naval expansion needs weaker pirates badly imo. Setting the chance to 100 in the rebel_factions file seemed to help a bit (deleting the pirates section causes a ctd).

    Anyway all the changes gradually made the pirates less of a barrier and i could see where carthage would go next.

    Carthage was the only place yet with a port so it would only be places Carthage could *see*. (A large part of this was to see which regions could be seen as a naval expansion target from different places.)



    So Carthage can see Lilybeum and Caralis and sees Caralis as closest (i am assuming that is why they went there first as caralis had a full rebel stack).
    They only go by see when they are blocked on land in some way but at least the routes are there. Oh yes, i put a fordless river between egypt and carthage for this just in case the far north-western nepte wasn't enough to keep the peace with this odd strat file setup. I was only interested in what path-finding glitchs would make carthage the pushover it usually is.

    Once on sicily they have adjacent land regions so that is it for naval expansion until sicily is taken (or in a normal game if they were at peace with another faction on sicily). The path to syracuse was no problem.



    (notice on minimap the regions the ai factions are having problems finding. no-one ever finds tribus sakae it seems. I wasn't watching those areas as i clicked end turn but if those regions are targeted but the attacking stacks are lost/stuck the whole faction might be stalled.)

    After this is all went wrong again.



    The army that took syracuse attacked and lost the battle for messana. Syracuse-messana can see each other and lilybeum-syracuse can see each other (when i say see i mean find the path) but lilybeum-messana can't, so once the first army retreated that was it for the carthage ai. If this was the normal vanilla game and carthage had been pushed out of sicily and spain because it was lost in the desert, and then made a come-back this is where the faction would stall again.

    This was painful to watch too but i did for a bit and it was quite funny in the end. The carthage ai kept sending re-inforcements by ship. The re-inforcements were just as stuck as the others. They landed more stacks and began to fill up all the available coast tiles. Bit by bit they got closer and closer to messana as new stacks were landed and bumped previous ones up the road. Finally they hit the jackpot and a bumped stack got round a bend or something and sieged messana. (going by the date on the images i think that took the AI about 40 turns.)



    Made me laugh anyway.

    Short-lived though as they lost and retreated back to syracuse and stalled too.

    Pointless image but i added it anyway. I tried to move a bunch of them next to messana but only one of those stacks (maybe more) is the prime attacker. The rest are supporters and back up if attack fails so i needed to guess which was the right one. Gave up after three.



    Sicily needs to be fixed for the ai to work. I think given the shape any small scale sicily needs to be triangular with the cities at the apexs(?) and straight-ish roads between the cities. I slapped a lot of mountains down in the middle and made the edges of the islands have at least two pixels of clear land for the road to go down.

    Not very pretty but would it work?



    No was the short answer. Needs to be tinkered with more but better to do that with a strat file set up with carth (or another faction) just on sicily so you can change the map and test it straight away. My current one sort of works in that carth now sees messana from lilybeum but i messed up their path to syracuse. But as messana sees syracuse as i hadn't changed that side of the map and as the carth armies are coming from lilybeum they don't get stuck as they go to syracuse via messana. So that was good enough for now to carry on testing the carth stuff.



    None of the cities on sicily can see italy and vice versa (though i intend to try and make messana and croton see each other eventually) so no more landings here. If there was a land-bridge carthage would now start going into italy (i prefer the naval option though when it can be made possible). So next stop palma.



    I wasn't paying attention here and didn't see where the ship was built that took this army to palma (that is the region that can *see* it). I *think* it was caralis as there was a port there now and i've seen the vanilla julii jump to palma as long as the senate had already got them to sardinia. Will check sometime by starting carthage on sardinia.

    Then it stalled for a bit. Not sure if that means they had no more naval expansion targets from theor current position or if they iberia was already picked and they were waiting for tingi to finish its port. Either way an army moved up to tingi and waited. A few turns later the port was done. Next turn a ship appeared. Then off to spain.



    With no desert distractions the ai was doing a good job focusing its forces.



    Then it all went wrong. Not at all surprising now i look at iberia after tinkering with the path-finding. I think it happened when a carth stack lost a siege against numantia and retreated behind a mountain. There were too many roman and carth stacks moving and fighting to spot the glitch but whatever it was the faction stalled and it stopped sending armies to iberia.



    (This is an exception to the rule about capitals. The ai only congregates around its capital when it has no targets.)

    I gave up here as testing the path-finding in iberia is going to take a while and it will be better done by starting carthage in corduba without any other factions so it is easier to seperate the general map glitchs from battle glitchs.

    As an indication of how messed up the ai can get in iberia:



    All but one of those (8 or 9) roman stacks are stuck (including the garrison in scallabis). The romans can't find the way to the last carth city and the carth garrison there is stuck too. The whole faction wasn't stuck because it had got big enough to have multiple targets which included ones in the east of their empire. A quick scan of the map showed that was about half the roman army.


    Couple of other things i saw before closing down.






    ~~~

    Anyway i think this all shows.

    1) The AI factions are massively handicapped by path-finding problems which can be found and fixed.
    2) Naval invasions work fine but only in certain specific directions which need to be found by testing (and only when the faction is land-blocked physically or by alliances).
    3) This is quite a good way of testing the path-finding (though probably much improvable).
    4) I like linking images a bit too much :)
    Last edited by nikolai1962; 05-02-2006 at 00:45.
    It's not a map.

  24. #24

    Default Re: Game AI stuff (1.5)

    Impressive work!

    offtopic: nikolai1962 I tryed to change the ownership of Samarbrovia from Britons To the Gauls I cut/paste the settlement from britons to the gauls...I moved the briton general to the gauls also I changed the coordonates x y with one or two ...I changed the unit type in the specific galic unit...deleted the map.rwm
    added -show_err to the shorcut rtw tab...and STILL KICK TO MENU!...the error says that Belenus (the moved general) is to old to be a parent 36<30

    I think has something to do with the families...must be relatives or something
    Can you please try it yourself if you want ? maybe you will succeed and if so...please post it here or upload the file

    p.s. some pics are funny
    Last edited by Coldfish; 04-21-2006 at 23:21.

  25. #25

    Default Re: Game AI stuff (1.5)

    wow who would have thought that beinds in roads could mess the ai up :(

    i think there is now a need for more functionaly maps rather than 100% historical maps. any trick to make the roads straight (like lakes, mountains) will surely make the game more enjoyable

  26. #26

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by Coldfish
    offtopic: nikolai1962 I tryed to change the ownership of Samarbrovia from Britons To the Gauls I cut/paste the settlement from britons to the gauls...I moved the briton general to the gauls also I changed the coordonates x y with one or two ...I changed the unit type in the specific galic unit...deleted the map.rwm
    added -show_err to the shorcut rtw tab...and STILL KICK TO MENU!...the error says that Belenus (the moved general) is to old to be a parent 36<30

    I think has something to do with the families...must be relatives or something
    Can you please try it yourself if you want ? maybe you will succeed and if so...please post it here or upload the file

    p.s. some pics are funny
    The steps are

    1) Copy the settlement for belgica to the gauls
    2) delete captain caradog and his army
    3) move belenus to the island. I moved him above Londinium (IIRC) which was x 55, y 132

    Everything should work then. There won't be a starting gaul garrison but they'll build a unit there.

    (Though personally when i play for enjoyment rather than testing out modding stuff i play EB or RTR. vanilla 1.5 is way better as a game than 1.2 but i miss the historical feel of those other mods after a while)

    I hope this is helpful enough. Problem I have is nearly every Rome folder on my machine (apart from EB and RTR) is messed up in some way through trying out different stuff. I don't even remember what half the RTW icons are for.
    Last edited by nikolai1962; 04-22-2006 at 02:21.
    It's not a map.

  27. #27

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by shaggy1973
    wow who would have thought that beinds in roads could mess the ai up :(
    Its only really sharp bends and in a way it isn't even the roads themselves. What it is is that the roads show you how the underlying terrain makes the ai decide to move because the path of the road will (mostly) be the path of least movement cost. The ai will still glitch moving over the same terrain without a road. But if you can get the roads between settlements gradually curving with no sharp bends and no cutting back on itself then the ai will glitch much less.

    Quote Originally Posted by shaggy1973
    i think there is now a need for more functionaly maps rather than 100% historical maps. any trick to make the roads straight (like lakes, mountains) will surely make the game more enjoyable
    I think the game ai will never be as good as it could be unless map makers find and fix these glitchs. Someone with a lot of patience could make a glitch free and accurate map probably. Just take a lot of tiny terrain changes, testing and patience. (I think)
    It's not a map.

  28. #28

    Default Re: Game AI stuff (1.5)

    IT WORKED !! A HEARTY THANK TO YOU nikolai1962

    I hope those britons will not invade the mainland

  29. #29
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Game AI stuff (1.5)

    Very interesting thread, you made some fine observations that'll surely help us make the AI at least do a bit better ;)
    I thought a bit about some of the things you mention about stalling and I have a theory that the AI decides to issue movement orders on a stack-per-stack tile-per-tile method which means it seeks a target for a stack and then only moves the stack to a tile if this tile decreases the (euclidian) distance to the target to the next integer (rounded).
    This would explain your example where the stacks got stalled after an unsuccessful siege south of the forest (distance would be 7, if the stack moved right, still 7)
    It would also explain the problem with 90 degree bends in roads that lead in a straight line to the target after the bend because the distance (in integers) wouldn't become smaller and they can't move diagonally because it'd take more movement points thus increasing the distance again.

  30. #30

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by alpaca
    Very interesting thread, you made some fine observations that'll surely help us make the AI at least do a bit better ;)
    I thought a bit about some of the things you mention about stalling and I have a theory that the AI decides to issue movement orders on a stack-per-stack tile-per-tile method which means it seeks a target for a stack and then only moves the stack to a tile if this tile decreases the (euclidian) distance to the target to the next integer (rounded).
    This would explain your example where the stacks got stalled after an unsuccessful siege south of the forest (distance would be 7, if the stack moved right, still 7)
    It would also explain the problem with 90 degree bends in roads that lead in a straight line to the target after the bend because the distance (in integers) wouldn't become smaller and they can't move diagonally because it'd take more movement points thus increasing the distance again.

    My thoughts exactly :)

    A move might make them go from say 60 pixels away from their target (in a straight line tile-centre to tile-centre) to 59.6 which gets rounded up to 60 therefore they don't move as (to them) they are not moving closer. *If* the distance is calculated on a pixel basis then you could expect to see less path-finding glitchs with higher screen resolutions (i think). It would also explain why armies moving to chersonesus from the east end up on that little bump of land that is closest to the target in a straight line.

    I'm pretty sure that is what is happening. The tweaks i am making to the vanilla map are being based now on trying to make a path between the settlements of adjacent regions where each tile moved decreases the straight line distance. It is proving quite tricky to get it to work in all cases from all adjacent directions though.
    It's not a map.

Page 1 of 5 12345 LastLast

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