Seems like you need a recursive algorithm for this. You start with the 'X', and check the tiles around it. If it's a wall tile, then you can continue through the algorithm, if it's not a wall, then use the algorithm to check for walls around that tile.
Something like this:
'X' is enclosed if it is surrounded by wall tiles, N,S,E,W,NE,SE,SW,NW.
so you go into the algorithm:
bool Enclosed(tile){ bool N,S,E,W,NE,SE,SW,NW; // Check to see if north tile is a wall if(tile.N == wall) N = true; // If it isn't, check to make sure north tile is Enclosed else N = Enclosed(tile.N); // Check to see if south tile is a wall if(tile.S == wall) S = true; // If it isn't, check to make sure south tile is Enclosed else S = Enclosed(tile.S); ...etc // Return true only if tile is enclosed by walls return (N && S && E && W && NE && SE && SW && NW);}
I didn't bother checking the above, I just hope that it gave you a possible idea since noone else has posted yet.
Have fun =\
[edited by - wavarian on October 10, 2003 12:11:50 AM]