give output-group eligibility one home

The rule that decides whether a group may be picked -- every item it yields
unlocked, the group judged whole because its items are produced together
(REQ-LOCK-OUTPUT-POOL) -- was written out inside rollOutputGroup, where nothing
outside the sim could reach it. It moves next to producesItem and
getProducibleItems in RecipesConfig.h, which is where the recipe-level queries
already shared between lib and ui live.

Deliberately narrow: the helper says whether a group is eligible, not whether
eligibility is asked about at all. rollOutputGroup keeps its own reason for not
asking when a recipe has a single group.

No behaviour change; the pool's end-to-end test still covers the rule and a
direct one now pins the judged-whole semantics.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
2026-08-20 14:26:36 +02:00
parent 7c02b8717b
commit f93252f69b
3 changed files with 43 additions and 10 deletions

View File

@@ -67,20 +67,13 @@ std::vector<Item> ProductionSystem::rollOutputGroup(const RecipeDef& recipe)
return itemsOf(recipe.outputGroups.front());
}
// Several groups: only those whose items are all unlocked can be picked, and a group
// holding any locked item is dropped whole, since its items come together
// (REQ-LOCK-OUTPUT-POOL). Weights are renormalized over what is left by
// discrete_distribution.
// Several groups: only the unlocked ones can be picked (REQ-LOCK-OUTPUT-POOL), and
// weights are renormalized over what is left by discrete_distribution.
std::vector<const RecipeOutputGroup*> eligible;
std::vector<double> weights;
for (const RecipeOutputGroup& group : recipe.outputGroups)
{
bool allUnlocked = true;
for (const RecipeOutput& out : group.items)
{
if (!m_isItemUnlocked(out.item)) { allUnlocked = false; break; }
}
if (!allUnlocked) { continue; }
if (!isOutputGroupUnlocked(group, m_isItemUnlocked)) { continue; }
eligible.push_back(&group);
weights.push_back(group.probability.value_or(1.0));
}