From f560586900dbb7fd10098c9108180b8f6c2d6ee0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 28 Apr 2019 18:59:31 +1000 Subject: [PATCH] plan: plan for one of every component --- plan.py | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/plan.py b/plan.py index ca5fc56..7e714c1 100755 --- a/plan.py +++ b/plan.py @@ -6,29 +6,15 @@ import collections import satisfactory -if __name__ == '__main__': - recipes = satisfactory.Cookbook('data/recipes') - +def calculate_rates(recipes, remain): required_items = collections.defaultdict(fractions.Fraction) - remain = [] - - target_name = 'supercomputer' - target = recipes[target_name] - target_recipe = target['recipes'][0] - - remain.append({ - target_name: fractions.Fraction( - target_recipe['output'][target_name], - target_recipe['crafting_time'] - ) - }) while remain: for dst_name, dst_rate in remain.pop().items(): required_items[dst_name] += dst_rate dst = recipes[dst_name] - if recipes.is_resource(dst_name): + if not recipes.is_component(dst_name): continue dst_recipe = recipes[dst_name]['recipes'][0] @@ -48,6 +34,31 @@ if __name__ == '__main__': ) * scale remain.append({src_name: src_rate}) + 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) + for name, rate in required_items.items(): print(name, rate, float(rate * 60)) if rate * 60 > 450: