For example I have this map
# is wall
<space> is open space
I need a function that can get all of the coordinate surrounding it..
Sorry, I don't really know how to word it
I will give example
1 2
|
vector< coordinate_t > getSurround( int x, int y );
getSurround( 8, 5 );
|
I should get
1 2 3 4 5 6 7
|
X
XX#X
X####X
X##X
XX
|
the coordinates of all the Xs
if there is no barrier surrounding it
it should return only the inputed coordinates
and also another testcase
1 2 3 4 5 6 7 8 9 10
|
X#X
X# #X
X# #X
X# X #X
X# X#X #
X# X#S#X#X
X# X#X#X
X# X#X
X# #X
X###X
|
This problem occur in my path finding program
if the target is blocked just path find to any point where it's the area surrounding the target...
I think flood fill is the solution but I can't think of how do it.
so can anyone give me a hint ?
Thanks in advance