# Create a firewall firewall_x = int( grid_width / 3 ) for row in grid: row[ firewall_x ] = 3 # Now leave some holes porosity = 0.2 num_holes = int( grid_height * porosity ) hole_count = 0 while hole_count < num_holes: hole_y = random.randint( 0 , grid_height - 1 ) if grid[ hole_y ][ firewall_x ] == 3: grid[ hole_y ][ firewall_x ] = 1 hole_count += 1