From 2f8fb25fe87f997ac7cd4135db5fe07fc0005471 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 14 Jul 2019 11:35:22 +1000 Subject: [PATCH] plan: document the basic algorithm --- plan.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plan.py b/plan.py index ed696f9..0bfdadf 100755 --- a/plan.py +++ b/plan.py @@ -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(): recipes = satisfactory.Cookbook('data/recipes') required_items = collections.defaultdict(fractions.Fraction) + # Create a list of items we want to make #targets = [ 'supercomputer' ] targets = recipes.components() - target_name = 'supercomputer' - target = recipes[target_name] - target_recipe = target['recipes'][0] - + # Create an initial name:rate request for all of the target items, then + # create a plan for their creation. remain = [{n: basic_rate(recipes[n]['recipes'][0]) for n in targets}] 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(): print(name, rate, float(rate * 60)) 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(): return collections.defaultdict(int) required_machines = collections.defaultdict(numberdict) @@ -90,6 +97,7 @@ def main(): machine = descriptor['machine'] required_machines[machine][name] += requested_rate / normal_rate + # Calculate the power requirements for all the machines required_power = 0 for machine, buckets in required_machines.items():