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)

    Case Study 02

    Using "toggle_terrain region" the Cappadocia region is adjacent to the Antioch region but the fastest path goes through Tarsus.

    Click image for larger version. 

Name:	cs03a.jpg 
Views:	872 
Size:	354.3 KB 
ID:	20384

    However "toggle_terrain choke" shows all the adjacent tiles are impassable

    Click image for larger version. 

Name:	cs03b.jpg 
Views:	849 
Size:	387.4 KB 
ID:	20385

    so the regions should be marked as non adjacent and the path via Tarsus shouldn't be a problem (and doesn't appear to be in game) and this is *generally* true in situations where all the adjacent tiles are impassable however from my observation it doesn't seem to be true in 100% of cases for some reason.

    On my edited map the Carthage region is blocked from the Gaetulia region by impassable terrain

    Click image for larger version. 

Name:	cs03c.jpg 
Views:	843 
Size:	264.3 KB 
ID:	20386

    and in this case I have noticed the occasional odd glitch which might be related to this (i.e. where Carthage should have been attacking Gaetulia but wasn't and all its units were messed up and milling about aimlessly). It might have been a naval landing gone wrong but another possibility I recently came up with is maybe it's the distance between settlements? A CA dude mentioned at one point that the path finding may glitch if settlements are too far apart and you can see here how the path finding arrow only goes a certain distance before it stops.

    Click image for larger version. 

Name:	cs03d.jpg 
Views:	858 
Size:	251.6 KB 
ID:	20387

    So maybe if settlements are too far apart the game glitches on impassable borders?

    Dunno - the Carthage thing is too random a glitch to test for specifically but as a general rule it may be worth checking settlements are all within the path finding arrow distance from each other. The AI generally manages with settlements that are far apart but regions like that are often deserts or steppe without a lot of impassable obstacles so the path finding glitching on impassable borders only when the settlements are too far apart is a possibility worth considering imo.

    #

    If true then it's easily fixed with new regions but apart from region borders, ford placement etc I currently want the edited map to still be as vanilla as possible so I'm avoiding adding new regions for now.
    Last edited by nikolai1962; 01-02-2018 at 00:40.
    It's not a map.

    Member thankful for this post:



  2. #2
    Arrogant Ashigaru Moderator Ludens's Avatar
    Join Date
    Nov 2003
    Posts
    9,065
    Blog Entries
    1

    Arrow Re: Game AI stuff (1.5)

    Thanks for these experiments, nikolai1962!

    I've linked to them in the Game Mechanics forum, to make them easier to find.
    Looking for a good read? Visit the Library!

    Member thankful for this post:



  3. #3
    Senior Member Senior Member ReluctantSamurai's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    2,483

    Default Re: Game AI stuff (1.5)

    I'm gradually getting psyched up to delve into RTW map-making/editing My work load is going to get significantly lighter in the near future, so I will have some free time. I'll have to get familiar with all the editing tools and how to manipulate them before then....so

    ...are all map editing commands done through the console, or are there third party tools to use?
    High Plains Drifter

  4. #4

    Default Re: Game AI stuff (1.5)

    I'm gradually getting psyched up to delve into RTW map-making/editing
    It's actually semi-fun now I've figured it out better. Originally I didn't know about toggle_terrain or the convexity issue so i did it all by trial and error and even a small map was a total nightmare but now it's not so bad.

    I'm a short way away from finishing up on the vanilla map (as much as i can without adding extra regions) and after I've stashed that version somewhere safe so i never have to do this again I want to try a few separate experiments on a copy to see how best to deal with very mountainous regions and then after that look at the BI and MTW2 maps to see if they are equally quick (at least relative to last time).

    ...are all map editing commands done through the console, or are there third party tools to use?
    the commands which show different map overlays (toggle_terrain region/tiletype/choke etc) are all console commands.

    map editing itself is done by editing the map files: map_features.tga, map_regions.tga and map_groundtypes.tga. I use gimp for this. There may be other useful tools but if there are I should probably know but don't :)
    It's not a map.

  5. #5

    Default Re: Game AI stuff (1.5)

    this will be the new "update" post as i think i've found the fastest way to fix AI path finding with the least effort

    so ignore all the stuff i said previously, instead...

    New Sequence

    1. start up the game/mod you want to map-check with each faction in turn

    2. bring up the regions overlay with the "toggle_terrain region" console command

    3. for each settlement select a unit in the settlement and use the right mouse click to show the fastest path to the settlement in each *adjacent* region

    Click image for larger version. 

Name:	sardgal01.jpg 
Views:	911 
Size:	288.6 KB 
ID:	20388

    nb "adjacent" is defined as two regions having adjacent *passable* terrain. if *all* the adjacent tiles between two regions are impassable then the game *generally* seems to mark the regions as non-adjacent. there may be occasional exceptions to this where something has gone wrong but it is generally true.
    4. note the cases where the fastest path between the settlements of two adjacent regions clips a third region (as it does it the above case of Sardis-Galatia) - these all need to be fixed as these are the primary cause of the AI path finding going wrong

    5. also note the cases where the path finding arrow runs out before it reaches the target settlement - I think this can cause problems *sometimes* for an as-yet unfigured out reason and it's worth considering trying to fix them but not as a priority

    Click image for larger version. 

Name:	toofar.jpg 
Views:	862 
Size:	356.4 KB 
ID:	20389

    6. I said previously to fix unreachable tiles as a first step but as you sometimes change what tiles are unreachable when you change region borders this step can be left to the end.

    7. only *after* fixing all of the issues found in step (4) and step (6) start the game up as a remote faction and turtle (or use the -ai command) and watch the AI move looking for additional glitches

    (or don't, just assume this process fixed the majority of cases and play short campaigns with each faction for fun and see if you notice any additional AI glitches while you're playing)

    This sequence is dramatically faster than my previous attempts.

    nb I'm not saying the game does path find like this (fastest path from settlement to settlement). I'm saying this process will highlight places in the game where the AI will often get stuck.
    #

    Reasoning

    the underlying principle behind this sequence is the same; it's simply much more efficient

    1) the path finding works (as shown by the player's path finding arrow)

    2) path finding has a computational load

    3) the game reduces the load by
    a) limiting the number of path finding iterations allowed (as shown by the path finding arrow stopping after a certain distance)
    b) using region to region pathing first and then unit to target pathing when close enough

    4) path finding glitches occur when:
    a) a unit in region A tries to path to a target in region A but the fastest path clips a different region
    b) a unit in region A tries to path to a target in an adjacent region B but the fastest path clips through a third region C
    c) *maybe* when the game's region adjacency database gets messed up somehow
    d) temporary e.g. enemy unit blocks a valid path and the alternative path glitches

    5) the perfect solution is making the map 100% "convex" which in this context means

    the fastest path from any passable tile in a region to any other passable tile in the region is completely contained within that region
    however this is very difficult and time consuming and what this new sequence does is recognize the AI uses some paths e.g. the ones between settlements, an order of magnitude more often than others and so glitches there are much more critical - so doing it this way round means you can fix 80% of the problems with maybe 20% or less of total necessary effort and far less time.

    #

    As I'm trying to find the fastest way to do this I moth balled the vanilla map editing i've been working on and started again from scratch on the vanilla map to compare speeds and this method is dramatically better.

    On the vanilla map i found 26 region-pairs where the pathing broke the rule (i may have missed some).

    (I knew almost all of them anyway from watching the AI get stuck but this method is much faster.)

    There's also at least a dozen cases of the settlements being too far apart for the path finding arrow which may or may not be important and i'll worry about later. (I think it's worth having the list so if you notice something odd happening that has no region-clipping explanation then maybe it's connected to this.)

    I'll be posting up how i fixed some of the 26 region-clipping cases from the vanilla map (although i've mentioned some of them before on this and other threads).
    Last edited by nikolai1962; 01-04-2018 at 22:09.
    It's not a map.

    Members thankful for this post (2):



  6. #6

    Default Re: Game AI stuff (1.5)

    Case Study 22, Sardis-Galatia

    with the region overlay on you can see the settlement to settlement path clips the Pergamon region

    Click image for larger version. 

Name:	sardgal01.jpg 
Views:	969 
Size:	288.6 KB 
ID:	20390

    switch to the "toggle_terrain choke" overlay to see if there is an easy fix moving region borders or rivers/fords

    Click image for larger version. 

Name:	sardgal02.jpg 
Views:	936 
Size:	308.1 KB 
ID:	20391

    and if not try "toggle_terrain tiletype" to see if there is an easy fix through editing terrain type.

    Click image for larger version. 

Name:	sardgal03.jpg 
Views:	883 
Size:	295.0 KB 
ID:	20394

    In this case the easiest solution is moving the Pergamon border back a couple of rows.

    Click image for larger version. 

Name:	sardgal04.jpg 
Views:	853 
Size:	293.6 KB 
ID:	20392

    nb when you change anything you need to check it hasn't caused new problems among the regions adjacent to the one you edited.

    #

    For a long time I thought diagonals were a problem for the game's path finding and spent hours making all the paths orthogonal but that was wrong - the problem is diagonals near region borders are often the place where this region clipping problem occurs. Anywhere on the map where 3 or 4 regions join at a single point (as in this case) are prime candidates for this path finding bug.

    This type of glitch can be 100% prevented by placing an impassable tile in the right spot at the junction of 3+ regions however I'd advise you do it at the end as there's a lot of places like this and the right spot depends on where the region borders are and you'll likely be changing region borders a lot.

    I did it for this case as an example (if you can see the dense forest tile).

    Click image for larger version. 

Name:	sardgal05.jpg 
Views:	882 
Size:	267.7 KB 
ID:	20393

    A lot of the 26 cases I've spotted from the vanilla map are a simple as this to fix (although not all).
    Last edited by nikolai1962; 01-03-2018 at 21:01.
    It's not a map.

    Members thankful for this post (2):



  7. #7

    Default Re: Game AI stuff (1.5)

    Case Study 23, Cappadocia-Galatia

    fastest path clips into the Cilicia region

    Click image for larger version. 

Name:	cappagal01.jpg 
Views:	871 
Size:	326.6 KB 
ID:	20395

    same thing looking at in with the choke overlay

    Click image for larger version. 

Name:	cappagal02.jpg 
Views:	868 
Size:	348.1 KB 
ID:	20396

    bunch of ways to fix it but the simplest was nudging the upper ford down a few tiles

    Click image for larger version. 

Name:	cappagal03.jpg 
Views:	882 
Size:	304.0 KB 
ID:	20397
    It's not a map.

    Member thankful for this post:



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