You should better elaborate your statement to get better help.
However, from the image you provided, I understand that you are trying to identify whether certain parts (red) are surrounded by other parts (blue).
And apparently, this will only happen in a 2D view (although you’re in 3D space), ie you don’t care about the Y axis, right?
In this case, it is first necessary to know: Will the blue parts be movable? That is, will the player be able to “close” a circle? Or will the blue parts always be static? Because if the blue parts don’t change, it’s easier to create logic.
Could you define “surrounded”? To me that would suggest finding red points enclosed by a region created by blue points.
If so, this is actually a relatively tricky problem mathematically.
The first thing you’d need to do would be to find the region itself. The only way I currently see you achieving this is using a kind of tree-like structure. Move from point to point based on magnitude from the previous point, storing each point in a list. The loop would end when the next point is a point already in the list. You could then back-track to find the point of the next lowest magnitude for each variation and so on.
Following each creation of a region you could then check if the red points lie within the region enclosed. There are a few methods you could use to do this. The best (mathematically) would probably be the Inside / Outside Problem. Alternatively you could do it procedurally, checking incrementally smaller regions surrounding the points. If you know how many red points there are you could have an ending clause for if all the red points are known to be enclosed.
The biggest issue with this kind of approach or similar is that it has at the very least an O(n^2) time complexity, meaning the computational power would go up very quickly.
Edit: The method I just listed is probably better, but I just realised you could probably just check if a red point lies on a line between two blue points. Then (again, depending on how you define “surrounded”) check if there are one or two blue points lying on either side.
This is actually probably the most computationally effective solution, since it doesn’t require you to build any regions.
I tried your solution, but i dont quite get how do i implement this. Its already been 1+ years and i just returned to continue working on this game, and i found that i can just use pathfinding to pathfind from dot to a point outside of the grid to check if its inside or outside. but thanks for your help tho!