Ejemplo n.º 1
0
 def setUp(self):
     self.world = World(w=self.W, h=self.H, config=BaseConfig)
     self.layer = self.world.layer_wind
Ejemplo n.º 2
0
from deworld import power_points
from deworld.configs import BaseConfig
from deworld import normalizers
from deworld.cartographer import draw_world

# shutil.rmtree('./results', ignore_errors=True)

# os.mkdir('./results')
# os.mkdir('./results/height')
# os.mkdir('./results/temperature')
# os.mkdir('./results/wind')

WIDTH = 100
HEIGHT = 100

world = World(w=WIDTH, h=HEIGHT, config=BaseConfig)


def get_height_power_function(borders, power_percent=1.0):
    def power_function(world, x, y):
        height = world.layer_height.data[y][x]

        if height < borders[0]:
            return (0.0, math.fabs(borders[0] - height) * power_percent)
        if height > borders[1]:
            return (math.fabs(borders[1] - height) * power_percent, 0.0)

        optimal = (borders[0] + borders[1]) / 2

        if height < optimal:
            return (0.0, math.fabs(borders[0] - height) / 2 * power_percent)