Sub topic 2
Stocks and Flows: What Accumulates and What Changes It
Assume you know the basic rules of strategy, racing, card, or board games and can read percentages. Optional Python knowledge will help with the simulation, but the arithmetic is simple.
The working model
A stock is a quantity that accumulates over time. It describes the current state of a game system. Examples include:
- Gold in a player's treasury
- Health on a character
- Cards in a deck or hand
- Distance traveled in a race
- Units controlled on a map
- Victory points earned so far
A flow is a change that increases or decreases a stock during a time period. Income is a positive flow into gold. Purchases are a negative flow out of gold. Damage is a negative flow out of health.
The basic update rule is:
new stock = old stock + inflows - outflowsThe time period might be a turn, second, lap, or round. Keep the time unit consistent when comparing flows.
| Game quantity | Stock | Possible flows |
|---|---|---|
| Player gold | Current gold | Income, purchases, taxes |
| Character health | Current health | Healing, damage |
| Race distance | Distance traveled | Movement, slowing effects |
A flow changes the stock. The stock does not equal the flow. If a player has 100 gold, that is the stock. If the player gains 10 gold per turn, 10 gold per turn is the flow.
A resource example
Suppose a player starts with 20 gold. Each turn, the player receives 8 gold and spends 5 gold on upkeep. The net flow is 3 gold per turn.
After one turn:
gold = 20 + 8 - 5 = 23The same rule applies when flows vary. A player might gain more income after capturing a mine, or spend extra gold to activate an ability. Those actions change the flow, while the accumulated gold remains the stock.
def simulate_gold(turns, start=20, income=8, upkeep=5):
gold = start
history = [gold]
for turn in range(1, turns + 1):
net_flow = income - upkeep
gold += net_flow
history.append(gold)
return history
print(simulate_gold(5))The output records the stock after every turn. It should be [20, 23, 26, 29, 32, 35].
Stocks can change the flows
In many games, the current stock affects future flows. A player with more gold may buy buildings that increase income. A character with low health may move more slowly, reducing future rewards. This creates feedback: the current state changes what happens next.
This diagram shows why tracking only events can hide important behavior. Record the stock at each time step, then record every flow that changed it. That history helps you identify whether a mechanic is steadily accumulating, draining, or changing direction.
Exercise
A player has 40 energy, gains 12 energy from a shrine, and spends 18 energy on an ability. What are the stock and net flow after the action?
Show answer
The net flow is 12 - 18 = -6 energy. The new stock is 40 - 6 = 34 energy.