Implements REQ-MAT-OUTPUT-GROUP. A recipe had two shapes -- outputs produced together, or outputs of which exactly one happened -- and every rule over them was written twice, selected by `building == ReprocessingPlant`: sizing a buffer, deciding whether a cycle fits, resolving what a cycle makes, costing an item. RecipeDef now holds output groups, each a weight and a list of items, and a cycle yields exactly one group. One group is the ordinary recipe, so the old two cases are the same shape with one and with several, and all four rules collapse to one expression apiece with no building-type test left. rollReprocessingOutput becomes rollOutputGroup, where a single group returns without drawing or testing eligibility. That early-out is load-bearing twice over. Drawing there would consume entropy for every ordinary recipe and shift every later random outcome; and eligibility must not apply either, since implicit unlocking is demand-derived, so an ordinary recipe's output can be producible while nothing yet calls for it -- testing it would stop the building producing rather than gate a drop. Past the early-out a group is eligible only when all of its items are unlocked, being produced whole. Threat follows the recipe's shape rather than the building, and the per-unit value now divides by the group's amount as well as its odds. That moves no number today: every item resolved through this path has amount 1, which is why the threat expectations are untouched. Config keeps `outputs = [...]` as the single-group form, so only the two reprocessing recipes change shape. The recipe summary gains "/" between groups and keeps "+" within one, which also fixes the plant reading as though a cycle produced all of its items at once. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
146 lines
4.3 KiB
TOML
146 lines
4.3 KiB
TOML
[[recipe]]
|
|
id = "mine_iron_ore"
|
|
building = "miner"
|
|
inputs = []
|
|
outputs = [{item = "iron_ore", amount = 1}]
|
|
duration_seconds = 1.0
|
|
|
|
[[recipe]]
|
|
id = "mine_copper_ore"
|
|
building = "miner"
|
|
inputs = []
|
|
outputs = [{item = "copper_ore", amount = 1}]
|
|
duration_seconds = 1.5
|
|
|
|
[[recipe]]
|
|
id = "iron_ingot"
|
|
building = "smelter"
|
|
inputs = [{item = "iron_ore", amount = 2}]
|
|
outputs = [{item = "iron_ingot", amount = 1}]
|
|
duration_seconds = 2.0
|
|
|
|
[[recipe]]
|
|
id = "copper_ingot"
|
|
building = "smelter"
|
|
inputs = [{item = "copper_ore", amount = 2}]
|
|
outputs = [{item = "copper_ingot", amount = 1}]
|
|
duration_seconds = 2.5
|
|
|
|
[[recipe]]
|
|
id = "circuit_board"
|
|
building = "assembler"
|
|
inputs = [{item = "iron_ingot", amount = 3}, {item = "copper_ingot", amount = 2}]
|
|
outputs = [{item = "circuit_board", amount = 1}]
|
|
duration_seconds = 5.0
|
|
|
|
[[recipe]]
|
|
id = "building_blocks"
|
|
building = "assembler"
|
|
inputs = [{item = "iron_ingot", amount = 4}]
|
|
outputs = [{item = "building_block", amount = 10}]
|
|
duration_seconds = 4.0
|
|
|
|
[[recipe]]
|
|
id = "premium_circuit"
|
|
building = "assembler"
|
|
unlocked_at_start = true
|
|
inputs = [{item = "circuit_board", amount = 1}]
|
|
outputs = [{item = "premium_circuit", amount = 1}]
|
|
duration_seconds = 8.0
|
|
|
|
[[recipe]]
|
|
id = "quick_circuit"
|
|
building = "assembler"
|
|
inputs = [{item = "copper_ingot", amount = 3}]
|
|
outputs = [{item = "circuit_board", amount = 1}]
|
|
duration_seconds = 3.0
|
|
|
|
[[recipe]]
|
|
id = "advanced_circuit"
|
|
building = "assembler"
|
|
inputs = [{item = "iron_ingot", amount = 5}]
|
|
outputs = [{item = "circuit_board", amount = 1}]
|
|
duration_seconds = 6.0
|
|
|
|
[[recipe]]
|
|
id = "exotic_alloy"
|
|
building = "assembler"
|
|
inputs = [{item = "exotic_ore", amount = 2}]
|
|
outputs = [{item = "exotic_alloy", amount = 1}]
|
|
duration_seconds = 10.0
|
|
|
|
[[recipe]]
|
|
id = "reprocessing_cycle"
|
|
building = "reprocessing_plant"
|
|
inputs = [{item = "scrap", amount = 5}]
|
|
duration_seconds = 3.0
|
|
|
|
[[recipe.output_group]]
|
|
probability = 0.6
|
|
items = [{item = "iron_ingot", amount = 2}]
|
|
|
|
[[recipe.output_group]]
|
|
probability = 0.3
|
|
items = [{item = "circuit_board", amount = 1}]
|
|
|
|
[[recipe.output_group]]
|
|
probability = 0.1
|
|
items = [{item = "advanced_alloy", amount = 1}]
|
|
|
|
# -------------------------------------------------------------------
|
|
# Extra recipes for ThreatCostCalculator unit tests (fixes 6-9)
|
|
# -------------------------------------------------------------------
|
|
|
|
# Fix 6: scrap-consuming smelter recipe for iron_ingot. Because iron_ingot
|
|
# already has a scrap-free smelter recipe above, this recipe must be excluded
|
|
# from iron_ingot's threat computation.
|
|
[[recipe]]
|
|
id = "scrap_iron"
|
|
building = "smelter"
|
|
inputs = [{item = "scrap", amount = 1}]
|
|
outputs = [{item = "iron_ingot", amount = 1}]
|
|
duration_seconds = 1.0
|
|
|
|
# Fix 7: a recipe that produces 2 items per cycle. Per-unit threat must
|
|
# divide by the output amount.
|
|
# dual_wire: (duration=3.0 + iron_ore(1.0)*1) / 2 = 4.0 / 2 = 2.0 per unit.
|
|
[[recipe]]
|
|
id = "dual_wire"
|
|
building = "assembler"
|
|
inputs = [{item = "iron_ore", amount = 1}]
|
|
outputs = [{item = "dual_wire", amount = 2}]
|
|
duration_seconds = 3.0
|
|
|
|
# Fix 8: an item downstream of a reprocessing-only item (advanced_alloy).
|
|
# advanced_alloy is resolved only by the reprocessing pass; downstream_product
|
|
# can only resolve in a non-reprocessing pass that runs AFTER the reprocessing
|
|
# pass, requiring proper fixpoint iteration.
|
|
# downstream_product: 2.0 + advanced_alloy(80.0)*1 = 82.0
|
|
[[recipe]]
|
|
id = "downstream_product"
|
|
building = "assembler"
|
|
inputs = [{item = "advanced_alloy", amount = 1}]
|
|
outputs = [{item = "downstream_product", amount = 1}]
|
|
duration_seconds = 2.0
|
|
|
|
# Fix 9: two recipes producing the same staggered_item. The cheap recipe
|
|
# resolves before circuit_board is known; the expensive one requires
|
|
# circuit_board. The item must be committed only once BOTH are computable,
|
|
# so the result is max(cheap, expensive).
|
|
# staggered_item_cheap: 1.0 + iron_ore(1.0)*1 = 2.0 (resolves early)
|
|
# staggered_item_expensive: 1.0 + circuit_board(28.0)*1 = 29.0 (resolves later)
|
|
# expected: max = 29.0
|
|
[[recipe]]
|
|
id = "staggered_item_cheap"
|
|
building = "assembler"
|
|
inputs = [{item = "iron_ore", amount = 1}]
|
|
outputs = [{item = "staggered_item", amount = 1}]
|
|
duration_seconds = 1.0
|
|
|
|
[[recipe]]
|
|
id = "staggered_item_expensive"
|
|
building = "assembler"
|
|
inputs = [{item = "circuit_board", amount = 1}]
|
|
outputs = [{item = "staggered_item", amount = 1}]
|
|
duration_seconds = 1.0
|