Compare commits

...

9 Commits

Author SHA1 Message Date
Nate Bowman
a586357cc0 Add examples of deck scripts and namelists 2026-11-21 14:49:53 -05:00
Nate Bowman
6d05bfa7d5 Add non-AI MIT license 2026-11-21 13:54:28 -05:00
Nate Bowman
9132636d40 Add helper function 2026-11-20 19:59:59 -05:00
Nate Bowman
9c4b9bd020 Add another namelist because I need it elsewhere 2026-10-28 19:46:19 -04:00
Nate Bowman
80bb9790bf Remove fighting files from module
Moved them to their own module. Must now import that module to use any
of the fighting functions.
2026-10-27 19:51:53 -04:00
Nate Bowman
361a63b478 Add research deck 2026-10-27 19:23:22 -04:00
Nate Bowman
8cfd03c6ec Allow creation of fighting cards in bulk 2026-10-27 19:22:44 -04:00
Nate Bowman
d29868960e Add example/helper scripts 2026-10-27 19:19:52 -04:00
Nate Bowman
79e695a5b0 Remove duplicates from name_data file
Several names show up more than once under various IDs. I think this is
due to some of them existing in an old version of the game and being
scrapped and replaced with new ones. In any case, the duplicates threw
off some of the scripts.
2026-10-27 19:17:09 -04:00
32 changed files with 1890 additions and 833 deletions

31
LICENSE.txt Normal file
View File

@@ -0,0 +1,31 @@
MIT NON-AI License
Copyright (c) 2026, Nathaniel Bowman
Permission is hereby granted, free of charge, to any person obtaining a copy of the software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
In addition, the following restrictions apply:
1. The Software and any modifications made to it may not be used for the purpose of training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining. This condition applies to any derivatives,
modifications, or updates based on the Software code. Any usage of the Software in an AI-training dataset is considered a breach of this License.
2. The Software may not be included in any dataset used for training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining.
3. Any person or organization found to be in violation of these restrictions will be subject to legal action and may be held liable
for any damages resulting from such use.
4. This software repository contains open-source software licenses that can be modified and used to derive other software licenses.
However, no derivative, modification or update is allowed to remove the licensing conditions that forbid the use of that derivative
for the purpose of training, or improving machine learning algorithms, including but not limited to artificial intelligence,
natural language processing, or data mining.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -56,6 +56,8 @@ The data used for this project was downloaded from:
* https://github.com/SiegeEngineers/aoe2techtree/blob/master/data/locales/en/strings.json
```
A few duplicate(-ish) elements were removed from `units_buildings_techs.de.json`.
The SiegeEngineers team on Github has a lot of cool stuff.
You should check them out.
The particular projects I took this from are called HALFON and aoe2techtree.

View File

@@ -1,150 +0,0 @@
{
"armor": {
"Parthian Tactics": [
{"Amount": 1, "Class": 4},
{"Amount": 2, "Class": 3}
],
"Gambesons": [
{"Amount": 1, "Class": 3}
],
"Padded Archer Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Leather Archer Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Ring Archer Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 2, "Class": 3}
],
"Scale Barding Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Chain Barding Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Plate Barding Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 2, "Class": 3}
],
"Scale Mail Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Chain Mail Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3}
],
"Plate Mail Armor": [
{"Amount": 1, "Class": 4},
{"Amount": 2, "Class": 3}
],
"Masonry": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3},
{"Amount": 3, "Class": 11}
],
"Architecture": [
{"Amount": 1, "Class": 4},
{"Amount": 1, "Class": 3},
{"Amount": 3, "Class": 11}
],
"Careening": [
{"Amount": 1, "Class": 3}
],
"Dry Dock": [
{"Amount": 1, "Class": 3}
],
"Loom": [
{"Amount": 1, "Class": 4},
{"Amount": 2, "Class": 3}
]
},
"attack": {
"Parthian Tactics": [
{"Amount": 2, "Class": 3}
],
"Arson": [
{"Amount": 2, "Class": 16}
],
"Forging": [
{"Amount": 1, "Class": 4}
],
"Iron Casting": [
{"Amount": 1, "Class": 4}
],
"Blast Furnace": [
{"Amount": 2, "Class": 4}
],
"Fletching": [
{"Amount": 1, "Class": 3}
],
"Bodkin Arrow": [
{"Amount": 1, "Class": 3}
],
"Bracer": [
{"Amount": 1, "Class": 3}
],
"Chemistry": [
{"Amount": 1, "Class": 3}
],
"Heated Shot (Castle, Krepost, or Harbor)": [
{"Amount": 4, "Class": 16}
],
"Sappers": [
{"Amount": 15, "Class": 11},
{"Amount": 15, "Class": 13},
{"Amount": 3, "Class": 17}
],
"Arrowslits (Watch Tower)": [
{"Amount": 1, "Class": 3}
],
"Arrowslits (Guard Tower)": [
{"Amount": 2, "Class": 3}
],
"Arrowslits (Keep or Donjon)": [
{"Amount": 3, "Class": 3}
],
"Siege Engineers (siege)": [
{"Percent": 20, "Class": 11},
{"Percent": 20, "Class": 13},
{"Percent": 20, "Class": 21},
{"Percent": 20, "Class": 22},
{"Percent": 20, "Class": 26}
],
"Siege Engineers (demo)": [
{"Percent": 40, "Class": 11},
{"Percent": 40, "Class": 13},
{"Percent": 40, "Class": 21},
{"Percent": 40, "Class": 22},
{"Percent": 40, "Class": 26}
],
"Heated Shot (Tower)": [
{"Percent": 125, "Class": 16}
]
},
"hp": {
"Bloodlines": [
{"Amount": 20, "Class": -1}
],
"Hoardings": [
{"Amount": 1000, "Class": -1}
],
"Sanctity": [
{"Amount": 15, "Class": -1}
],
"Loom": [
{"Amount": 15, "Class": -1}
],
"Masonry": [
{"Percent": 10, "Class": -1}
],
"Architecture": [
{"Percent": 10, "Class": -1}
]
}
}

178
data/counters.json Normal file
View File

@@ -0,0 +1,178 @@
{
"Archer": {
"hard": [
"Militia",
"Spearman",
"Slinger",
"Camel Rider",
"Monk"
],
"soft": [
"Hand Cannoneer",
"Scout Cavalry",
"Steppe Lancer"
]
},
"Hand Cannoneer": {
"hard": [
"Militia",
"Spearman",
"Eagle",
"Slinger",
"Monk"
],
"soft": [
"Camel Rider",
"Steppe Lancer"
]
},
"Skirmisher": {
"hard": [
"Spearman",
"Archer",
"Slinger",
"Hand Cannoneer",
"Cavalry Archer",
"Elephant Archer",
"Monk"
],
"soft": []
},
"Knight": {
"hard": [
"Skirmisher",
"Slinger",
"Scout Cavalry"
],
"soft": [
"Militia",
"Eagle",
"Hand Cannoneer",
"Elephant Archer",
"Steppe Lancer"
]
},
"Cavalry Archer": {
"hard": [
"Militia",
"Slinger",
"Monk"
],
"soft": [
"Spearman",
"Archer",
"Hand Cannoneer",
"Knight",
"Steppe Lancer"
]
},
"Militia": {
"hard": [
"Spearman",
"Eagle"
],
"soft": [
"Skirmisher",
"Scout Cavalry",
"Camel Rider",
"Monk"
]
},
"Spearman": {
"hard": [
"Scout Cavalry",
"Knight",
"Camel Rider",
"Battle Elephant"
],
"soft": [
"Elephant Archer",
"Steppe Lancer"
]
},
"Monk": {
"hard": [
"Elephant Archer",
"Knight",
"Camel Rider",
"Battle Elephant"
],
"soft": [
"Steppe Lancer"
]
},
"Slinger": {
"hard": [
"Militia",
"Spearman",
"Eagle",
"Monk"
],
"soft": []
},
"Camel Rider": {
"hard": [
"Skirmisher",
"Elephant Archer",
"Scout Cavalry",
"Knight",
"Battle Elephant",
"Steppe Lancer"
],
"soft": [
"Slinger",
"Cavalry Archer"
]
},
"Scout Cavalry": {
"hard": [
"Skirmisher",
"Slinger",
"Monk"
],
"soft": []
},
"Battle Elephant": {
"hard": [
"Militia",
"Eagle",
"Scout Cavalry",
"Knight",
"Steppe Lancer"
],
"soft": []
},
"Steppe Lancer": {
"hard": [
"Skirmisher"
],
"soft": [
"Militia",
"Eagle",
"Slinger"
]
},
"Eagle": {
"hard": [
"Archer",
"Skirmisher",
"Monk"
],
"soft": [
"Spearman",
"Scout Cavalry",
"Camel Rider"
]
},
"Monk": {
"hard": [
"Elephant Archer",
"Knight",
"Camel Rider",
"Battle Elephant"
],
"soft": [
"Steppe Lancer"
]
}
}

View File

@@ -805,29 +805,6 @@
"localised_name": "",
"rms_const": null
},
"35": {
"cost": {
"wood": 160,
"food": 0,
"gold": 75,
"stone": 0
},
"attack": 2,
"melee_armor": -3,
"pierce_armor": 180,
"base_id": 35,
"help_converter": 26094,
"language_file_name": 5094,
"language_file_help": 105094,
"name": "BTRAM",
"hit_points": 175,
"line_of_sight": 3,
"garrison_capacity": 6,
"type": 70,
"class": 13,
"localised_name": "Battering Ram",
"rms_const": "BATTERING_RAM"
},
"36": {
"cost": {
"wood": 225,
@@ -4232,29 +4209,6 @@
"localised_name": "",
"rms_const": null
},
"184": {
"cost": {
"wood": 0,
"food": 50,
"gold": 35,
"stone": 0
},
"attack": 9,
"melee_armor": 1,
"pierce_armor": 3,
"base_id": 184,
"help_converter": 26114,
"language_file_name": 5114,
"language_file_help": 105114,
"name": "CONDOPLACEHOLDER",
"hit_points": 80,
"line_of_sight": 6,
"garrison_capacity": 0,
"type": 70,
"class": 6,
"localised_name": "Condottiero",
"rms_const": null
},
"185": {
"cost": {
"wood": 25,
@@ -13202,29 +13156,6 @@
"localised_name": "",
"rms_const": null
},
"583": {
"cost": {
"wood": 50,
"food": 60,
"gold": 0,
"stone": 0
},
"attack": 4,
"melee_armor": 0,
"pierce_armor": 1,
"base_id": 583,
"help_converter": 26663,
"language_file_name": 5663,
"language_file_help": 105663,
"name": "GENIT",
"hit_points": 60,
"line_of_sight": 5,
"garrison_capacity": 0,
"type": 70,
"class": 36,
"localised_name": "Genitour",
"rms_const": "GENITOUR"
},
"584": {
"cost": {
"wood": 100,
@@ -13501,29 +13432,6 @@
"localised_name": "",
"rms_const": null
},
"596": {
"cost": {
"wood": 50,
"food": 60,
"gold": 0,
"stone": 0
},
"attack": 5,
"melee_armor": 0,
"pierce_armor": 1,
"base_id": 596,
"help_converter": 26665,
"language_file_name": 5665,
"language_file_help": 105665,
"name": "GENITX",
"hit_points": 70,
"line_of_sight": 6,
"garrison_capacity": 0,
"type": 70,
"class": 36,
"localised_name": "Elite Genitour",
"rms_const": "ELITE_GENITOUR"
},
"597": {
"cost": {
"wood": 275,
@@ -20079,29 +19987,6 @@
"localised_name": "Wild Camel",
"rms_const": "DLC_WILD_CAMEL"
},
"885": {
"cost": {
"wood": 220,
"food": 0,
"gold": 120,
"stone": 0
},
"attack": 6,
"melee_armor": -2,
"pierce_armor": 100,
"base_id": 885,
"help_converter": 26446,
"language_file_name": 5445,
"language_file_help": 105446,
"name": "SGTWR",
"hit_points": 220,
"line_of_sight": 8,
"garrison_capacity": 6,
"type": 70,
"class": 13,
"localised_name": "Siege Tower",
"rms_const": null
},
"886": {
"cost": {
"wood": 0,
@@ -21114,29 +20999,6 @@
"localised_name": "Khosrau",
"rms_const": null
},
"931": {
"cost": {
"wood": 0,
"food": 60,
"gold": 60,
"stone": 0
},
"attack": 18,
"melee_armor": 1,
"pierce_armor": 1,
"base_id": 931,
"help_converter": 26000,
"language_file_name": 5702,
"language_file_help": 105000,
"name": "JARL",
"hit_points": 140,
"line_of_sight": 7,
"garrison_capacity": 0,
"type": 70,
"class": 12,
"localised_name": "Jarl",
"rms_const": null
},
"932": {
"cost": {
"wood": 0,
@@ -21275,29 +21137,6 @@
"localised_name": "",
"rms_const": null
},
"938": {
"cost": {
"wood": 180,
"food": 0,
"gold": 180,
"stone": 0
},
"attack": 4,
"melee_armor": 3,
"pierce_armor": 8,
"base_id": 938,
"help_converter": 26739,
"language_file_name": 5739,
"language_file_help": 105739,
"name": "DRAGS",
"hit_points": 150,
"line_of_sight": 6,
"garrison_capacity": 0,
"type": 70,
"class": 22,
"localised_name": "Dragon Ship",
"rms_const": null
},
"939": {
"cost": {
"wood": 0,
@@ -80399,4 +80238,4 @@
"localised_name": ""
}
}
}
}

28
decks/building-costs.py Normal file
View File

@@ -0,0 +1,28 @@
from flashcards.decks import create_deck_from_back_function
# your choice of deck name and filename
deck_name = 'Building Costs'
deck_fname = 'building-costs'
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'buildings.txt'
# key into json file specifying which data you want
# uncomment either 'units_buildings' or 'techs'
data_json_key = 'units_buildings'
#data_json_key = 'techs'
def card_back(num, name, data):
cost = data[num]['cost']
back = '\n'.join([f'{res}: {val}' for res, val in cost.items()
if val != 0])
return back
create_deck_from_back_function(namelist,
data_json_key,
card_back,
deck_name,
deck_fname)

32
decks/building-times.py Normal file
View File

@@ -0,0 +1,32 @@
from flashcards.decks import create_deck
from flashcards.maps import (create_name_to_lname_map,
read_data_to_dict)
# your choice of deck name and filename
deck_name = 'Building Times'
deck_fname = 'building-times'
namelist = 'buildings.txt'
name_json_key = 'units_buildings'
data_json_keys = ('data', 'Building',)
lnames = create_name_to_lname_map(namelist, name_json_key)
data = read_data_to_dict(data_json_keys)
notes = []
for v in data.values():
name = v['internal_name']
if name in lnames.keys():
front = lnames[name]
back = str(v['TrainTime'])
notes.append((front, back))
#print(front, back)
else:
print(f'missing: {name} --')
print(v)
print('\n\n')
deck = create_deck(notes, deck_name, deck_fname)

54
decks/counters.py Normal file
View File

@@ -0,0 +1,54 @@
from collections import defaultdict
import json
from flashcards.config import config
from flashcards.decks import create_deck
from flashcards.maps import create_maps, read_name_data_to_dict
def generate_counter_list(counters):
all_c_names = []
for c_type in sorted(counters.keys()):
c_names = '\n'.join(counters[c_type])
if len(c_names) > 0:
all_c_names.append(f'<b>{c_type}</b>:\n\n{c_names}')
return '\n\n\n'.join(all_c_names)
# your choice of deck name and filename
deck_name = 'Counters'
deck_fname = 'counters'
# --- create list of notes ---
# read in data
with open(config.data_dir / 'counters.json', 'r') as f:
data = json.load(f)
# determine countered_by from counters
all_countered_by = defaultdict(lambda: defaultdict(list))
for unit, counters in data.items():
for counter_type in counters.keys(): # 'hard' or 'soft'
for unit2 in counters[counter_type]:
all_countered_by[unit2][counter_type].append(unit)
notes = []
for unit in data.keys():
# note: 'counters' contains units countered *by* 'unit'
# note: 'countered_by' contains units that counter 'unit'
counters = data[unit]
countered_by = all_countered_by[unit]
front = f'{unit} is a counter against...'
back = generate_counter_list(counters)
notes.append((front, back))
#print(f'front: {front}\tback: {back}')
front = f'{unit} is countered by...'
back = generate_counter_list(countered_by)
notes.append((front, back))
#print(f'front: {front}\tback: {back}')
# write deck to .apkg file
deck = create_deck(notes, deck_name, deck_fname)

View File

@@ -0,0 +1,44 @@
from flashcards.decks import create_deck
from fighting.fighting import Fighting
from flashcards.maps import (create_maps,
read_data_to_dict)
# your choice of deck name and filename
deck_name = 'Fighting (Units, Non-Unique)'
deck_fname = 'fighting-non-unique-units'
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'units-non-unique.txt'
# key into json file specifying which data you want
name_json_keys = 'units_buildings'
data_json_keys = ('data', 'Unit')
# --- create list of notes ---
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
fight = Fighting(data, nums)
results = fight.generate_all_fight_results()
# create cards based on data and maps
notes = []
for k, v in results.items():
attacker, defender = k
title = f'{attacker} attacking {defender}'
for fight in v:
front = '\n'.join([title, fight['notes']])
hits = [f'{bonus}: {hit}' for bonus, hit in fight['hits'].items()]
back = '\n'.join(hits)
notes.append((front, back))
#print(f'front: {front}\tback: {back}')
# write deck to .apkg file
deck = create_deck(notes, deck_name, deck_fname)

View File

@@ -0,0 +1,54 @@
from flashcards.decks import create_deck
from flashcards.helpers import parse_research_string
from flashcards.maps import (create_maps,
read_data_to_dict,
read_name_data_to_dict,
read_string_data_to_dict)
# your choice of deck name and filename
deck_name = 'Research (Non-Unique)'
deck_fname = 'research-non-unique'
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'research-non-unique.txt'
# key into json file specifying which data you want
name_json_keys = 'techs'
data_json_keys = ('data', 'Tech',)
string_json_keys = ()
# --- create list of notes ---
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
names = read_name_data_to_dict(name_json_keys)
strings = read_string_data_to_dict(string_json_keys)
# create cards based on data and maps
order = ['Wood', 'Food', 'Gold', 'Stone']
notes = []
for name, num in nums.items():
front = name
cost = data[num]['Cost']
# works, but puts wood in the wrong order (i.e., after food)
#all_cost = '\n'.join([f'{res}: {val}' for res, val in cost.items()
#if val != 0])
all_cost = '\n'.join([f'{k}: {cost[k]}' for k in order
if k in cost.keys() and cost[k] != 0])
time_text = f'Research time: {data[num]["ResearchTime"]}'
help_id = str(names[num]['help_converter'])
help_text = parse_research_string(strings[help_id])
back = '\n\n'.join([all_cost, time_text, help_text])
notes.append((front, back))
#print(f'front: {name}\tback: {back}')
# write deck to .apkg file
deck = create_deck(notes, deck_name, deck_fname)

28
decks/units-times.py Normal file
View File

@@ -0,0 +1,28 @@
from flashcards.decks import create_deck
from flashcards.maps import (create_name_to_lname_map,
read_data_to_dict)
# your choice of deck name and filename
deck_name = 'Unit Training Times'
deck_fname = 'units-times'
namelist = 'units-non-unique.txt'
name_json_key = 'units_buildings'
data_json_keys = ('data', 'Unit',)
lnames = create_name_to_lname_map(namelist, name_json_key)
data = read_data_to_dict(data_json_keys)
notes = []
for v in data.values():
name = v['internal_name']
if name in lnames.keys():
front = lnames[name]
back = str(v['TrainTime'])
notes.append((front, back))
#print(front, back)
deck = create_deck(notes, deck_name, deck_fname)

40
decks/units-upgrades.py Normal file
View File

@@ -0,0 +1,40 @@
from flashcards.decks import create_deck
from flashcards.maps import (create_maps,
read_data_to_dict)
# your choice of deck name and filename
deck_name = 'Unit Upgrades'
deck_fname = 'unit-upgrades'
# key into json file specifying which data you want
data_json_keys = ('data', 'unit_upgrades',)
# --- create list of notes ---
data = read_data_to_dict(data_json_keys)
# create cards based on data and maps
order = ['Wood', 'Food', 'Gold', 'Stone']
notes = []
completed = set()
for d in data.values():
front = d['internal_name']
if front not in completed:
completed.add(front)
cost = d['Cost']
all_cost = '\n'.join([f'{k}: {cost[k]}' for k in order
if k in cost.keys() and cost[k] != 0])
time_text = f'Research time: {d["ResearchTime"]}'
back = '\n\n'.join([all_cost, time_text])
notes.append((front, back))
#print(f'front: {front}\tback: {back}')
# write deck to .apkg file
deck = create_deck(notes, deck_name, deck_fname)

View File

@@ -1,23 +0,0 @@
import itertools
from flashcards.maps import (create_maps,
read_data_to_dict,
read_name_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-buildings-trimmed.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)
generate_all_fight_results(data, nums)

View File

@@ -4,7 +4,7 @@ import yaml
config_file = 'settings.yaml'
config_file = '/home/nate/projects/aoe/flashcards/settings.yaml'
with open(config_file, 'r') as f:
c = yaml.safe_load(f)
@@ -12,8 +12,8 @@ data_path = Path(c['storage']['data'])
output_path = Path(c['storage']['output'])
config = SimpleNamespace()
config.data_dir = data_path
config.data_file = data_path / 'data.json'
config.bonus_data_file = data_path / 'bonuses.json'
config.name_data_file = data_path / 'name_data.json'
config.string_data_file = data_path / 'strings.json'
config.namelists_dir = output_path / 'namelists'

View File

@@ -1,141 +0,0 @@
from flashcards.types import ArmorClasses
ranges = {ArmorClasses.MELEE: {
'standard': range(-3, 5),
'parthian tactics (armor)': range(-3, 5),
'villager': range(0, 5),
'villager (loom)': range(-1, 4),
},
ArmorClasses.PIERCE: {
'standard': range(-4, 5),
'parthian tactics (armor)': range(-6, 5),
'parthian tactics (attack)': range(-4, 7),
'gambesons': range(-5, 5),
'villager': range(0, 5),
'villager (loom)': range(-2, 4),
}
}
bonuses = {
'attack': {
'Parthian Tactics': {
'attackers': [
'Cavalry Archer',
'Heavy Cavalry Archer',
'Mounted Crossbowman',
'Heavy Mounted Crossbowman',
'Elephant Archer',
'Mangudai',
'Elite Mangudai',
'War Wagon',
'Elite War Wagon',
'Camel Archer',
'Elite Camel Archer',
'Genitour',
'Elite Genitour',
'Kipchak',
'Elite Kipchak',
'Ratha (Ranged)',
'Elite Ratha (Ranged)',
'Xianbei Raider',
'Bolas Rider',
'Elite Bolas Rider',
'Arambai',
'Elite Arambai',
],
'defenders': [
'Spearman',
'Pikeman',
'Halberdier',
],
},
},
'armor': {
'Gambesons': [
'Milita',
'Man-at-Arms',
'Long Swordsman',
'Two-Handed Swordsman',
'Champion',
'Fire Lancer',
'Elite Fire Lancer',
'Varangian Guard',
'Elite Varangian Guard',
],
'Loom': ['Villager'],
},
'hp': {
'Bloodlines': [
'Arambai',
'Elite Arambai',
'Ballista Elephant',
'Elite Ballista Elephant',
'Battle Elephant',
'Elite Battle Elephant',
'Boyar',
'Elite Boyar',
'Camel Archer',
'Camel Rider',
'Camel Scout',
'Cavalier',
'Cavalry Archer',
'Heavy Cavalry Archer',
'Centurion',
'Elite Centurion',
'Conquistador',
'Elite Conquistador',
'Elephant Archer',
'Elite Elephant Archer',
'Flaming Camel',
'Genitour',
'Elite Genitour',
'Heavy Camel Rider',
'Hussar',
'Imperial Camel Rider',
'Iron Pagoda',
'Elite Iron Pagoda',
'Keshik',
'Elite Keshik',
'Kipchak',
'Elite Kipchak',
'Knight',
'Konnik',
'Elite Konnik',
'Leitis',
'Elite Leitis',
'Light Cavalry',
'Magyar Huszar',
'Elite Magyar Huszar',
'Mameluke',
'Elite Mameluke',
'Mangudai',
'Elite Mangudai',
'Missionary',
'Elite Missionary',
'Monaspa',
'Elite Monaspa',
'Paladin',
'Savar',
'Elite Savar',
'Scout Cavalry',
'Shrivamsha Rider',
'Elite Shrivamsha Rider',
'Steppe Lancer',
'Elite Steppe Lancer',
'Tarkan',
'Elite Tarkan',
'Tiger Cavalry',
'Elite Tiger Cavalry',
'War Elephant',
'Elite War Elephant',
'Winged Hussar',
'Xianbei Raider',
'Elite Xianbei Raider',
],
'Loom': ['Villager'],
},
}
bonuses['armor']['Parthian Tactics'] = bonuses['attack']['Parthian Tactics']['attackers']

View File

@@ -1,340 +0,0 @@
import itertools
import json
import math
from copy import deepcopy
from flashcards.config import config
from flashcards.types import BonusTypes, ArmorClasses
from flashcards import constants
def _calculate_hp_bonus(hp, bonuses):
for b in bonuses:
b_amount, _ = b.values()
if 'Amount' in b.keys():
hp += b_amount
else:
hp *= b_amount
hp = int(hp)
return hp
def _calculate_bonus(orig, bonuses, attack=False):
for b in bonuses:
b_amount, b_clss = b.values()
used = False
for iorig in range(len(orig)):
_, clss = orig[iorig].values()
if clss == b_clss:
if 'Amount' in b.keys():
orig[iorig]['Amount'] += b_amount
else:
orig[iorig]['Amount'] *= b_amount
orig[iorig]['Amount'] = int(orig[iorig]['Amount'])
used = True
if attack and not used:
# bonus can add an attack but should not add an armor type
orig.append(b)
def generate_bonus_with_value(amount, clss):
return {"Amount": amount, "Class": clss}
def generate_bonus_with_percent(amount, clss):
return {"Percent": amount, "Class": clss}
def get_bonuses_from_names(clss, names):
bonuses = []
if len(names) > 0:
with open(config.bonus_data_file, 'r') as f:
bonus_data = json.load(f)
for name in names:
bonuses.extend(bonus_data[clss.value][name])
return bonuses
def get_possible_bonus_names_for_fight(attacker, defender):
'''
Returns the bonuses as a tuple of lists. The first list contains attack
bonuses, the second armor bonuses, and the third hp bonuses.
'''
attack_bonuses = []
armor_bonuses = []
hp_bonuses = []
for bonus, names in constants.bonuses['attack'].items():
if bonus in ['Parthian Tactics']:
if (attacker in names['attackers'] and
defender in names['defenders']):
attack_bonuses.append(bonus)
elif attacker in names:
attack_bonuses.append(bonus)
for bonus, names in constants.bonuses['armor'].items():
if defender in names:
armor_bonuses.append(bonus)
for bonus, names in constants.bonuses['hp'].items():
if defender in names:
hp_bonuses.append(bonus)
return (attack_bonuses, armor_bonuses, hp_bonuses)
def get_bonus_range(attacker, defender, attack_type, extras):
'''
Determines the appropriate "bonus range" for an attacker-defender pair.
The poorly-named "bonus range" is the set of all possible
(attack - defense) values when considering all blacksmith research and any
extra research described in the `extras` argument. An example of "extra"
research would be Parthian Tactics.
For example, you can compute a single "bonus" (i.e., one element of the
"bonus range") as follows. If there are no `extra` bonuses, and if the
attacker has Iron Casting (i.e., +2 attack) and the defender has Scale
Barding Armor (i.e., +1 defense), then the "bonus" for that combination is
2 (attack) - 1 (defense) = 1 (bonus). By considering bonus as a single
number in this way, we do not need to consider all possible combinations of
attack and armor blacksmith research.
'''
possible = constants.ranges[attack_type]
if defender == 'Villager':
if 'Loom' in extras[2]:
return possible['villager (loom)']
else:
return possible['villager']
elif 'Parthian Tactics' in extras[1]:
return possible['parthian tactics (armor)']
elif attack_type == ArmorClasses.PIERCE:
if 'Parthian Tactics' in extras[0]:
return possible['parthian tactics (attack)']
elif 'Gambesons' in extras[1]:
return possible['gambesons']
return possible['standard']
def get_attack_type(attacker_id, data):
attacks = data[attacker_id]['Attacks']
val = 0
for attack in attacks:
if attack['Class'] == ArmorClasses.MELEE:
val = attack['Amount']
if val > 0:
return ArmorClasses.MELEE
else:
return ArmorClasses.PIERCE
def generate_notes(attack_bonus_names, armor_bonus_names, hp_bonus_names):
notes = ''
if len(hp_bonus_names) > 0:
notes += f'with {" and ".join(hp_bonus_names)} applied. '
other = attack_bonus_names + armor_bonus_names
if len(other) > 0:
verb = 'is'
if len(other) > 1:
verb = 'are'
notes += f'{" and ".join(other)} {verb} incoporated into net attack range'
return notes
def _powerset(elements):
for size in range(len(elements) + 1):
for combo in itertools.combinations(elements, size):
yield list(combo)
def generate_all_combinations(attack, armor, hp):
'''
Generates all combinations of bonuses, but assumes that most attack and
armor bonuses are always active. This is done because those bonuses are
already accounted for in the "bonus ranges" if using
generate_all_fight_results. If you are not using that function, it may not
make sense to call this one.
Note: avoids nonsensical combinations such as having Loom for HP but not
Loom for armor.
'''
armor = deepcopy(armor)
for b in armor:
if b in hp:
armor.remove(b)
attack_combos = [deepcopy(attack)]
armor_combos = [armor]
hp_combos = _powerset(hp)
all_combos = itertools.product(attack_combos, armor_combos, hp_combos)
return [_make_valid_combination(*val) for val in all_combos]
def _make_valid_combination(attack, armor, hp):
for name in hp:
if name in constants.bonuses['armor'].keys():
armor.append(name)
return (attack, armor, hp)
def calculate_hits_to_kill(attacker,
defender,
data,
nums,
attack_bonuses=[],
armor_bonuses=[],
hp_bonuses=[]):
'''
Calculates hits to kill for a single attacker and defender with one set of
bonuses (i.e., no looping over attackers, defenders, or bonuses).
'''
# Get base values
attacks = deepcopy(data[nums[attacker]]['Attacks'])
armors = deepcopy(data[nums[defender]]['Armours'])
hp = data[nums[defender]]['HP']
# Apply any bonuses from technologies or civilizations
_calculate_bonus(attacks, attack_bonuses, attack=True)
_calculate_bonus(armors, armor_bonuses)
hp = _calculate_hp_bonus(hp, hp_bonuses)
damage = 0
for a in attacks:
amount, clss = a.values()
for d in armors:
d_amount, d_clss = d.values()
if clss == d_clss:
damage += max(0, amount - d_amount)
damage = max(1, damage)
hits = math.ceil(hp/damage)
return hits
def generate_fight_results(attacker,
defender,
armor_class,
bonus_range,
data,
nums,
notes='',
extra_attack_bonuses=[],
extra_armor_bonuses=[],
hp_bonuses=[],
verbose=False):
'''
For a single attacker and defender, loops over all values of
(attack - defense) for blacksmith bonuses and Chemistry. Accepts extra
bonuses (e.g., Bloodlines), but the values of those extra bonuses are held
fixed for the duration of this function. Does not loop over attackers,
defenders, or any non-blacksmith (+Chemistry) bonuses.
'''
if verbose:
print(f'{attacker} attacking {defender}')
if len(notes) > 0:
print(notes)
print('--------------------------------')
results = {'hits': {}}
for i in bonus_range:
attack_bonuses = deepcopy(extra_attack_bonuses)
armor_bonuses = deepcopy(extra_armor_bonuses)
b = generate_bonus_with_value(abs(i), armor_class)
if i < 0:
armor_bonuses.append(b)
else:
attack_bonuses.append(b)
hits = calculate_hits_to_kill(attacker,
defender,
data,
nums,
attack_bonuses=attack_bonuses,
armor_bonuses=armor_bonuses,
hp_bonuses=hp_bonuses)
results['hits'][i] = hits
if verbose:
print(f'Net attack bonus: {i}\thits: {hits}')
results['notes'] = notes
return results
def generate_fight_results_from_names(attacker,
defender,
attack_type,
bonus_range,
data,
nums,
attack_bonus_names,
armor_bonus_names,
hp_bonus_names,
verbose):
'''
Simple convenience wrapper for generate_fight_results. Accepts
non-blacksmith bonuses' names (e.g., 'Bloodlines') and obtains the
corresponding bonuses in the form expected by generate_fight_results (i.e.,
lists of dictionaries). This function does not loop over anything itself,
although generate_fight_results, which this function calls, has its own
looping as described in its documentation.
Note: when using this wrapper for generate_fight_results, any extra attack
and armor upgrades are not actually applied as bonuses. It is assumed that
they are already incorporated into the provided bonus range.
'''
hp_bonuses = get_bonuses_from_names(BonusTypes.HP,
hp_bonus_names)
notes = generate_notes(attack_bonus_names,
armor_bonus_names,
hp_bonus_names)
return generate_fight_results(attacker,
defender,
attack_type,
bonus_range,
data,
nums,
notes=notes,
extra_attack_bonuses=[],
extra_armor_bonuses=[],
hp_bonuses=hp_bonuses,
verbose=verbose)
def generate_all_fight_results(data, nums):
'''
For a given group of units (specified implicitly by the nums argument,
which was itself probably generated from a namelist), determines the number
of hits for each unit to kill each other unit. For each pair, this function
loops over all possible values of blacksmith research and any other
relevant non-blacksmith bonuses found in fighting.constants.bonuses.
'''
for attacker, defender in itertools.product(nums.keys(), nums.keys()):
attack_type = get_attack_type(nums[attacker], data)
bonus_names = get_possible_bonus_names_for_fight(attacker, defender)
combos = generate_all_combinations(*bonus_names)
for combo in combos:
bonus_range = get_bonus_range(attacker, defender, attack_type, combo)
results = generate_fight_results_from_names(attacker,
defender,
attack_type,
bonus_range,
data,
nums,
combo[0],
combo[1],
combo[2],
True)
print(results)

3
flashcards/helpers.py Normal file
View File

@@ -0,0 +1,3 @@
def parse_research_string(string):
no_intro = string.split('\n')[1:]
return ' '.join(no_intro)

View File

@@ -33,6 +33,28 @@ def create_maps(namelist_fname, key):
return names, nums
def create_name_to_lname_map(namelist_fname, key):
# Read in the full data dictionary
with open(config.name_data_file, 'r') as f:
big = json.load(f)
# Use whitelist to filter data and map only as needed
namelist_path = config.namelists_dir / namelist_fname
with open(namelist_path, 'r') as f:
whitelist = [s.strip() for s in f.readlines()]
lnames = {}
for v in big[key].values():
lname = v['localised_name'].strip()
name = v['name'].strip()
if lname in whitelist:
if name in lnames.keys() and lnames[name] != lname:
raise Exception(f'Duplicate name {name} for {lname}')
lnames[name] = lname
return lnames
def read_string_data_to_dict(keys):
return _read_file_to_dict(config.string_data_file, keys)

View File

@@ -1,14 +0,0 @@
from enum import Enum, IntEnum
class ArmorClasses(IntEnum):
# taken as genie editor value unless otherwise noted
HP = -1 # my own addition
PIERCE = 3
MELEE = 4
class BonusTypes(Enum):
ARMOR = 'armor'
ATTACK = 'attack'
HP = 'hp'

View File

@@ -1 +0,0 @@
*

View File

@@ -0,0 +1,41 @@
Archery Range
Barracks
Blacksmith
Dock
Siege Workshop
Farm
Fortified Gate
Mill
House
Town Center
Palisade Wall
Gate
Watch Tower
Castle
Market
Stable
Trade Workshop
Stone Wall
Fortified Wall
Fish Trap
University
Guard Tower
Keep
Bombard Tower
Wonder
Lumber Camp
Mining Camp
Outpost
Palisade Gate
Feitoria
Fortified Tower
Harbor
Krepost
Donjon
Folwark
Fortified Church
Settlement
Mule Cart
Caravanserai
Pasture
Monastery

View File

@@ -0,0 +1,41 @@
Archery Range
Barracks
Blacksmith
Dock
Siege Workshop
Farm
Fortified Gate
Mill
House
Town Center
Palisade Wall
Gate
Watch Tower
Castle
Market
Stable
Trade Workshop
Stone Wall
Fortified Wall
Fish Trap
University
Guard Tower
Keep
Bombard Tower
Wonder
Lumber Camp
Mining Camp
Outpost
Palisade Gate
Feitoria
Fortified Tower
Harbor
Krepost
Donjon
Folwark
Fortified Church
Settlement
Mule Cart
Caravanserai
Pasture
Monastery

View File

@@ -0,0 +1,71 @@
Elite Arambai
Elite Ballista Elephant
Elite Battle Elephant
Elite Berserk
Elite Blackwood Archer
Elite Bolas Rider
Elite Boyar
Elite Camel Archer
Elite Cannon Galleon
Elite Caravel
Elite Cataphract
Elite Centurion
Elite Chakram Thrower
Elite Champi Warrior
Elite Chu Ko Nu
Elite Composite Bowman
Elite Conquistador
Elite Coustillier
Elite Eagle Warrior
Elite Elephant Archer
Elite Fire Archer
Elite Fire Lancer
Elite Gbeto
Elite Genitour
Elite Genoese Crossbowman
Elite Ghulam
Elite Guecha Warrior
Elite Huskarl
Elite Hussite Wagon
Elite Ibirapema Warrior
Elite Iron Pagoda
Elite Jaguar Warrior
Elite Janissary
Elite Kamayuk
Elite Karambit Warrior
Elite Keshik
Elite Kipchak
Elite Kona
Elite Konnik
Elite Leitis
Elite Liao Dao
Elite Longboat
Elite Longbowman
Elite Magyar Huszar
Elite Mameluke
Elite Mangudai
Elite Monaspa
Elite Obuch
Elite Organ Gun
Elite Plumed Archer
Elite Qizilbash Warrior
Elite Ratha
Elite Rattan Archer
Elite Samurai
Elite Serjeant
Elite Shotel Warrior
Elite Shrivamsha Rider
Elite Skirmisher
Elite Steppe Lancer
Elite Tarkan
Elite Temple Guard
Elite Teutonic Knight
Elite Throwing Axeman
Elite Tiger Cavalry
Elite Turtle Ship
Elite Urumi Swordsman
Elite War Dog
Elite War Elephant
Elite War Wagon
Elite White Feather Guard
Elite Woad Raider

View File

@@ -0,0 +1,307 @@
Elite Tarkan
Yeomen
Holcans
Furor Celtica
Drill
Citadels
Town Watch
Zealotry
Artillery
Crenellations
Crop Rotation
Heavy Plow
Horse Collar
Guilds
Anarchy
Banking
Atheism
Loom
Coinage
Garland Wars
Elite Plumed Archer
Bimaristan
Medium Warships
Heavy Warships
Husbandry
Faith
Devotion
Chemistry
Caravan
Bogsveigar
Masonry
Architecture
Rocketry
Treadmill Crane
Gold Mining
Kataparuto
Elite Conquistador
Logistica
Keep
Bombard Tower
Gillnets
Forging
Iron Casting
Scale Mail Armor
Blast Furnace
Chain Mail Armor
Plate Mail Armor
Plate Barding Armor
Scale Barding Armor
Chain Barding Armor
Bearded Axe
Ballistics
Capped Ram
Elite Skirmisher
Crossbowman
Feudal Age
Castle Age
Imperial Age
Guard Tower
Gold Shaft Mining
Fortified Wall
Pikeman
Fletching
Bodkin Arrow
Bracer
Double-Bit Axe
Bow Saw
Long Swordsman
Cavalier
Padded Archer Armor
Leather Archer Armor
Wheelbarrow
Squires
Two-Handed Swordsman
Heavy Cavalry Archer
Ring Archer Armor
Two-Man Saw
Man-at-Arms
Block Printing
Sanctity
Illumination
Heavy Camel Rider
Arbalester
Heavy Scorpion
Heavy Demolition Ship
Hand Cart
Fervor
Light Cavalry
Siege Ram
Onager
Champion
Paladin
Stone Mining
Stone Shaft Mining
Town Patrol
Conscription
Redemption
Atonement
Siege Onager
Sappers
Murder Holes
Elite Longbowman
Elite Cataphract
Elite Chu Ko Nu
Elite Throwing Axeman
Elite Teutonic Knight
Elite Huskarl
Elite Samurai
Elite War Elephant
Elite Mameluke
Elite Janissary
Elite Woad Raider
Elite Mangudai
Elite Longboat
Shipwright
Careening
Dry Dock
Elite Cannon Galleon
Siege Engineers
Hoardings
Heated Shot
Eagle Warrior
Elite Berserk
Spies/Treason
Hussar
Halberdier
Elite Jaguar Warrior
Elite Eagle Warrior
Bloodlines
Parthian Tactics
Thumb Ring
Theocracy
Heresy
Supremacy
Herbal Medicine
Shinkichon
Elite Turtle Ship
Elite War Wagon
Counterweights
Detinets
Perfusion
Atlatl
Warwolf
Great Wall
Chieftains
Greek Fire
Elite Genoese Crossbowman
Elite Magyar Huszar
Elite Elephant Archer
Stronghold
Marauders
Yasama
Hul'che Javelineers
Eupseong
Nomads
Kamandaran
Ironclad
Madrasah
Sipahi
Inquisition
Chivalry
Pavise
Silk Road
Elite Boyar
Grand Trunk Road
Shatagni
Elite Kamayuk
Orthodoxy
Druzhina
Corvinian Army
Recurve Bow
Andean Sling
Fabric Shields
Imperial Camel Rider
Revetments
Savar
Enable Sheep
Enable Llamas
Enable Cows
Enable Turkeys
Elite Organ Gun
Elite Camel Archer
Elite Gbeto
Elite Shotel Warrior
Carrack
Arquebus
Royal Heirs
Torsion Engines
Tigui
Farimba
Kasbah
Maghrebi Camels
Elite Caravel
Elite Genitour
Arson
Arrowslits
Elite Ballista Elephant
Elite Karambit Warrior
Elite Arambai
Elite Rattan Archer
Tusk Swords
Double Crossbow
Thalassocracy
Forced Levy
Howdah
Manipur Cavalry
Chatras
Paper Money
Elite Battle Elephant
Imperial Skirmisher
Elite Konnik
Elite Keshik
Elite Kipchak
Elite Leitis
Stirrups
Bagains
Silk Armor
Timurid Siegecraft
Steppe Husbandry
Cuman Mercenaries
Hill Forts
Tower Shields
Elite Steppe Lancer
Supplies
Elite Coustillier
Elite Serjeant
Burgundian Vineyards
Flemish Revolution
First Crusade
Hauberk
Elite Obuch
Elite Hussite Wagon
Szlachta Privileges
Lechitic Legacy
Wagenburg Tactics
Hussite Reforms
Winged Hussar
Houfnice
Elite Urumi Swordsman
Elite Ratha
Elite Chakram Thrower
Medical Corps
Wootz Steel
Paiks
Mahayana
Kshatriyas
Frontier Guards
Siege Elephant
Elite Ghulam
Elite Shrivamsha Rider
Gambesons
Elite Centurion
Ballistas
Comitatenses
Legionary
Pirotechnia
Demolition Ship
Fishing Lines
Carvel Hull
Clinker Construction
Siphons
Incendiaries
Elite Composite Bowman
Elite Monaspa
Fereters
Cilician Fleet
Svan Towers
Aznauri Cavalry
Elite Qizilbash Warrior
Heavy Rocket Cart
Elite Fire Lancer
Elite Iron Pagoda
Fortified Bastions
Thunderclap Bombs
Elite Liao Dao
Lamellar Armor
Ordo Cavalry
Transhumance
Pastoralism
Domestication
Heavy Hei Guang Cavalry
Elite Tiger Cavalry
Tuntian
Ming Guang Armor
Elite White Feather Guard
Bolt Magazine
Coiled Serpent Array
Elite Fire Archer
Red Cliffs Tactics
Sitting Tiger
Champi Warrior
Elite Champi Warrior
Elite Guecha Warrior
Herbalism
Huaracas
Elite Kona
Elite Bolas Rider
Malon
Butalmapu
Elite War Dog
Elite Blackwood Archer
Elite Ibirapema Warrior
Caciques
Curare
Elite Temple Guard
Champi Runner
Circumnavigation

View File

@@ -0,0 +1,83 @@
Town Watch
Crop Rotation
Heavy Plow
Horse Collar
Guilds
Banking
Loom
Coinage
Medium Warships
Heavy Warships
Husbandry
Faith
Devotion
Chemistry
Caravan
Masonry
Architecture
Treadmill Crane
Gold Mining
Keep
Bombard Tower
Gillnets
Forging
Iron Casting
Scale Mail Armor
Blast Furnace
Chain Mail Armor
Plate Mail Armor
Plate Barding Armor
Scale Barding Armor
Chain Barding Armor
Ballistics
Feudal Age
Castle Age
Imperial Age
Guard Tower
Gold Shaft Mining
Fortified Wall
Fletching
Bodkin Arrow
Bracer
Double-Bit Axe
Bow Saw
Padded Archer Armor
Leather Archer Armor
Wheelbarrow
Squires
Ring Archer Armor
Two-Man Saw
Block Printing
Sanctity
Illumination
Hand Cart
Fervor
Stone Mining
Stone Shaft Mining
Town Patrol
Conscription
Redemption
Atonement
Sappers
Murder Holes
Shipwright
Careening
Dry Dock
Siege Engineers
Hoardings
Heated Shot
Spies/Treason
Bloodlines
Parthian Tactics
Thumb Ring
Theocracy
Heresy
Herbal Medicine
Arson
Arrowslits
Gambesons
Fishing Lines
Carvel Hull
Clinker Construction
Siphons
Incendiaries

View File

@@ -0,0 +1,108 @@
Yeomen
Holcans
Furor Celtica
Drill
Citadels
Artillery
Crenellations
Anarchy
Atheism
Garland Wars
Bimaristan
Bogsveigar
Rocketry
Kataparuto
Logistica
Supremacy
Shinkichon
Counterweights
Detinets
Perfusion
Atlatl
Warwolf
Great Wall
Chieftains
Greek Fire
Stronghold
Marauders
Yasama
Hul'che Javelineers
Eupseong
Nomads
Kamandaran
Ironclad
Sipahi
Inquisition
Chivalry
Silk Road
Grand Trunk Road
Shatagni
Druzhina
Corvinian Army
Recurve Bow
Andean Sling
Fabric Shields
Arquebus
Royal Heirs
Torsion Engines
Tigui
Farimba
Kasbah
Maghrebi Camels
Tusk Swords
Double Crossbow
Thalassocracy
Forced Levy
Howdah
Manipur Cavalry
Chatras
Paper Money
Stirrups
Bagains
Silk Armor
Timurid Siegecraft
Steppe Husbandry
Cuman Mercenaries
Hill Forts
Tower Shields
Burgundian Vineyards
Flemish Revolution
First Crusade
Hauberk
Szlachta Privileges
Lechitic Legacy
Wagenburg Tactics
Hussite Reforms
Medical Corps
Wootz Steel
Paiks
Mahayana
Kshatriyas
Frontier Guards
Ballistas
Comitatenses
Pirotechnia
Fereters
Cilician Fleet
Svan Towers
Aznauri Cavalry
Fortified Bastions
Thunderclap Bombs
Lamellar Armor
Ordo Cavalry
Transhumance
Pastoralism
Domestication
Tuntian
Ming Guang Armor
Bolt Magazine
Coiled Serpent Array
Red Cliffs Tactics
Sitting Tiger
Herbalism
Huaracas
Malon
Butalmapu
Caciques
Curare
Circumnavigation

View File

@@ -0,0 +1,225 @@
Archer
Hand Cannoneer
Elite Skirmisher
Skirmisher
Longbowman
Mangudai
Fishing Ship
Trade Cog
War Galley
Crossbowman
Teutonic Knight
Battering Ram
Bombard Cannon
Knight
Cavalry Archer
Cataphract
Huskarl
Trebuchet
Janissary
Chu Ko Nu
Militia
Man-at-Arms
Long Swordsman
Spearman
Monk
Condottiero
Slinger
Imperial Camel Rider
Woad Raider
War Elephant
Longboat
Scorpion
Mangonel
Throwing Axeman
Mameluke
Cavalier
Samurai
Camel Rider
Heavy Camel Rider
Trebuchet (Packed)
Pikeman
Halberdier
Cannon Galleon
Capped Ram
Petard
Hussar
Galleon
Scout Cavalry
Two-Handed Swordsman
Heavy Cavalry Archer
Arbalester
Demolition Ship
Heavy Demolition Ship
Fire Ship
Elite Longbowman
Elite Throwing Axeman
Fast Fire Ship
Elite Longboat
Elite Woad Raider
Galley
Heavy Scorpion
Transport Ship
Light Cavalry
Siege Ram
Onager
Elite Cataphract
Elite Teutonic Knight
Elite Huskarl
Elite Mameluke
Elite Janissary
Elite War Elephant
Elite Chu Ko Nu
Elite Samurai
Elite Mangudai
Champion
Paladin
Genitour
Siege Onager
Elite Genitour
Elite Cannon Galleon
Berserk
Elite Berserk
Jaguar Warrior
Elite Jaguar Warrior
Eagle Scout
Elite Eagle Warrior
Eagle Warrior
Tarkan
Elite Tarkan
Plumed Archer
Elite Plumed Archer
Conquistador
Elite Conquistador
Missionary
War Wagon
Elite War Wagon
Turtle Ship
Elite Turtle Ship
Genoese Crossbowman
Elite Genoese Crossbowman
Magyar Huszar
Elite Magyar Huszar
Elephant Archer
Elite Elephant Archer
Boyar
Elite Boyar
Kamayuk
Elite Kamayuk
Siege Tower
Dragon Ship
Organ Gun
Elite Organ Gun
Caravel
Elite Caravel
Camel Archer
Elite Camel Archer
Gbeto
Elite Gbeto
Shotel Warrior
Elite Shotel Warrior
Fire Galley
Demolition Raft
Ballista Elephant
Elite Ballista Elephant
Karambit Warrior
Elite Karambit Warrior
Arambai
Elite Arambai
Rattan Archer
Elite Rattan Archer
Battle Elephant
Elite Battle Elephant
Imperial Skirmisher
Konnik
Elite Konnik
Keshik
Elite Keshik
Kipchak
Elite Kipchak
Leitis
Elite Leitis
Flaming Camel
Steppe Lancer
Elite Steppe Lancer
Xolotl Warrior
Coustillier
Elite Coustillier
Serjeant
Elite Serjeant
Flemish Militia
Obuch
Elite Obuch
Hussite Wagon
Elite Hussite Wagon
Winged Hussar
Houfnice
Urumi Swordsman
Elite Urumi Swordsman
Ratha (Melee)
Elite Ratha (Melee)
Chakram Thrower
Elite Chakram Thrower
Armored Elephant
Siege Elephant
Ghulam
Elite Ghulam
Thirisadai
Shrivamsha Rider
Elite Shrivamsha Rider
Camel Scout
Ratha (Ranged)
Elite Ratha (Ranged)
Centurion
Elite Centurion
Legionary
Dromon
Composite Bowman
Elite Composite Bowman
Monaspa
Elite Monaspa
Warrior Priest
Savar
Fire Lancer
Elite Fire Lancer
Rocket Cart
Heavy Rocket Cart
Iron Pagoda
Elite Iron Pagoda
Grenadier
Liao Dao
Elite Liao Dao
Mounted Trebuchet
Traction Trebuchet
Hei Guang Cavalry
Heavy Hei Guang Cavalry
Lou Chuan
Tiger Cavalry
Elite Tiger Cavalry
Xianbei Raider
White Feather Guard
Elite White Feather Guard
Fire Archer
Elite Fire Archer
Jian Swordsman
Sun Jian
Champi Scout
Champi Warrior
Elite Champi Warrior
Guecha Warrior
Elite Guecha Warrior
Kona
Elite Kona
Bolas Rider
Elite Bolas Rider
Blackwood Archer
Elite Blackwood Archer
Ibirapema Warrior
Elite Ibirapema Warrior
Temple Guard
Elite Temple Guard
Champi Runner
Hulk
War Hulk
Carrack
Catapult Galleon

View File

@@ -0,0 +1,226 @@
Archer
Hand Cannoneer
Elite Skirmisher
Skirmisher
Longbowman
Mangudai
Fishing Ship
Trade Cog
War Galley
Crossbowman
Teutonic Knight
Battering Ram
Bombard Cannon
Knight
Cavalry Archer
Cataphract
Huskarl
Trebuchet
Janissary
Chu Ko Nu
Militia
Man-at-Arms
Long Swordsman
Spearman
Monk
Condottiero
Slinger
Imperial Camel Rider
Woad Raider
War Elephant
Longboat
Scorpion
Mangonel
Throwing Axeman
Mameluke
Cavalier
Samurai
Camel Rider
Heavy Camel Rider
Trebuchet (Packed)
Pikeman
Halberdier
Cannon Galleon
Capped Ram
Petard
Hussar
Galleon
Scout Cavalry
Two-Handed Swordsman
Heavy Cavalry Archer
Arbalester
Demolition Ship
Heavy Demolition Ship
Fire Ship
Elite Longbowman
Elite Throwing Axeman
Fast Fire Ship
Elite Longboat
Elite Woad Raider
Galley
Heavy Scorpion
Transport Ship
Light Cavalry
Siege Ram
Onager
Elite Cataphract
Elite Teutonic Knight
Elite Huskarl
Elite Mameluke
Elite Janissary
Elite War Elephant
Elite Chu Ko Nu
Elite Samurai
Elite Mangudai
Champion
Paladin
Genitour
Siege Onager
Elite Genitour
Elite Cannon Galleon
Berserk
Elite Berserk
Jaguar Warrior
Elite Jaguar Warrior
Eagle Scout
Elite Eagle Warrior
Eagle Warrior
Tarkan
Elite Tarkan
Plumed Archer
Elite Plumed Archer
Conquistador
Elite Conquistador
Missionary
War Wagon
Elite War Wagon
Turtle Ship
Elite Turtle Ship
Genoese Crossbowman
Elite Genoese Crossbowman
Magyar Huszar
Elite Magyar Huszar
Elephant Archer
Elite Elephant Archer
Boyar
Elite Boyar
Kamayuk
Elite Kamayuk
Siege Tower
Jarl
Dragon Ship
Organ Gun
Elite Organ Gun
Caravel
Elite Caravel
Camel Archer
Elite Camel Archer
Gbeto
Elite Gbeto
Shotel Warrior
Elite Shotel Warrior
Fire Galley
Demolition Raft
Ballista Elephant
Elite Ballista Elephant
Karambit Warrior
Elite Karambit Warrior
Arambai
Elite Arambai
Rattan Archer
Elite Rattan Archer
Battle Elephant
Elite Battle Elephant
Imperial Skirmisher
Konnik
Elite Konnik
Keshik
Elite Keshik
Kipchak
Elite Kipchak
Leitis
Elite Leitis
Flaming Camel
Steppe Lancer
Elite Steppe Lancer
Xolotl Warrior
Coustillier
Elite Coustillier
Serjeant
Elite Serjeant
Flemish Militia
Obuch
Elite Obuch
Hussite Wagon
Elite Hussite Wagon
Winged Hussar
Houfnice
Urumi Swordsman
Elite Urumi Swordsman
Ratha (Melee)
Elite Ratha (Melee)
Chakram Thrower
Elite Chakram Thrower
Armored Elephant
Siege Elephant
Ghulam
Elite Ghulam
Thirisadai
Shrivamsha Rider
Elite Shrivamsha Rider
Camel Scout
Ratha (Ranged)
Elite Ratha (Ranged)
Centurion
Elite Centurion
Legionary
Dromon
Composite Bowman
Elite Composite Bowman
Monaspa
Elite Monaspa
Warrior Priest
Savar
Fire Lancer
Elite Fire Lancer
Rocket Cart
Heavy Rocket Cart
Iron Pagoda
Elite Iron Pagoda
Grenadier
Liao Dao
Elite Liao Dao
Mounted Trebuchet
Traction Trebuchet
Hei Guang Cavalry
Heavy Hei Guang Cavalry
Lou Chuan
Tiger Cavalry
Elite Tiger Cavalry
Xianbei Raider
White Feather Guard
Elite White Feather Guard
Fire Archer
Elite Fire Archer
Jian Swordsman
Sun Jian
Champi Scout
Champi Warrior
Elite Champi Warrior
Guecha Warrior
Elite Guecha Warrior
Kona
Elite Kona
Bolas Rider
Elite Bolas Rider
Blackwood Archer
Elite Blackwood Archer
Ibirapema Warrior
Elite Ibirapema Warrior
Temple Guard
Elite Temple Guard
Champi Runner
Hulk
War Hulk
Carrack
Catapult Galleon

View File

@@ -0,0 +1,70 @@
Archer
Hand Cannoneer
Elite Skirmisher
Skirmisher
Fishing Ship
Trade Cog
War Galley
Crossbowman
Battering Ram
Bombard Cannon
Knight
Cavalry Archer
Trebuchet
Militia
Man-at-Arms
Long Swordsman
Spearman
Monk
Slinger
Scorpion
Mangonel
Cavalier
Camel Rider
Heavy Camel Rider
Trebuchet (Packed)
Pikeman
Halberdier
Capped Ram
Petard
Hussar
Galleon
Scout Cavalry
Two-Handed Swordsman
Heavy Cavalry Archer
Arbalester
Demolition Ship
Heavy Demolition Ship
Fire Ship
Fast Fire Ship
Galley
Heavy Scorpion
Transport Ship
Light Cavalry
Siege Ram
Onager
Champion
Paladin
Siege Onager
Eagle Scout
Siege Tower
Fire Galley
Demolition Raft
Xolotl Warrior
Winged Hussar
Armored Elephant
Siege Elephant
Camel Scout
Dromon
Rocket Cart
Heavy Rocket Cart
Traction Trebuchet
Hei Guang Cavalry
Heavy Hei Guang Cavalry
Lou Chuan
Champi Scout
Champi Runner
Hulk
War Hulk
Carrack
Catapult Galleon

View File

@@ -0,0 +1,3 @@
Spearman
Onager
Bombard Cannon

View File

@@ -0,0 +1,152 @@
Condottiero
Imperial Camel Rider
Missionary
Dragon Ship
Imperial Skirmisher
Houfnice
Thirisadai
Legionary
Warrior Priest
Savar
Grenadier
Mounted Trebuchet
Xianbei Raider
Jian Swordsman
Longbowman
Throwing Axeman
Longboat
Woad Raider
Cataphract
Teutonic Knight
Huskarl
Mameluke
Janissary
War Elephant
Chu Ko Nu
Samurai
Mangudai
Genitour
Cannon Galleon
Berserk
Jaguar Warrior
Eagle Warrior
Tarkan
Plumed Archer
Conquistador
War Wagon
Turtle Ship
Genoese Crossbowman
Magyar Huszar
Elephant Archer
Boyar
Kamayuk
Organ Gun
Caravel
Camel Archer
Gbeto
Shotel Warrior
Ballista Elephant
Karambit Warrior
Arambai
Rattan Archer
Battle Elephant
Konnik
Keshik
Kipchak
Leitis
Steppe Lancer
Coustillier
Serjeant
Obuch
Hussite Wagon
Urumi Swordsman
Ratha (Melee)
Chakram Thrower
Ghulam
Shrivamsha Rider
Ratha (Ranged)
Centurion
Composite Bowman
Monaspa
Fire Lancer
Iron Pagoda
Liao Dao
Tiger Cavalry
White Feather Guard
Fire Archer
Champi Warrior
Guecha Warrior
Kona
Bolas Rider
Blackwood Archer
Ibirapema Warrior
Temple Guard
Elite Longbowman
Elite Throwing Axeman
Elite Longboat
Elite Woad Raider
Elite Cataphract
Elite Teutonic Knight
Elite Huskarl
Elite Mameluke
Elite Janissary
Elite War Elephant
Elite Chu Ko Nu
Elite Samurai
Elite Mangudai
Elite Genitour
Elite Cannon Galleon
Elite Berserk
Elite Jaguar Warrior
Elite Eagle Warrior
Elite Tarkan
Elite Plumed Archer
Elite Conquistador
Elite War Wagon
Elite Turtle Ship
Elite Genoese Crossbowman
Elite Magyar Huszar
Elite Elephant Archer
Elite Boyar
Elite Kamayuk
Elite Organ Gun
Elite Caravel
Elite Camel Archer
Elite Gbeto
Elite Shotel Warrior
Elite Ballista Elephant
Elite Karambit Warrior
Elite Arambai
Elite Rattan Archer
Elite Battle Elephant
Elite Konnik
Elite Keshik
Elite Kipchak
Elite Leitis
Elite Steppe Lancer
Elite Coustillier
Elite Serjeant
Elite Obuch
Elite Hussite Wagon
Elite Urumi Swordsman
Elite Ratha (Melee)
Elite Chakram Thrower
Elite Ghulam
Elite Shrivamsha Rider
Elite Ratha (Ranged)
Elite Centurion
Elite Composite Bowman
Elite Monaspa
Elite Fire Lancer
Elite Iron Pagoda
Elite Liao Dao
Elite Tiger Cavalry
Elite White Feather Guard
Elite Fire Archer
Elite Champi Warrior
Elite Guecha Warrior
Elite Kona
Elite Bolas Rider
Elite Blackwood Archer
Elite Ibirapema Warrior
Elite Temple Guard

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')