Ok, so I am writing a program that will go through the grid and find the cameras. For each camera that is white, it fills it with color. As long as the gap next to this spot is also white, it continues to fill with color until the space is a wall. Then he continues scanning until he finds a new white camera. here is an example of what the grid will look like: http://imgur.com/uDzzq . Here is the code so far ...
x = 0 y = 0 if cave[row][col] != AIR: return if cave[row][col] == WATER: return if cave[row][col] == AIR: cave[row][col] = WATER grid.fill_cell(row, col, color) if row <= length: #RIGHT fill(cave, row+1, col, color) x+=1 if col <= length: #DOWN fill(cave, row, col+1, color) y+=1 if row >= 0: #LEFT fill(cave, row-1, col, color) x-=1 if col >= 0: #UP fill(cave, row, col-1, color) y-=1
and here it is called
for row in range(length) : for col in range(length): if(cave[row][col]): if(cave[row][col]) == AIR: color = grid.get_cur_color() fill(cave, row, col, color) chambers += 1 grid.get_next_color()
The problem I am facing is that it only works in very simple caves. When I try to run something that does not have walls bordering on the outside, I get errors. Can anyone determine where my problem is? This is an example of more complex caves and what it should look like at the end: http://imgur.com/41ptc
source share