Idle Kingdom Clicker Internals

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. That's a priority order, not a price: the real worth of goods is section 1's exchange rate.

What this means in play

What's verified and what isn't