コード例 #1
0
ファイル: plates.py プロジェクト: pangal/worldengine
def world_gen(name, width, height, seed, temps, humids, num_plates=10, ocean_level=1.0,
              step=Step.full(), fade_borders=True, verbose=get_verbose()):
    if verbose:
        start_time = time.time()
    world = _plates_simulation(name, width, height, seed, temps, humids, num_plates,
                               ocean_level, step, verbose)

    center_land(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: set_elevation, set_plates, center_land " +
              "complete. Elapsed time " + str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    add_noise_to_elevation(world, numpy.random.randint(0, 4096))  # uses the global RNG; this is the very first call to said RNG - should that change, this needs to be taken care of
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: elevation noise added. Elapsed time " +
              str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    if fade_borders:
        place_oceans_at_map_borders(world)
    initialize_ocean_and_thresholds(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: oceans initialized. Elapsed time " +
              str(elapsed_time) + " seconds.")

    return generate_world(world, step)
コード例 #2
0
def generate_plates(seed, world_name, output_dir, width, height,
                    num_plates=10):
    """
    Eventually this method should be invoked when generation is called at
    asked to stop at step "plates", it should not be a different operation
    :param seed:
    :param world_name:
    :param output_dir:
    :param width:
    :param height:
    :param num_plates:
    :return:
    """
    elevation, plates = generate_plates_simulation(seed, width, height,
                                                   num_plates=num_plates)

    world = World(world_name, width, height, seed, num_plates, -1.0, "plates")
    world.set_elevation(numpy.array(elevation).reshape(height, width), None)
    world.set_plates(array_to_matrix(plates, width, height))

    # Generate images
    filename = '%s/plates_%s.png' % (output_dir, world_name)
    # TODO calculate appropriate sea_level
    sea_level = 1.0
    draw_simple_elevation_on_file(world, filename, None)
    print("+ plates image generated in '%s'" % filename)
    geo.center_land(world)
    filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ centered plates image generated in '%s'" % filename)
コード例 #3
0
ファイル: plates.py プロジェクト: stefan-feltmann/lands
def world_gen(name, width, height, seed, num_plates=10, ocean_level=1.0,
              step=Step.full(), verbose=get_verbose()):
    if verbose:
        start_time = time.time()
    world = _plates_simulation(name, width, height, seed, num_plates,
                               ocean_level, step, verbose)

    center_land(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: set_elevation, set_plates, center_land " +
              "complete. Elapsed time " + str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    add_noise_to_elevation(world, random.randint(0, 4096))
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: elevation noise added. Elapsed time " +
              str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    place_oceans_at_map_borders(world)
    initialize_ocean_and_thresholds(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: oceans initialized. Elapsed time " +
              str(elapsed_time) + " seconds.")

    return generate_world(world, step)
コード例 #4
0
ファイル: main.py プロジェクト: Mindwerks/worldengine
def generate_plates(seed, world_name, output_dir, width, height,
                    num_plates=10):
    """
    Eventually this method should be invoked when generation is called at
    asked to stop at step "plates", it should not be a different operation
    :param seed:
    :param world_name:
    :param output_dir:
    :param width:
    :param height:
    :param num_plates:
    :return:
    """
    elevation, plates = generate_plates_simulation(seed, width, height,
                                                   num_plates=num_plates)

    world = World(world_name, Size(width, height), seed,
                  GenerationParameters(num_plates, -1.0, "plates"))
    world.elevation = (numpy.array(elevation).reshape(height, width), None)
    world.plates = numpy.array(plates, dtype=numpy.uint16).reshape(height, width)

    # Generate images
    filename = '%s/plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ plates image generated in '%s'" % filename)
    geo.center_land(world)
    filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ centered plates image generated in '%s'" % filename)
コード例 #5
0
ファイル: plates.py プロジェクト: tcld/worldengine
def world_gen(name,
              width,
              height,
              seed,
              temps=[.874, .765, .594, .439, .366, .124],
              humids=[.941, .778, .507, .236, 0.073, .014, .002],
              num_plates=10,
              ocean_level=1.0,
              step=Step.full(),
              gamma_curve=1.25,
              curve_offset=.2,
              fade_borders=True,
              verbose=get_verbose()):
    if verbose:
        start_time = time.time()
    world = _plates_simulation(name, width, height, seed, temps, humids,
                               gamma_curve, curve_offset, num_plates,
                               ocean_level, step, verbose)

    center_land(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: set_elevation, set_plates, center_land " +
              "complete. Elapsed time " + str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    add_noise_to_elevation(
        world, numpy.random.randint(0, 4096)
    )  # uses the global RNG; this is the very first call to said RNG - should that change, this needs to be taken care of
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: elevation noise added. Elapsed time " +
              str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    if fade_borders:
        place_oceans_at_map_borders(world)
    initialize_ocean_and_thresholds(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: oceans initialized. Elapsed time " +
              str(elapsed_time) + " seconds.")

    return generate_world(world, step)
コード例 #6
0
ファイル: plates.py プロジェクト: sdp0et/worldengine
def world_gen(name,
              width,
              height,
              seed,
              num_plates=10,
              ocean_level=1.0,
              step=Step.full(),
              fade_borders=True,
              verbose=get_verbose()):
    if verbose:
        start_time = time.time()
    world = _plates_simulation(name, width, height, seed, num_plates,
                               ocean_level, step, verbose)

    center_land(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: set_elevation, set_plates, center_land " +
              "complete. Elapsed time " + str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    add_noise_to_elevation(world, random.randint(0, 4096))
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: elevation noise added. Elapsed time " +
              str(elapsed_time) + " seconds.")

    if verbose:
        start_time = time.time()
    if fade_borders:
        place_oceans_at_map_borders(world)
    initialize_ocean_and_thresholds(world)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.world_gen: oceans initialized. Elapsed time " +
              str(elapsed_time) + " seconds.")

    return generate_world(world, step)
コード例 #7
0
ファイル: main.py プロジェクト: olivierh59500/worldengine
def generate_plates(seed,
                    world_name,
                    output_dir,
                    width,
                    height,
                    num_plates=10):
    """
    Eventually this method should be invoked when generation is called at
    asked to stop at step "plates", it should not be a different operation
    :param seed:
    :param world_name:
    :param output_dir:
    :param width:
    :param height:
    :param num_plates:
    :return:
    """
    elevation, plates = generate_plates_simulation(seed,
                                                   width,
                                                   height,
                                                   num_plates=num_plates)

    world = World(world_name, Size(width, height), seed,
                  GenerationParameters(num_plates, -1.0, "plates"))
    world.elevation = (numpy.array(elevation).reshape(height, width), None)
    world.plates = numpy.array(plates,
                               dtype=numpy.uint16).reshape(height, width)

    # Generate images
    filename = '%s/plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ plates image generated in '%s'" % filename)
    geo.center_land(world)
    filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ centered plates image generated in '%s'" % filename)