I ma trying to make my program read a maze like this:
#.#######
#.......#
####.####
#....#..#
#.####.##
and print out the reachable zones and non-reachable zones in the maze, which should look like this:
#+#######
#+++++++#
####+####
#++++#--#
#+####-##
Walls are represented with "#", and passable cells are represented with ".".
The "+" that replaces the cells means that those cells are reachable from the top entry point of the maze. The "-" symbol are the cells that can't be reached if you enter the top of the maze.
For example, in the above maze, all the cells are reachable except for the cells in the bottom right-hand corner. This is because those cells cannot be reached from the entry point at the top of the maze.
I am trying to use some recursion to flood fill the maze, and determine the reachable zones, but I am having trouble with that.
This is what I have so far:
int
flood_fill(m_t * maze, int row, int col) {
int direction;
direction = flood_fill(maze, row+1, col); /* down */
if (!direction) {
direction = flood_fill(maze, row, col+1); /* right */
}
if (!direction) {
direction = flood_fill(maze, row-1, col); /* up */
}
if (!direction) {
direction = flood_fill(maze, row, col-1); /* left */
}
if (direction) {
maze->M[row][col].type = path;
}
return direction;
}
I know that my flood_fill function is not doing the right thing, and I'm having difficulty getting it right. Can anyone help me please me get my flood filling part of the code right, so I can call the function elsewhere in the code and determine which cells can be reached.