Exemple #1
0
def load_names(type, string_to_token):
    path = dmtools.get_data_path() + "names/"
    path += type + "_names.txt"
    data = []
    with open(path, "rb") as f:
        for line in f:
            data += [START_TOKEN] + tokenify(line.strip(), string_to_token) + [END_TOKEN]
    return data
Exemple #2
0
def load_tokens(type):
    path = dmtools.get_data_path() + "names/"
    path += type + "_tokens.txt"
    string_to_token = {">": END_TOKEN, "<": START_TOKEN}
    token_to_string = {END_TOKEN: ">", START_TOKEN: "<"}
    with open(path, "rb") as f:
        for i, line in enumerate(f):
            string_to_token[line.strip()] = i
            token_to_string[i] = line.strip()
    return string_to_token, token_to_string
Exemple #3
0
def generate(water_level=0.15,
             seed=6,
             show_france=True):

    data_path = dmtools.get_data_path()
    generate_coastline(data_path, water_level, show_france, seed)
    generate_elevation(data_path, seed)
    generate_temperature(data_path)
    generate_wind(data_path, seed)
    generate_moisture(data_path)
    generate_biomes(data_path)
    generate_history(data_path)
    render_image(data_path)
Exemple #4
0
def generate_notes(moral_alignment, law_alignment):
    data_path = dmtools.get_data_path()
    with open(data_path + "npcs/appearance.txt") as f:
        appearance = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/mannerisms.txt") as f:
        mannerism = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/interaction.txt") as f:
        interaction = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/abilities.txt") as f:
        abilities = f.readlines()
        ability1 = random.choice(abilities)
        abilities.remove(ability1)
        ability1 = ability1.strip()
        ability2 = random.choice(abilities).strip()
    with open(data_path + "npcs/talents.txt") as f:
        talent = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/ideals_" + alignment_to_string[moral_alignment] + ".txt") as f:
        moral_ideal = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/ideals_" + alignment_to_string[law_alignment] + ".txt") as f:
        law_ideal = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/bonds.txt") as f:
        bond = random.choice(f.readlines()).strip()
    with open(data_path + "npcs/flaws.txt") as f:
        flaw = random.choice(f.readlines()).strip()

    return [
        appearance,
        mannerism,
        interaction,
        ability1,
        ability2,
        talent,
        "Ideals: " + moral_ideal + ", " + law_ideal.lower(),
        "Bond: " + bond,
        "Flaw: " + flaw,
    ]