How would you go about accounting for AI moving around mobs in your pathfinding library? IOW, I made a hack into the lib in order to allow other mobs to be avoided in a mob's path[] (I'm only using 1 mob per tile, ATM). The way I did it was:
//change the call parameters for AStar
AStar(mob/mover,start,end,adjacent,dist,maxnodes,maxnodedepth,mintargetdist,minnodedist)
//and inside this proc, called the adjacent proc like so:
var/L[] = call(cur.source,adjacent)(mover)
//where it would show back up in the user-defined proc
proc/AdjacentTurfs(var/mob/TBSS_mob/mover)
Is there a better way to do this that you can see?
It's probably best not to mess with the library itself as you'll have to make the change every time I update :P. Best to just store any information that the adjacentnodes and dist procs need in a global. At least until I get around to doing a version wrapped in a datum.
Anyway the best way to avoid a mob is to increase the distance for tile transitions that move you close to the mob. To do this you can just loop through all mobs in range in the dist proc and scale the distance according to how close the tile is. Unfortunately this can be very slow as the distance proc is called a whole lot so you don't want to do this for long paths. Another method is to make a threat map(a grid with modifications to the tile weights or just store the threat value of a tile directly on the tile) and just adjust it each time a mob that affects the threat value of tiles moves. Plus you can also use this for anything else that is a threat and you want to make the pathfinder try and avoid tiles. Then in the dist proc add in the threat map value to the distance for the tile.
Another thing to consider is that if you are traversing a long area and have to deal with dynamic obsticals is that they change and the longer the path the more likely stuff has changed at the end of the path before you got there. When making long paths have a much simpler version of the dist proc and adjacent nodes one which ignores dynamic obsticals completely. Then when following the path generate new smaller paths to follow for subsections of the path say every 10 or so tiles using much more detailed adjacent nodes and dist procs and set a maxnodedepth so it doesn't wander far to generate the small path to guide it along the larger one. You can also use the new mintargetdist parameter to keep it from trying to hit exact points along the larger path rather just stick close to it in case one of the original tiles in the path is blocked.