Add example/helper scripts
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import itertools
|
||||
|
||||
from flashcards.maps import (create_maps,
|
||||
read_data_to_dict,
|
||||
read_name_data_to_dict)
|
||||
read_data_to_dict)
|
||||
from flashcards.fighting import generate_all_fight_results
|
||||
|
||||
|
||||
@@ -11,7 +8,8 @@ from flashcards.fighting import generate_all_fight_results
|
||||
|
||||
# specify the namelist to be used to create the deck
|
||||
# give the relative path of the file from config.namelists_dir
|
||||
namelist = 'units-buildings-trimmed.txt'
|
||||
namelist = 'units-test.txt'
|
||||
#namelist = 'units-non-unique.txt'
|
||||
|
||||
# key into json file specifying which data you want
|
||||
name_json_keys = 'units_buildings'
|
||||
@@ -20,4 +18,5 @@ data_json_keys = ('data', 'Unit')
|
||||
_, nums = create_maps(namelist, name_json_keys)
|
||||
data = read_data_to_dict(data_json_keys)
|
||||
|
||||
generate_all_fight_results(data, nums)
|
||||
results = generate_all_fight_results(data, nums)
|
||||
print(results)
|
||||
44
scripts/find-unique-research.py
Normal file
44
scripts/find-unique-research.py
Normal 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')
|
||||
Reference in New Issue
Block a user