BFS with provider

Hi @aron_granberg! Is there any way You could add something like BFS that uses traversal provider (including custom ones) to find movement range?

1 Like

Hi

Sorry for the late reply.
The BFS function takes a filter parameter which can be used for the same purpose. It’s a bit annoying if you have an ITraversalProvider, but you could do this:

var dummyPath = ABPath.Construct(...);
PathUtilities.BFS(..., (node) => provider.CanTraverse(node, dummyPath))

If you have a custom ITraversalProvider you may be able to just pass null instead of a dummy path.

Hi @aron_granberg , thank You for fast(yes!) answer. Unfortunatelly I cannot use it, because this function does not giving me possibility to use the node I start from (the previous one in other words). My traversal provider checks also connections (not if exiests, but some kind of dynamic connectios, some let pawns pass, the others not). So if its bigger problem with traversal provider, would You at least give the previous node in the filter function?

Hi

Yeah currently that function does not allow you to filter edges. However, the BFS function is quite short, you can just copy and paste it to your own script and modify it there. There are no complex dependencies except for two global variables (that you can also copy).

Don’t you think that would be useful for a broader userbase? I would make use of it also.