Sub topic 1
Seeing a Game as a System
Prerequisites
This chapter assumes you know how common game genres work, such as strategy, racing, or card games. You should be comfortable with percentages and simple formulas. Basic Python helps with the code example, but you can skip it.
Seeing a Game as a System
A game is a system: a set of parts whose state changes as players act. The state is everything the game tracks at a given moment, such as each player's gold, health, or position. Player actions change the state, and the new state determines what the player can do next. That cycle drives how a match unfolds over time.
Stocks and Flows
A stock is a quantity that accumulates, such as gold, health, or territory. A flow is a rate that changes a stock, such as income per turn or damage per second. Stocks change only through flows. To explain why one player is ahead, identify the stocks and the flows that fill or drain them.
What a Feedback Loop Is
A feedback loop forms when a stock affects the flow that changes that same stock. The output of the system feeds back in as input. Loops explain why a small early advantage can grow into a large lead, or fade away.
Positive Feedback: Success That Feeds on Itself
Positive feedback, also called reinforcing feedback, is a loop where more of a stock produces more change in the same direction. A player with more gold earns more income, and that income adds more gold. The stock grows faster as it grows larger.
def reinforcing(turns, rate=0.10, start=10.0):
gold = start
history = [gold]
for _ in range(turns):
gold += rate * gold # income is proportional to current gold
history.append(gold)
return history
print(reinforcing(5))Each turn adds 10% of the current gold, so the increase gets larger every turn.
Exercise
In the code above, what happens to gold if rate is set to 0?
Show answer
Gold stays at 10.0 on every turn, because the income flow is zero and nothing changes the stock.