diff --git a/calc2.py b/calc2.py index fcb9a9c..5c1c26d 100644 --- a/calc2.py +++ b/calc2.py @@ -172,6 +172,10 @@ MACHINES = { 'offshore-pump', } +MACHINES_REAL = { + 'assembler': ('_assembler-2', 0.75), +} + def get_resource_name(orig_name: str, recipe_name: str) -> str: if orig_name in MACHINES: @@ -234,20 +238,37 @@ def drop_machines(group: ResourceGroup) -> tuple[ResourceGroup, ResourceGroup]: return group_wo_machines, group_machines +def get_real_resource_counts(group: ResourceGroup) -> list[tuple[str, float]]: + def get_real_rc(rc: tuple[str, float]) -> tuple[str, float]: + resource, count = rc + for resource_from, (resource_real, ratio) in MACHINES_REAL.items(): + if resource.startswith(resource_from): + resource = resource.replace(resource_from, resource_real) + count = count / ratio + break + return resource, count + + rcs = list(map(get_real_rc, group.items())) + return rcs + + def print_resource_group(group: ResourceGroup) -> None: - for resource, count in sorted(group.items()): - print(f' {resource:40}: {dot_align(tuple(group.values()), count)}') + rcs = get_real_resource_counts(group) + cs = tuple(map(lambda rc: rc[1], rcs)) + for resource, count in sorted(rcs): + print(f' {resource:40}: {dot_align(cs, count)}') -SPM = 1 +# science-per-second +SPS = 1 bus_groups: list[ResourceGroup] = [ - {'science-red': SPM}, - {'science-green': SPM}, - {'science-gray': SPM}, - {'science-blue': SPM}, - {'science-purple': SPM}, - {'science-yellow': SPM}, - {'science-white': SPM}, + {'science-red': SPS}, + {'science-green': SPS}, + {'science-gray': SPS}, + {'science-blue': SPS}, + {'science-purple': SPS}, + {'science-yellow': SPS}, + {'science-white': SPS}, ] bus_base = { 'iron-plate', @@ -263,7 +284,7 @@ bus_base = { 'rocket-fuel', } -print(f'{SPM=}') +print(f'{SPS=}') print(f'{bus_base=}') bus_inputs = {} for group in bus_groups: @@ -344,6 +365,9 @@ oil_inputs, oil_machines = drop_machines(oil_inputs) if pg := oil_inputs.pop('petroleum-gas', 0) > 0: raise RuntimeError(f'petrolium-gas > 0: {pg=}') +# ignore heavy/light oil overflow +oil_inputs.pop('light-oil', 0) +oil_inputs.pop('heavy-oil', 0) smelting_outputs = add_recipe(bus_inputs, oil_inputs, -1) smelting_outputs = add_recipe(smelting_outputs, chemical_inputs, -1) @@ -352,7 +376,7 @@ print('smelting outputs') print_resource_group(smelting_outputs) # smelting -smelting_base = {'furnace', 'iron-ore', 'copper-ore', 'coal', 'stone', 'steam', 'water', 'crude-oil'} +smelting_base = {'furnace', 'iron-ore', 'copper-ore', 'coal', 'stone', 'steam', 'water', 'crude-oil', 'light-oil'} # combine to compute mining requirements smelting_inputs, intermediates = reduce_to_base_resources(smelting_outputs, smelting_base) @@ -379,7 +403,7 @@ _, mining_machines = drop_machines(mining_inputs) def despecify_machines(group: ResourceGroup) -> ResourceGroup: # assembler[belt-y] -> assembler, etc. result = {} - for resource, count in group.items(): + for resource, count in get_real_resource_counts(group): if '[' in resource: resource = resource[: resource.find('[')] count = math.ceil(count)