Sub topic 12
Simulating an Economy Before Release
Assume you understand basic game rewards, prices, and percentages. You should also be comfortable reading short Python programs. A simulation is a small model that runs an economy many times with different assumptions. It helps you find problems before players discover them.
Choose the quantities to model
Start with a stock-and-flow model:
- A stock is an amount held at a moment, such as a player's balance.
- An inflow adds to the stock, such as quest rewards.
- An outflow removes from the stock, such as repair costs.
- A rate describes how often or how strongly a flow changes.
For a simple economy, update the balance once per day:
new balance = old balance + income - spending
You can model spending as a percentage of the current balance. This represents a sink such as fees, repairs, or crafting costs that grows as players become wealthier.
def simulate(days, income_per_day, sink_rate, start=0.0):
"""Track one player's balance over several days."""
balance = start
history = []
for day in range(1, days + 1):
balance += income_per_day
balance -= balance * sink_rate
history.append((day, round(balance, 2)))
return history
history = simulate(60, income_per_day=100, sink_rate=0.10)
for day, balance in history[::10]:
print(f"Day {day}: {balance}")
print(f"Final balance: {history[-1][1]}")With a fixed income of 100 and a 10% sink, the balance approaches a stable level near 900. The balance does not grow forever because the sink removes more currency as the balance rises.
Read the simulation as a model
The program is useful because it makes assumptions visible. It does not predict player behavior perfectly. It answers a narrower question: what happens if income and the sink behave as specified?
Change one input at a time and compare the result.
| Input | Meaning | Possible test |
|---|---|---|
| `income_per_day` | Currency earned by a typical player | 50, 100, 150 |
| `sink_rate` | Fraction removed after income | 0.05, 0.10, 0.20 |
| `days` | Length of the modeled period | 30, 60, 180 |
Test several player profiles rather than one average player. A new player may earn 50 currency per day, while an expert earns 200. If both face the same prices, the expert may accumulate too much or the new player may find progression too slow.
Test scenarios and failure signals
Useful scenarios include:
- A player who never spends currency.
- A player who spends the expected amount.
- A highly active player who earns at the maximum normal rate.
- A player who returns after several weeks away.
- A player who reaches an unusual but valid balance.
Look for these signals:
- Balances increase without approaching a useful range.
- Players cannot afford required purchases.
- One reward source dominates all other sources.
- A sink removes currency faster than players can recover.
- A small input change creates an extreme outcome.
A simulation should produce measurements such as median balance, time to afford an upgrade, and currency created per day. Compare those measurements with your design targets, then adjust rewards, prices, or sinks.
Exercise
If daily income is 200 and the sink rate is 5%, will this model settle at a higher or lower balance than income of 100 and a sink rate of 10%?
Show answer
It will settle at a higher balance. The approximate stable balance is income multiplied by (1 - sink rate) divided by sink rate: 200 × 0.95 ÷ 0.05 = 3,800, compared with 100 × 0.90 ÷ 0.10 = 900.