2019-04-28 17:23:21 +10:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2019-04-28 18:02:57 +10:00
|
|
|
import math
|
2019-04-28 17:23:21 +10:00
|
|
|
import fractions
|
|
|
|
import collections
|
|
|
|
|
2019-04-28 18:02:57 +10:00
|
|
|
import satisfactory
|
|
|
|
|
2019-04-28 18:59:31 +10:00
|
|
|
def calculate_rates(recipes, remain):
|
2019-04-28 18:02:57 +10:00
|
|
|
required_items = collections.defaultdict(fractions.Fraction)
|
2019-04-28 17:23:21 +10:00
|
|
|
|
|
|
|
while remain:
|
|
|
|
for dst_name, dst_rate in remain.pop().items():
|
2019-04-28 18:02:57 +10:00
|
|
|
required_items[dst_name] += dst_rate
|
2019-04-28 17:23:21 +10:00
|
|
|
|
|
|
|
dst = recipes[dst_name]
|
2019-04-28 18:59:31 +10:00
|
|
|
if not recipes.is_component(dst_name):
|
2019-04-28 17:23:21 +10:00
|
|
|
continue
|
|
|
|
|
|
|
|
dst_recipe = recipes[dst_name]['recipes'][0]
|
|
|
|
src_recipe = recipes[dst_name]['recipes'][0]
|
|
|
|
|
|
|
|
normal_rate = fractions.Fraction(
|
|
|
|
dst_recipe['output'][dst_name],
|
|
|
|
dst_recipe['crafting_time']
|
|
|
|
)
|
|
|
|
|
|
|
|
scale = dst_rate / normal_rate
|
|
|
|
|
|
|
|
for src_name, src_count in src_recipe['input'].items():
|
|
|
|
src_rate = fractions.Fraction(
|
|
|
|
src_count,
|
|
|
|
dst_recipe['crafting_time']
|
|
|
|
) * scale
|
|
|
|
remain.append({src_name: src_rate})
|
|
|
|
|
2019-04-28 18:59:31 +10:00
|
|
|
return required_items
|
|
|
|
|
|
|
|
|
|
|
|
def basic_rate(recipes, name: str):
|
|
|
|
return fractions.Fraction(
|
|
|
|
target_recipe['output'][target_name],
|
|
|
|
target_recipe['crafting_time']
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
recipes = satisfactory.Cookbook('data/recipes')
|
|
|
|
|
|
|
|
required_items = collections.defaultdict(fractions.Fraction)
|
|
|
|
|
|
|
|
#targets = [ 'supercomputer' ]
|
|
|
|
targets = recipes.components()
|
|
|
|
|
|
|
|
target_name = 'supercomputer'
|
|
|
|
target = recipes[target_name]
|
|
|
|
target_recipe = target['recipes'][0]
|
|
|
|
|
|
|
|
remain = [{n: basic_rate(recipes, n) for n in targets}]
|
|
|
|
required_items = calculate_rates(recipes, remain)
|
|
|
|
|
2019-04-28 18:02:57 +10:00
|
|
|
for name, rate in required_items.items():
|
|
|
|
print(name, rate, float(rate * 60))
|
|
|
|
if rate * 60 > 450:
|
|
|
|
print("Rate exceeds mk4 conveyer")
|
|
|
|
|
|
|
|
def numberdict():
|
|
|
|
return collections.defaultdict(int)
|
|
|
|
required_machines = collections.defaultdict(numberdict)
|
|
|
|
|
|
|
|
for name, requested_rate in required_items.items():
|
|
|
|
if recipes.is_resource(name):
|
|
|
|
continue
|
|
|
|
|
|
|
|
descriptor = recipes[name]
|
|
|
|
|
|
|
|
normal_rate = fractions.Fraction(
|
|
|
|
descriptor['recipes'][0]['output'][name],
|
|
|
|
descriptor['recipes'][0]['crafting_time']
|
|
|
|
)
|
|
|
|
|
|
|
|
machine = descriptor['machine']
|
|
|
|
required_machines[machine][name] += requested_rate / normal_rate
|
|
|
|
|
|
|
|
required_power = 0
|
|
|
|
|
|
|
|
for machine, buckets in required_machines.items():
|
|
|
|
for result, rate in buckets.items():
|
|
|
|
count = int(math.ceil(rate))
|
|
|
|
required_power += count * recipes[machine]['power_usage']
|
|
|
|
print(machine, result, math.ceil(rate))
|
2019-04-28 17:23:21 +10:00
|
|
|
|
2019-04-28 18:02:57 +10:00
|
|
|
print(required_power)
|
|
|
|
print(math.ceil(required_power / 150), "fuel generators")
|