plan: plan for one of every component
This commit is contained in:
parent
988e66720a
commit
f560586900
43
plan.py
43
plan.py
@ -6,29 +6,15 @@ import collections
|
|||||||
|
|
||||||
import satisfactory
|
import satisfactory
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def calculate_rates(recipes, remain):
|
||||||
recipes = satisfactory.Cookbook('data/recipes')
|
|
||||||
|
|
||||||
required_items = collections.defaultdict(fractions.Fraction)
|
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:
|
while remain:
|
||||||
for dst_name, dst_rate in remain.pop().items():
|
for dst_name, dst_rate in remain.pop().items():
|
||||||
required_items[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 not recipes.is_component(dst_name):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dst_recipe = recipes[dst_name]['recipes'][0]
|
dst_recipe = recipes[dst_name]['recipes'][0]
|
||||||
@ -48,6 +34,31 @@ if __name__ == '__main__':
|
|||||||
) * scale
|
) * scale
|
||||||
remain.append({src_name: src_rate})
|
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():
|
for name, rate in required_items.items():
|
||||||
print(name, rate, float(rate * 60))
|
print(name, rate, float(rate * 60))
|
||||||
if rate * 60 > 450:
|
if rate * 60 > 450:
|
||||||
|
Loading…
Reference in New Issue
Block a user