Greetings! I have a task to scan an area of the map for passability. In your map generation you use some algorithm that devide the map into differently colored areas. Unit from area of certain color can’t get to the area of other color. That’s what I’m looking for! But! I need to use this function at runtime. Can you give some kind of documentation for this function? Or can you just explain me, how to use it? Or at least, can you hint me the place in the source code, where can I find examples of using this function? Thank you in advance!
Hi
How exactly do you want to use this?
Do you want to check if there is a valid path from one point to another point? Or something else?
The algorithm to divide it up into different colors is just a simple DFS search.
See http://en.wikipedia.org/wiki/Depth-first_search
Though this page might be more descriptive even if it isn’t exactly the same algorithm: http://en.wikipedia.org/wiki/Flood_fill
I’ll give you an example from a computer game named “FTL: Faster then light” .
The map to the left is a starship’s interior. Rooms that colored red is the rooms with no air because of hull breaches/opened airlocks. Other rooms of the ship doesn’t loose air because they cut off from red area by doors. I need to make a similar thing: scan the area and find out, which rooms are loosing air (because they have a direct access to hull breaches or opened airlocks) and which doesn’t.
Well, writing my own depth search was a plan B. I was hoping that your awesome product will save me some time on this one
Aha, I see.
You can use PathUtilities.GetReachableNodes from your hull breaches to find all nodes which will be without air.