Support Forum

Storing paths and light weight movement script

Hi, my A* implementation (grid graph, AIPath) is coming along nicely, but as I am planning to scale up to about 1000 AIs, I have two questions to help me go forward. In particular I plan to do the following to help performance:

  • a lot of my source and destination nodes are fixed, so I could calculate paths at the beginning of the game; is there a recommended way (or even sample code) as to how to calculate, store and retrieve paths? I’m not concerned about the memory implications of storing many paths.

  • this thread
    https://forum.arongranberg.com/t/1000-agents-and-more/8215
    mentions that “… for 1000 agents you will want to use a custom movement script or at least use the AILerp movement script (the fastest of the built-in ones). AIPath and RichAI would probably have too much overhead …”. Are any examples of such light-weight movement scripts available? I would need local avoidance to still work with such a script.

Thank you for your time.

Hi

If your destinations are fixed (and you have few of them) then you may be intersted in the FloodPath path type. See https://arongranberg.com/astar/docs/floodpath.html

This will calculate all possible paths to a given point very efficiently and then you can use the FloodPathTracer path type to calculate a path to that destination much much quicker than a normal path request.

Hi Aron,

Thank you for your quick reply. I had a look at FloodPath before, but don’t think they will quite work for my application. Is there any way to calculate and store paths for later usage given that I’m using a grid graph and AIPath? If AIPath is the problem, then I could potentially switch to AILerp.

As far as i know, the builtin pathers are re-requesting paths in certain intervals, so each returned path is likely a new one (tags etc. could have changed inbetween). But if you have fixed paths and conditions, you could use the vector list used for movement of the path to (re)store it yourself. The builtin components seem to have a method SetPath that looks useful too. Not sure how to construct valid paths though, haven’t used the system for a while. But writing your own pather shouldn’t be too hard and that way you’re free to bypass the system with precalculated stuff.

Thank you Polymo, for pointing me in the right direction. I’ll have a look at those functions and see how far I can get.