Factorio: cleanup and optimize some requirement graph functions

This commit is contained in:
Fabian Dill
2021-11-26 02:37:15 +01:00
parent 383d0f1a66
commit 8af5855af6
2 changed files with 23 additions and 21 deletions

View File

@@ -131,6 +131,7 @@ class Recipe(FactorioElement):
base = {technology_table[tech_name] for tech_name in recipe_sources.get(self.name, ())}
for ingredient in self.ingredients:
base |= required_technologies[ingredient]
base |= required_technologies[self.crafting_machine]
return base
@property
@@ -472,7 +473,7 @@ def get_science_pack_pools() -> Dict[str, Set[str]]:
cost += rel_cost.get(ingredient_name, 1) * amount
return cost
science_pack_pools = {}
science_pack_pools: Dict[str, Set[str]] = {}
already_taken = blacklist.copy()
current_difficulty = 5
for science_pack in Options.MaxSciencePack.get_ordered_science_packs():
@@ -483,7 +484,8 @@ def get_science_pack_pools() -> Dict[str, Set[str]]:
current |= set(recipe.products)
if science_pack == "automation-science-pack":
current |= {"iron-ore", "copper-ore", "coal", "stone"}
current -= liquids # Can't hand craft automation science if liquids end up in its recipe, making the seed impossible.
# Can't hand craft automation science if liquids end up in its recipe, making the seed impossible.
current -= liquids
elif science_pack == "logistic-science-pack":
current |= {"steam"}
current -= already_taken