Game Internals › Idle Kingdom Clicker › Production chains

Production chains

How raw goods turn into Food, Material and Science, what every recipe consumes and produces, how much value each step adds, and how the game plans its carts. Built from Code.dll (BalanceTools, ResourceTools, EconomyResolver, EconomyNetworkNode) and the BalanceData25 tables.

1. What goods are worth

ResourceTools.SummarizeVirtualInPlace · SetupLookupTables · BalanceTools.ResourceValue · ResourceValueForCategoryTable

Food, Material and Science aren't stockpiles of their own. They're virtual totals: every good sitting in storage counts towards its category at a fixed exchange rate.

Food = Σ (stored food goods) × value Material = Σ (stored material goods) × value Science = Σ (stored science goods) × value

The same sum is used for the totals you see (UpdateTotalAvailableResourcesSystem), for deciding whether you can afford something (CanPayFromGlobal), and for prestige's "collected this run" (TrackTotalAmountCollectedInRunSystem). When you spend Food, carts draw real goods out of storage at the same rate (ResourceCollectorTools.LoadResources). So a good's value is exactly what one unit is worth everywhere in the economy.

"Routing value" is the solver's value (section 5). It only decides what carts prioritise, never what anything is worth.

How to unlock the producer is the research that unlocks the building that makes each good (research page). The research's tier and its first-level Science cost show roughly when in the game it comes within reach. Four researches are yours from the start (Castle Construction, Foodstore, Foraging Hut, Grassland Dwelling), and a few unlock free as your castle levels up. Some producers also need a deposit or a terrain you can claim.

2. Chain maps

BuildingProductionBaseTable · ResourceConverterTable · ProductionTimerTable

Each good has exactly one producing building, and no chain crosses categories. Arrows show how many units per second one level of the consumer takes. Hover a building to highlight its supply chain.

Raw producer (no inputs)Refinery (turns goods into other goods)

3. Recipes and value added

BuildingProductionPerSecondBase · ConverterConsumptionPerSecondBase @ 0x2851578 · ConverterConsumptionWithAllBoosts · ConverterResourcesRequiredPerCycle
output/s = output base × level × 2^tiers × global × local input/s = input base × level × 2^tiers × global × local per cycle = per second × cycle time (cycle = timer × 0.5^tiers)

A refinery's inputs scale exactly like its output, with the same level, tier doubling and boosts (ConverterConsumptionWithAllBoosts applies the same global and local adjustments). So its input:output ratio is fixed at every level, and boosts don't make a converter more efficient, only bigger. The table shows rates for one level at tier 0, valued with section 1's exchange rates.

Net = output value − input value, per second per level. Refineries only count if their inputs actually arrive. Input values are what the consumed goods would have been worth left in storage.

4. Supply calculator

Pick a building and its level. The calculator follows the chain upstream and works out how much of each input it needs. It expresses that as level-units of the supplying building, where one level-unit means 1 level at tier 0; a level-L building with t tiers supplies L × 2^t of them. It then converts that into a number of suppliers at the level you choose.

Try it

5. How carts are planned

EconomyResolver.BuildAndRunLp · EconomyNetworkNode.TransferToLinearProgram · CreatePerResourceSurplusColumns · ClpRunner.RunProblem (COIN-OR CLP)

The game doesn't move goods with simple rules. Every time the economy is re-planned, EconomyResolver builds a linear program over your whole network and solves it with the bundled COIN-OR CLP solver (libclp.so). Each building contributes columns (variables) and rows (constraints):

Variables
production rate, per-resource ingress and egress, per-route flows from each source building, surplus, and backlog (from the column builders' names).
Limits
production capacity, transport capacity of stores and connectors, storage limits (resourceLimitTable), flow preservation per route, and refinery input ratios.
Objective
maximise Σ routing value × surplus delivered. Deliveries to Universities are weighted ×4, and to Academies and Village Centers ×2 (verified in CreatePerResourceSurplusColumns: weights −4, −2, −2 and −1 in a minimised objective). Food, Material and Science themselves have routing value 0.

The routing values form a ladder. Most distinct steps are ×1.5 (some goods tie), and the jumps get much bigger among the top-tier goods (Elixir → Ink is ×22). So when transport capacity is short, the solver serves higher-tier goods first. These values only set the order goods are served in; for what goods are actually worth, see section 1's exchange rate.

What this means in play

  • If carts or connectors are the bottleneck, low-ladder goods (Fruit, Logs, Potion) are the first to be left waiting.
  • Universities pull hardest (×4), so a University in range of a busy network will soak up carts before ordinary stores do.
  • Storage that's nearly full limits the surplus the solver can deliver there. The code scales the surplus allowance by the free space.

Sources and confidence

  • Read from the code: the virtual-total exchange rates and where they're used; refinery consumption = base × level × 2^tiers × the same boosts as production; the solver's per-good value (routing value, falling back to the category value, 0 for Food/Material/Science); and the ×4/×2/×2/×1 delivery weights.
  • From names, not fully traced: the exact LP constraint set. The variable and constraint families are listed by the names of the methods that build them; not every coefficient has been followed.
  • Not modelled here: cart travel time and capacity, connector limits, storage caps, and governor and Royal Edict boosts on individual tiles. The supply calculator assumes inputs arrive and outputs are stored.
  • Unused data: Oil has a Science value but no producer or consumer. ResourceValueSalesMods (1, 4, 3.5, 3, 0.9) wasn't traced.
  • Checked in the game: building output. A level-1 Foraging Hut on map 1 showed 0.105 Food/s base × level 1 × governors (castle) ×12.72 × research level 17 ×6.6 × prestige ×988.3233ab = 8.71ac Food/s. The formula gives 8.712ac. Fruit is worth 1 Food each, so that's also its Food value per second.