Beispiel #1
0
def run_tabou(file_number: str):
    file_config = open("test_config/tabou/tabou" + file_number + ".txt", "r")
    file_name = file_config.readline().strip("\n")
    nb_test = file_config.readline().strip("\n")
    index_test = 1
    weights, distances = tools.parse_file("data/" + file_name)
    # Partie avec plaquette fixe
    config = file_config.readline().strip("\n")
    while config != "random":
        config_infos = config.split(";")
        lancer_tabou_fixe(weights, distances, int(config_infos[0]),
                          int(config_infos[1]), int(config_infos[2]),
                          file_number)
        config = file_config.readline().strip("\n")
        print(index_test, "/", nb_test)
        index_test += 1
    for config in file_config.readlines():
        config.strip("\n")
        config_infos = config.split(";")
        lancer_tabou_random(int(config_infos[0]), weights, distances,
                            int(config_infos[1]), int(config_infos[2]),
                            int(config_infos[3]), file_number)
        print(index_test, "/", nb_test)
        index_test += 1
    file_config.close()
    print("tabou", file_number, "finished")
Beispiel #2
0
                    edges.append((idx(i, j, k + 1), idx(i, j + 1, k + 1)))
                    edges.append((idx(i, j + 1, k), idx(i + 1, j + 1, k)))
                    edges.append((idx(i + 1, j, k), idx(i + 1, j + 1, k)))
                    edges.append((idx(i + 1, j, k), idx(i + 1, j, k + 1)))
                    edges.append((idx(i, j + 1, k), idx(i, j + 1, k + 1)))
                    edges.append((idx(i, j, k + 1), idx(i + 1, j, k + 1)))
    return edges


if __name__ == '__main__':

    cmin = 0
    cmax = 2
    n_points = 100  # very slow
    n_points = 30

    points = center(rescale(parse_file('../resources/demo4.mod1')))
    points = np.vstack([points, gen_borders(cmin, cmax, cmin, cmax)])

    hmap = height_map(points, n_points, cmin, cmax)
    nodes = height_to_nodes(hmap)
    edges = height_to_edges(hmap)

    wr = Wireframe()
    wr.addNodes(nodes)
    wr.addEdges(edges)
    pv = ProjectionViewerNP(800, 800)
    pv.addWireframe(wr)
    pv.cube_colors(hmap)
    pv.run()
Beispiel #3
0
import numpy as np
import wireframe
import ProjectionViewer as pview
import tools
from interpol import idw_mesh

if __name__ == '__main__':
    points = tools.center(tools.rescale(tools.parse_file('../resources/demo5.mod1')))
    print(points)
    points = np.vstack([points, tools.gen_borders(0, 2, 0, 2)])
    res = idw_mesh(points, 100, 0.6)

    wr = wireframe.Wireframe()
    wr.addNodes(res)

    pv = pview.ProjectionViewerNP(800, 800)
    pv.addWireframe(wr)
    pv.run()
            link.get('href').rsplit('=', 1)[-1],
            link.text.strip('!~').split(' :: ')[-1].split('2')[0].split(' : ')
            [0].split('(')[0].split('-')[0].split('[')[0].split(
                ' for ')[0].strip(),
            None,
            False,
        ])

    ########################
    # load stellaris files #
    ########################

    district_files_overwritten.extend(
        os.listdir(stellaris_folder + '/common/districts'))
    for file_name in district_files_overwritten:
        parsed = parse_file(stellaris_folder + '/common/districts/' +
                            file_name)
        district_output_files.append((file_name, parsed))
        for district_name in parsed:
            districts_overwritten.append(district_name)

    for output_file in district_output_files:
        for district_name, district in output_file[1].items():
            for key in [
                    'triggered_planet_modifier', 'triggered_desc',
                    'ai_resource_production'
            ]:
                for modifier in district[0].get_list(key):
                    modifier.ensure({'vanilla': [{'NOR': [{}]}]})

    district_files_overwritten.append('udp_extra_districts.txt')
    district_output_files.append(('udp_extra_districts.txt', StellarisDict()))