plan: document the basic algorithm
This commit is contained in:
parent
0f0e281db8
commit
2f8fb25fe8
18
plan.py
18
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():
|
||||
|
Loading…
Reference in New Issue
Block a user