38fd2e4e89a792946bd01c1b45b6b0a55bc2b766
Four algorithm fixes to bring ThreatCostCalculator.cpp into agreement with
tools/threat_report.py and the newly amended REQ-THREAT-ITEM semantics:
6. Scrap-consuming recipes as threat fallback only. Non-reprocessing recipes
that take scrap as an input are excluded from an item's threat computation
whenever at least one scrap-free recipe (miner/smelter/assembler) produces
that item. Previously the scrap_smelting recipe (1 scrap → 1 iron_ingot)
would have inflated iron_ingot's threat via the max rule.
7. Per-unit item threat. computeRecipeThreatPerUnit() now divides by the
recipe's output amount, so multi-output recipes price each unit correctly.
Example: copper_wire (1 copper_ingot, 1 s, output 2) is now 1.5, not 3.
8. Fixpoint resolution. The resolution loop now alternates the non-reprocessing
pass and the reprocessing pass until neither makes progress, rather than
running the reprocessing pass once at the end. Items downstream of
reprocessing-only items (voidsteel_plate, capital_core, capital hulls,
drone_hangar_module) now resolve correctly.
9. Max rule across staggered recipes. An item is committed only once every
eligible recipe producing it is computable, so a shallow shortcut recipe
(e.g. shortcut_steel_plate: 3 iron_ore → 1 steel_plate, resolvable one
iteration earlier) cannot undercut the expensive base path. A deadlock
fallback (require_all_recipes=False) handles potential recipe cycles.
docs/requirements.md: REQ-THREAT-ITEM amended for per-unit division, the
scrap-fallback rule, and order-independence via fixpoint.
docs/progression_design.md: action items 6-9 removed (completed); remaining
items 1-5 renumbered unchanged.
tools/threat_report.py: NOTE updated — C++ now matches Python semantics.
bin/test/data/config/recipes.toml: four minimal test recipes added (one per
fix: scrap_iron, dual_wire, downstream_product, staggered_item_{cheap,expensive}).
src/test/ThreatCostCalculatorTest.cpp: four new TEST_CASEs covering each fix.
Expected values with the live config (bin/app/data/config) verified by
threat_report.py: iron_ingot 2, copper_wire 1.5, steel_plate 7, control_chip
12, voidsteel_plate 141, capital_core 240; fitted ships 10.5/47/99/233.5/
354.5/722.5/1491.5/1436.5. All 378 test cases pass.
Description
No description provided
Languages
C++
96%
CMake
2.2%
Python
1.2%
C
0.6%