Sub topic 9
Limits, caps and saturation
What this chapter assumes
You should already know stocks and flows, and the difference between reinforcing (positive) and balancing (negative) loops. The code is plain Python 3 with no libraries. Everything here builds on the one-line update stock += flow.
Why every growth loop meets a limit
A reinforcing loop with no limit grows without bound. In a real game something always stops it. The screen runs out of room, the rules forbid more, or the player has nothing left to spend on. Some limit is always present. The design question is whether you chose it or it appeared by accident.
A limit works as a balancing loop that is weak when the stock is small and strong when the stock is large. It adds a second loop to the system, and the interaction between the two decides how the game feels. The next chapter covers that interaction in detail. This chapter covers the limit itself.
Three kinds of limit
| Kind | How it acts | Typical example | Feel |
|---|---|---|---|
| Hard cap | Clamps the stock at a maximum | A mana pool that cannot exceed 10 | Abrupt. Growth is full-speed, then it stops. |
| Soft cap | Shrinks the flow as the stock rises | Diminishing returns on stacked bonuses | Gradual. Each step costs more for less. |
| Drain | Adds an outflow that rises with the stock | Unit upkeep, inventory weight, decay | Natural. The stock settles where inflow equals outflow. |
The terms for the end state are as follows.
- Saturation is the condition in which the stock sits near its limit and extra effort barely moves it.
- Carrying capacity is the stock level at which inflow and outflow balance, so the stock stops changing.
A hard cap in code
A hard cap is a min call. This version extends the reinforcing loop from the earlier example.
def capped(turns, rate=0.10, start=10.0, cap=30.0):
gold = start
history = [gold]
for _ in range(turns):
gold = min(cap, gold + rate * gold)
history.append(gold)
return history
print([round(g, 1) for g in capped(15)])The stock grows by 10% per turn until turn 12, when it would reach about 31.4. The min call clamps it to 30.0, and it stays there. The loop is still running at that point. Each turn it computes a larger number and the cap discards the excess. The reinforcing loop is still active, but the cap overrides its output.
A soft limit in code
A soft limit multiplies the growth by a factor that falls to zero at capacity. This is the standard logistic form: growth is proportional to the stock (reinforcing) and to the remaining room (balancing).
def logistic(turns, rate=0.30, capacity=100.0, start=5.0):
stock = start
history = [stock]
for _ in range(turns):
stock += rate * stock * (1 - stock / capacity)
history.append(stock)
return history
smooth = logistic(30)
print([round(s, 1) for s in smooth[::5]])
# Same model, but a much larger rate
jumpy = logistic(12, rate=2.2)
print(round(max(jumpy), 1), "exceeds capacity:", max(jumpy) > 100.0)With rate=0.30 the curve is an S shape. Growth is nearly exponential while the stock is small, fastest near the middle, and it flattens as the stock approaches 100. It approaches the capacity from below and never passes it.
The second call shows a failure mode. With rate=2.2, each turn's step is so large that the stock jumps past the capacity (it reaches about 101.8 on the fourth turn). The balancing term then pulls it back too hard on the next turn. The result is overshoot and oscillation, even though the formula looks like a gentle limit. The cause is that you update in discrete turns, and a strong correction applied once per turn overshoots the target. Delays and oscillation get their own chapter. For now, treat a large rate in a turn-based model as a warning sign.
How the loops fit together
The top loop is reinforcing. The bottom loop is balancing, because more gold leads to more upkeep, which removes gold. At low stock the income loop dominates. At high stock the upkeep loop dominates. The stock settles where the two flows are equal.
Where limits appear in real games
- Hearthstone caps mana crystals at 10 and hand size at 10. Both are hard caps that bound the late game.
- Real-time strategy games such as StarCraft cap total army supply at 200. Resource income can keep growing, but it can no longer be converted into more units.
- Role-playing games usually have a level cap, and many also add soft caps. The experience needed per level rises, so each hour of play gives less visible progress.
- Inventory weight limits are drains in disguise. Carrying more makes you slower, which makes picking up more costly.
Design consequences
A cap changes where the decisions are
Before a hard cap, the question is how to grow fastest. After it, growth no longer matters, and the question becomes what to do with the surplus. A cap that arrives too early removes the growth decisions. A cap that arrives too late lets a leader run away unchecked, which is the snowballing problem from earlier chapters.
Wasted flow is visible to the player
When a stock sits at its cap, new income is thrown away. If the player can see that waste, it feels bad. Some games soften this by converting the overflow into something else, such as a bonus resource or banked progress, or by showing a warning before the cap is reached.
Caps can hide a broken loop
A hard cap can make a dangerous reinforcing loop look harmless. The loop still runs behind the clamp, and any change that raises the cap or removes it brings the runaway back at once. When you test, check the uncapped behavior as well, so you know how much the cap is doing.
Check the order of operations
In a simulation, the order of the cap and the other updates affects the result. Consider these two orderings.
- Add income, then clamp, then subtract upkeep. The stock can end a turn below the cap even though it was clamped mid-turn.
- Subtract upkeep, then add income, then clamp. Income that arrives at the cap is wasted, because upkeep did not make room first.
Both are valid. They give different results, so choose one deliberately and keep it the same in every run you compare.
Choosing a limit type
Use these criteria to decide.
- Choose a hard cap when you need predictable bounds, such as a UI that must fit ten cards or a network budget that must hold. It is easy to explain to players.
- Choose a soft cap when you want players to keep progressing but with falling returns, and you want to avoid a visible wall.
- Choose a drain when you want the stock to reflect the player's ongoing choices, because the equilibrium moves when the player changes how much they spend.
Combining them is common. A drain gives a natural equilibrium, and a hard cap acts as a safety net in case a loop is tuned badly.
Exercise
In capped(15), the cap is 30 and the rate is 10%. Suppose you change the code so the order is "clamp first, then add income" (gold = min(cap, gold) + rate * gold). What problem does this create, and how would you detect it?
Show answer
The stock can exceed the cap at the end of a turn. Once gold reaches 30, the clamp does nothing to the new income, so gold becomes 33 and then 36.3, and so on. The cap no longer bounds the stored value. You can detect it by asserting max(history) <= cap after every run. The fix is to apply the clamp after the income is added.
Exercise
A game has an income loop (income = 8% of gold) and an upkeep drain (upkeep = 2% of gold squared divided by 100, with gold in coins). At what gold level are income and upkeep equal, apart from gold = 0?
Show answer
Set 0.08 × g = 0.02 × g² / 100. Dividing both sides by g (g is not 0) gives 0.08 = 0.0002 × g, so g = 400. Below 400 gold, income exceeds upkeep and the stock grows. Above 400, upkeep exceeds income and the stock shrinks. The equilibrium at 400 is stable, because the net flow pushes the stock back toward it from either side.