def combine(wavs): output = zeros(len(wavs[0])) for i in range(len(wavs[0])): for a in range(len(wavs)): output[i] = output[i] + wavs[a][i] output = output/len(wavs) return output
search(input_grid, flow_grid, space):
if space has flow or cannot flow:
return
if space doesn't have flow and can flow:
mark space with flow
search neighbors (which neighbors depends on which type of percolation)
percolation(input_grid):
initialize flow_grid to all ones
search from every square in the top row
check bottom row for flow