plan: document the basic algorithm

This commit is contained in:
Danny Robson 2019-07-14 11:35:22 +10:00
parent 0f0e281db8
commit 2f8fb25fe8

18
plan.py
View File

@ -52,26 +52,33 @@ def basic_rate(recipe: Dict) -> fractions.Fraction:
) )
# The number of items per minute that each tier of conveyor can carry
conveyor_rates = [0, 60, 120, 270, 480, 780, 900]
def main(): def main():
recipes = satisfactory.Cookbook('data/recipes') recipes = satisfactory.Cookbook('data/recipes')
required_items = collections.defaultdict(fractions.Fraction) required_items = collections.defaultdict(fractions.Fraction)
# Create a list of items we want to make
#targets = [ 'supercomputer' ] #targets = [ 'supercomputer' ]
targets = recipes.components() targets = recipes.components()
target_name = 'supercomputer' # Create an initial name:rate request for all of the target items, then
target = recipes[target_name] # create a plan for their creation.
target_recipe = target['recipes'][0]
remain = [{n: basic_rate(recipes[n]['recipes'][0]) for n in targets}] remain = [{n: basic_rate(recipes[n]['recipes'][0]) for n in targets}]
required_items = calculate_rates(recipes, remain) required_items = calculate_rates(recipes, remain)
# Note if any particular item is (in aggregate) going to exceed the
# highest conveyor belt capacity.
for name, rate in required_items.items(): for name, rate in required_items.items():
print(name, rate, float(rate * 60)) print(name, rate, float(rate * 60))
if rate * 60 > 780: if rate * 60 > 780:
print("Rate exceeds mk4 conveyer") print("Rate exceeds mk5 conveyor")
# Calculate the number of machines required to build each item at the
# calculated rates.
def numberdict(): def numberdict():
return collections.defaultdict(int) return collections.defaultdict(int)
required_machines = collections.defaultdict(numberdict) required_machines = collections.defaultdict(numberdict)
@ -90,6 +97,7 @@ def main():
machine = descriptor['machine'] machine = descriptor['machine']
required_machines[machine][name] += requested_rate / normal_rate required_machines[machine][name] += requested_rate / normal_rate
# Calculate the power requirements for all the machines
required_power = 0 required_power = 0
for machine, buckets in required_machines.items(): for machine, buckets in required_machines.items():