For my micromouse i store the wall information in a 16x16 array of integers. The LSB of each integer is the south wall of a cell, and the 2nd bit is the east wall of a cell. 1 means the wall exists...
So if i want to check if there is a wall to the west of cell A, then i have to look at the cell west of cell A and see if it has a wall east of it.
My MATLAB algorithm ( very similar to C ) goes like this :
flooded = zeros(16,16); %Create an array of 0s to store the flood values
flooded(mouse_y, mouse_x) = 1; %Give the mouse's current position a flood value of 1
while 1 %Loop until break command
for x = 1:16 %Scan across the grid
for y = 1:16
%Check if current cell already has a flood value.
%If it does then move on.
if flooded(y,x) > 0
continue
end
%Check the cell North of the current cell
if y-1 > 0 %If the cell exists...
if flooded(y-1,x) > 0 %If the cell is flooded...
if bitand(maze(y-1,x),1) == 0 %If there is no wall between them...
flooded(y,x) = flooded(y-1,x) + 1; %Then give the current cell a flood value 1 higher than the north cell.
continue; %Move onto the next cell
end
end
end
%Check South
if y+1 < 17
if flooded(y+1,x) > 0
if bitand(maze(y,x),1) == 0
flooded(y,x) = flooded(y+1,x) + 1;
continue;
end
end
end
%Check West
if x-1 > 0
if flooded(y,x-1) > 0
if bitand(maze(y,x-1),2) == 0
flooded(y,x) = flooded(y,x-1) + 1;
continue;
end
end
end
%Check East
if x+1 < 17
if flooded(y,x+1) > 0
if bitand(maze(y,x),2) == 0
flooded(y,x) = flooded(y,x+1) + 1;
continue;
end
end
end
end
end
if flooded(target_y, target_x) > 0 %If there is a flood value in the target cell, then enough flooding has occurred for a route to be planned.
break
end
end
I know my coding isn't the most legible, so if you have any problems... just ask