I'm creating a tile based game similar to Minesweeper. When a user clicks on a tile and its not a mine or a number space I need to search and expose the adjacent tiles that are empty and stop when it hits a number or the edge of the board. I have it working right now so that it will clear the row of the tile clicked and stop at a numbered tile or the edge of the board. What I have is going to get ugly quickly and I am sure there is a easier way of doing this. Is there a searching algorithm I can use that will find all adjacent tiles to the one the player click only stopping once it hits the edge of the board or hit a numbered tile?
The search algorithm you're looking for is called Flood Fill
Every empty tile is colour A. Every non-empty tile is colour B. Then you apply the flood fill with the modification that you also stop filling in that direction when there's an adjacent non-empty tile.
Alternatively: every empty-with-no-adjacent-non-empty tile is colour A, all the others colour B, and you apply a flood fill then enlarge the filled area mask by 1 tile in all directions.