def test_matrix_min_and_max(self): m1 = [[-0.8, -0.5, 1.0, 2.6], [-0.8, -1.5, 8.8, 2.7]] m2 = [] m3 = [[], []] m4 = [[0.0]] self.assertEqual((-1.5, 8.8), matrix_min_and_max(m1)) self.assertEqual((None, None), matrix_min_and_max(m2)) self.assertEqual((None, None), matrix_min_and_max(m3)) self.assertEqual((0.0, 0.0), matrix_min_and_max(m4))
def test_matrix_min_and_max(self): m1 = [ [-0.8, -0.5, 1.0, 2.6], [-0.8, -1.5, 8.8, 2.7] ] m2 = [] m3 = [[], []] m4 = [[0.0]] self.assertEqual((-1.5, 8.8), matrix_min_and_max(m1)) self.assertEqual((None, None), matrix_min_and_max(m2)) self.assertEqual((None, None), matrix_min_and_max(m3)) self.assertEqual((0.0, 0.0), matrix_min_and_max(m4))
def sea_depth(world, sea_level): sea_depth = [[sea_level - world.elevation['data'][y][x] for x in range(world.width)] for y in range(world.height)] for y in range(world.height): for x in range(world.width): if world.tiles_around((x, y), radius=1, predicate=world.is_land): sea_depth[y][x] = 0 elif world.tiles_around((x, y), radius=2, predicate=world.is_land): sea_depth[y][x] *= 0.3 elif world.tiles_around((x, y), radius=3, predicate=world.is_land): sea_depth[y][x] *= 0.5 elif world.tiles_around((x, y), radius=4, predicate=world.is_land): sea_depth[y][x] *= 0.7 elif world.tiles_around((x, y), radius=5, predicate=world.is_land): sea_depth[y][x] *= 0.9 sea_depth = anti_alias(sea_depth, 10) min_depth, max_depth = matrix_min_and_max(sea_depth) sea_depth = [[rescale_value(sea_depth[y][x], min_depth, max_depth, 0.0, 1.0) for x in range(world.width)] for y in range(world.height)] return sea_depth
def sea_depth(world, sea_level): sea_depth = [[ sea_level - world.elevation['data'][y][x] for x in range(world.width) ] for y in range(world.height)] for y in range(world.height): for x in range(world.width): if world.tiles_around((x, y), radius=1, predicate=world.is_land): sea_depth[y][x] = 0 elif world.tiles_around((x, y), radius=2, predicate=world.is_land): sea_depth[y][x] *= 0.3 elif world.tiles_around((x, y), radius=3, predicate=world.is_land): sea_depth[y][x] *= 0.5 elif world.tiles_around((x, y), radius=4, predicate=world.is_land): sea_depth[y][x] *= 0.7 elif world.tiles_around((x, y), radius=5, predicate=world.is_land): sea_depth[y][x] *= 0.9 sea_depth = anti_alias(sea_depth, 10) min_depth, max_depth = matrix_min_and_max(sea_depth) sea_depth = [[ rescale_value(sea_depth[y][x], min_depth, max_depth, 0.0, 1.0) for x in range(world.width) ] for y in range(world.height)] return sea_depth