Add example/helper scripts

This commit is contained in:
Nate Bowman
2026-10-27 19:19:52 -04:00
parent 79e695a5b0
commit d29868960e
2 changed files with 49 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
from flashcards.maps import (create_maps,
read_data_to_dict)
from flashcards.fighting import generate_all_fight_results
# --- General section to read in names and data
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'units-test.txt'
#namelist = 'units-non-unique.txt'
# key into json file specifying which data you want
name_json_keys = 'units_buildings'
data_json_keys = ('data', 'Unit')
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
results = generate_all_fight_results(data, nums)
print(results)

View File

@@ -0,0 +1,44 @@
import itertools
from flashcards.config import config
from flashcards.maps import (create_maps,
read_data_to_dict,
read_name_data_to_dict)
# --- General section to read in names and data
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'research-standard.txt'
# key into json file specifying which data you want
name_json_keys = 'techs'
data_json_keys = ('civs',)
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
non_uniques = []
uniques = []
for name, num in nums.items():
count = 0
recent_civ = None
for civ in data.keys():
if int(num) in data[civ]['Tech']:
count += 1
recent_civ = civ
if count == 1:
#print(f'{name}: {recent_civ}')
uniques.append(name)
elif count > 1:
non_uniques.append(name)
with open(config.namelists_dir / 'research-unique.txt', 'w') as f:
f.writelines('\n'.join(uniques))
f.write('\n')
with open(config.namelists_dir / 'research-non-unique.txt', 'w') as f:
f.writelines('\n'.join(non_uniques))
f.write('\n')