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
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 wrongnb "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.
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
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
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.the fastest path from any passable tile in a region to any other passable tile in the region is completely contained within that region
#
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).
Bookmarks