mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Factorio: exclude science packs and rocket-part from free samples
This commit is contained in:
@@ -99,6 +99,7 @@ class Machine(FactorioElement):
|
||||
self.name: str = name
|
||||
self.categories: set = categories
|
||||
|
||||
|
||||
# recipes and technologies can share names in Factorio
|
||||
for technology_name in sorted(raw):
|
||||
data = raw[technology_name]
|
||||
@@ -125,7 +126,8 @@ for recipe_name, recipe_data in raw_recipes.items():
|
||||
|
||||
recipe = Recipe(recipe_name, recipe_data["category"], set(recipe_data["ingredients"]), set(recipe_data["products"]))
|
||||
recipes[recipe_name] = Recipe
|
||||
if recipe.products.isdisjoint(recipe.ingredients) and "empty-barrel" not in recipe.products: # prevents loop recipes like uranium centrifuging
|
||||
if recipe.products.isdisjoint(
|
||||
recipe.ingredients) and "empty-barrel" not in recipe.products: # prevents loop recipes like uranium centrifuging
|
||||
for product_name in recipe.products:
|
||||
all_product_sources.setdefault(product_name, set()).add(recipe)
|
||||
|
||||
@@ -153,6 +155,7 @@ def unlock_just_tech(recipe: Recipe, _done) -> Set[Technology]:
|
||||
current_technologies |= recursively_get_unlocking_technologies(ingredient_name, _done)
|
||||
return current_technologies
|
||||
|
||||
|
||||
def unlock(recipe: Recipe, _done) -> Set[Technology]:
|
||||
current_technologies = set()
|
||||
current_technologies |= recipe.unlocking_technologies
|
||||
@@ -162,7 +165,9 @@ def unlock(recipe: Recipe, _done) -> Set[Technology]:
|
||||
|
||||
return current_technologies
|
||||
|
||||
def recursively_get_unlocking_technologies(ingredient_name, _done=None, unlock_func=unlock_just_tech) -> Set[Technology]:
|
||||
|
||||
def recursively_get_unlocking_technologies(ingredient_name, _done=None, unlock_func=unlock_just_tech) -> Set[
|
||||
Technology]:
|
||||
if _done:
|
||||
if ingredient_name in _done:
|
||||
return set()
|
||||
@@ -180,7 +185,6 @@ def recursively_get_unlocking_technologies(ingredient_name, _done=None, unlock_f
|
||||
return current_technologies
|
||||
|
||||
|
||||
|
||||
required_machine_technologies: Dict[str, FrozenSet[Technology]] = {}
|
||||
for ingredient_name in machines:
|
||||
required_machine_technologies[ingredient_name] = frozenset(recursively_get_unlocking_technologies(ingredient_name))
|
||||
@@ -192,14 +196,14 @@ for machine in machines.values():
|
||||
if machine != pot_source_machine \
|
||||
and machine.categories.issuperset(pot_source_machine.categories) \
|
||||
and required_machine_technologies[machine.name].issuperset(
|
||||
required_machine_technologies[pot_source_machine.name]):
|
||||
required_machine_technologies[pot_source_machine.name]):
|
||||
logically_useful = False
|
||||
break
|
||||
|
||||
if logically_useful:
|
||||
logical_machines[machine.name] = machine
|
||||
|
||||
del(required_machine_technologies)
|
||||
del (required_machine_technologies)
|
||||
|
||||
machines_per_category: Dict[str: Set[Machine]] = {}
|
||||
for machine in logical_machines.values():
|
||||
@@ -219,11 +223,11 @@ for ingredient_name in all_ingredient_names:
|
||||
required_technologies[ingredient_name] = frozenset(
|
||||
recursively_get_unlocking_technologies(ingredient_name, unlock_func=unlock))
|
||||
|
||||
|
||||
advancement_technologies: Set[str] = set()
|
||||
for technologies in required_technologies.values():
|
||||
advancement_technologies |= {technology.name for technology in technologies}
|
||||
|
||||
|
||||
@functools.lru_cache(10)
|
||||
def get_rocket_requirements(ingredients: Set[str]) -> Set[str]:
|
||||
techs = recursively_get_unlocking_technologies("rocket-silo")
|
||||
@@ -232,6 +236,8 @@ def get_rocket_requirements(ingredients: Set[str]) -> Set[str]:
|
||||
return {tech.name for tech in techs}
|
||||
|
||||
|
||||
free_sample_blacklist = all_ingredient_names | {"rocket-part"}
|
||||
|
||||
rocket_recipes = {
|
||||
Options.MaxSciencePack.option_space_science_pack:
|
||||
{"rocket-control-unit": 10, "low-density-structure": 10, "rocket-fuel": 10},
|
||||
@@ -247,4 +253,4 @@ rocket_recipes = {
|
||||
{"electronic-circuit": 10, "stone-brick": 10, "coal": 10},
|
||||
Options.MaxSciencePack.option_automation_science_pack:
|
||||
{"copper-cable": 10, "iron-plate": 10, "wood": 10}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user