Sub topic 3
What a feedback loop is
This chapter defines a feedback loop and gives you a test for spotting one in a game. It assumes you can already tell a stock from a flow (the previous chapter) and can read simple percentage formulas. The Python examples are short, and you can follow the chapter without running them.
The definition
A feedback loop is a chain of cause and effect that returns to where it started. The state of the game changes something, and that change eventually changes the state again.
A loop has three parts:
- A stock, which is a quantity that accumulates, such as gold, health, territory or score.
- A flow, which is the rate at which that stock rises or falls each turn or each second.
- A link from the stock back to the flow. The current level of the stock affects how large the flow is.
The third part is the one that matters. Without it you have a stock and a flow, but no loop.
Chains versus loops
Many game mechanics look like loops but are one-way chains. A chain has a cause and an effect, and the effect never reaches back to the cause.
| Mechanic | Structure | Why |
|---|---|---|
| A mine produces 2 gold per turn | Chain | The income is fixed. Having more gold does not change it. |
| You earn 10% interest on your gold each turn | Loop | Gold sets the income, and the income adds to the gold. |
| A trap deals 5 damage when stepped on | Chain | The damage does not depend on your health. |
| A boss enrages below 30% health | Loop | Health sets the boss's damage, and that damage affects the player's play, which affects the boss's health. |
The test is simple. Pick a stock and follow the arrows outward. If you can return to the same stock without breaking the chain, there is a loop.
Seeing the difference in code
The function below runs a stock for a number of turns. Its flow_from argument is a function that decides the size of the flow. We call it twice: once with a constant flow and once with a flow that reads the stock.
def run(stock, flow_from, turns):
history = [stock]
for _ in range(turns):
stock += flow_from(stock) # the flow may read the current stock
history.append(stock)
return history
no_loop = run(10.0, lambda s: 2.0, 4) # flow ignores the stock
with_loop = run(10.0, lambda s: 0.2 * s, 4) # flow depends on the stock
print([round(x, 2) for x in no_loop])
print([round(x, 2) for x in with_loop])The output is:
[10.0, 12.0, 14.0, 16.0, 18.0]
[10.0, 12.0, 14.4, 17.28, 20.74]Both runs start at 10 and add 2 on the first turn. The constant flow keeps adding exactly 2. In the looped run the flow grows with the stock, so the increments become 2.0, 2.4, 2.88 and 3.46.
The loop is visible in the line stock += flow_from(stock). The stock goes into the function that decides how much the stock changes. When you read game code, look for this pattern: a value is read to compute a change to that same value, possibly through several steps.
Loops are often indirect
Real loops rarely have one step. The stock usually reaches its own flow through other variables. Consider a racing game where the player in last place gets stronger items:
- The player's position falls behind.
- The item system gives better items to players further back.
- Better items let the player gain speed or hit the leader.
- The player's position improves.
Position affects items, items affect speed, and speed affects position. No single formula contains the loop. It exists in the chain of dependencies, so you find it by tracing, not by reading one line.
The longer the path, the easier it is to miss. When you analyze a mechanic, list every variable that the stock influences and ask what each of them influences in turn. Stop when you either return to the stock or run out of effects.
The loop closes through players, too
Not every link is a number in the code. Some links run through human decisions.
- A player who sees an opponent far ahead may attack that opponent. This links the leader's position to the leader's own losses.
- A player with a huge army may stop building defenses. This links strength to a later weakness.
- A player who is losing may take riskier bets, which changes how fast the losing stock moves.
These loops are real and shape the game, but they are harder to measure because they depend on player behavior. A designer who counts only the loops written into the rules will underestimate the feedback in the game.
Direction: the sign of a loop
Each link in a loop either pushes in the same direction or the opposite direction. More gold gives more income (same direction). More health for a boss gives less damage taken by the boss (opposite direction). Whether a whole loop amplifies change or resists it depends on its links, and later chapters name these two types positive (reinforcing) and negative (balancing).
For now, remember only that a loop does one of two things to a change:
- It makes the change bigger, and the stock keeps moving in the direction it already moves.
- It makes the change smaller, and the stock is pulled back toward some level.
Neither type is good or bad by itself. Which one a game needs depends on what the designer wants players to feel.
A loop needs time
A loop works in steps: the stock changes, the flow responds, and the stock changes again. The size of these steps matters.
In code, the step is a turn or a frame. In a game, it might be a round, a resource tick or a respawn timer. If the response to a change takes a long time, a loop can overshoot, and the flow keeps pushing after the stock has already reached a sensible level. Chapter 12 covers delays and oscillation in detail. For now, keep in mind that a loop describes how a system changes over time, not only what it looks like at one moment.
How to find loops in a game you know
Use this routine on any mechanic:
- Name the stock you care about. Make it a quantity that accumulates (gold, lead, territory).
- List the flows that raise it and the flows that lower it.
- For each flow, ask what determines its size.
- If the answer includes the stock, you have a direct loop.
- If the answer includes another variable, ask what determines that one. Continue until you reach the stock or a fixed value.
- Mark any link that depends on player choice, and note it separately.
Take a typical city-building game as an example. The stock is population. A flow, births, is larger when population is larger. A second flow, deaths, may be larger when population is crowded. Both flows depend on the stock, so this one stock has two loops pushing on it.
Common mistakes
- Calling any cause and effect a loop. If the effect cannot reach the cause, it is a chain.
- Forgetting that a loop has to pass through a stock. Flows come from stocks, so if you cannot name the stock, you have not found the loop.
- Missing indirect links. A loop that passes through four variables is as real as one that passes through none.
- Ignoring player-mediated links, which often carry the strongest feedback in competitive games.
- Assuming one stock has one loop. A single stock often has several loops acting on it at once, and the next chapters show why that matters.
Exercise
In a card game, each player draws one card per turn. A player who holds more than 7 cards at the end of their turn must discard down to 7. Is there a feedback loop on hand size? Name the stock, the flow and the link, and say whether a loop exists.
Show answer
Yes, a loop exists, but only above the cap. The stock is the number of cards in hand. The flows are drawing, which adds one card per turn, and discarding. The discard flow depends on the stock: it is zero at 7 cards or fewer, and it equals the excess above 7 otherwise. Hand size therefore determines the size of the discard flow, and discarding reduces hand size, so the loop closes. Drawing alone is a chain, because it is a fixed one card per turn that ignores hand size. This loop is balancing: it pulls hand size back toward 7.
Exercise
A strategy game gives each player 1 gold per owned town per turn. Players spend gold to capture more towns. Trace the loop in four steps, and say what you would need to change to turn it into a chain.
Show answer
Towns produce gold (1 per town per turn), gold buys captures, captures increase the number of towns, and towns produce gold again. To make it a chain, break the final link: for example, give every player a fixed income regardless of towns, or make towns unable to be captured with gold. Then the number of towns would no longer influence the income, and the cycle would be broken.