From 970faf4c8b9665d42280b9953da3e97d3343a07b Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 28 Apr 2019 18:02:57 +1000 Subject: [PATCH] plan: add machine count calculation --- plan.py | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/plan.py b/plan.py index 0ca8ae1..ca5fc56 100755 --- a/plan.py +++ b/plan.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 -import satisfactory - +import math import fractions import collections +import satisfactory + if __name__ == '__main__': recipes = satisfactory.Cookbook('data/recipes') - required = collections.defaultdict(fractions.Fraction) + required_items = collections.defaultdict(fractions.Fraction) remain = [] target_name = 'supercomputer' @@ -24,7 +25,7 @@ if __name__ == '__main__': while remain: for dst_name, dst_rate in remain.pop().items(): - required[dst_name] += dst_rate + required_items[dst_name] += dst_rate dst = recipes[dst_name] if recipes.is_resource(dst_name): @@ -47,7 +48,36 @@ if __name__ == '__main__': ) * scale 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(): - machine = recipes[name]['machine'] + 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)) + + print(required_power) + print(math.ceil(required_power / 150), "fuel generators")