plan: remove initial request construction out of 'plan'

This commit is contained in:
Danny Robson 2019-07-14 12:03:38 +10:00
parent 2112292fc1
commit f75047dde5

33
plan.py
View File

@ -120,17 +120,16 @@ def required_power(recipes: satisfactory.Cookbook, machines: Dict[str, int]) ->
return total return total
def main(): def plan(recipes: satisfactory.Cookbook, required: Dict[str, Fraction]):
recipes = satisfactory.Cookbook('data/recipes') """
Print the items and rates, machines and counts, and power requirements
need to produce the items named in the dict at the mapped rate.
# Create a list of items we want to make :param recipes:
# names = [ 'supercomputer' ] :param required:
names = recipes.components() :return:
"""
# Create an initial name:rate request for all of the target items, then rates = required_rates(recipes, required)
# create a plan for their creation.
remain = [{n: basic_rate(recipes[n]['recipes'][0]) for n in names}]
rates = required_rates(recipes, remain)
# Note if any particular item is (in aggregate) going to exceed the # Note if any particular item is (in aggregate) going to exceed the
# highest conveyor belt capacity. # highest conveyor belt capacity.
@ -146,5 +145,19 @@ def main():
print(math.ceil(power / 150), "fuel generators") print(math.ceil(power / 150), "fuel generators")
def main():
recipes = satisfactory.Cookbook('data/recipes')
# Create a list of items we want to make
# names = [ 'supercomputer' ]
names = recipes.components()
# Create an initial name:rate request for all of the target items, then
# create a plan for their creation.
request = [{n: basic_rate(recipes[n]['recipes'][0]) for n in names}]
plan(recipes, request)
if __name__ == '__main__': if __name__ == '__main__':
main() main()