plan: add machine count calculation

This commit is contained in:
Danny Robson 2019-04-28 18:02:57 +10:00
parent b0ec4a8a63
commit 970faf4c8b

44
plan.py
View File

@ -1,14 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import satisfactory import math
import fractions import fractions
import collections import collections
import satisfactory
if __name__ == '__main__': if __name__ == '__main__':
recipes = satisfactory.Cookbook('data/recipes') recipes = satisfactory.Cookbook('data/recipes')
required = collections.defaultdict(fractions.Fraction) required_items = collections.defaultdict(fractions.Fraction)
remain = [] remain = []
target_name = 'supercomputer' target_name = 'supercomputer'
@ -24,7 +25,7 @@ if __name__ == '__main__':
while remain: while remain:
for dst_name, dst_rate in remain.pop().items(): for dst_name, dst_rate in remain.pop().items():
required[dst_name] += dst_rate required_items[dst_name] += dst_rate
dst = recipes[dst_name] dst = recipes[dst_name]
if recipes.is_resource(dst_name): if recipes.is_resource(dst_name):
@ -47,7 +48,36 @@ if __name__ == '__main__':
) * scale ) * scale
remain.append({src_name: src_rate}) remain.append({src_name: src_rate})
print(required) for name, rate in required_items.items():
print(name, rate, float(rate * 60))
if rate * 60 > 450:
print("Rate exceeds mk4 conveyer")
for name, rate in required.items(): def numberdict():
machine = recipes[name]['machine'] 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))
print(required_power)
print(math.ceil(required_power / 150), "fuel generators")