Sub topic 10
Tuning Rules and Parameters
Assume you know loops, functions, dictionaries, and sets, and that a game updates its state in turns or ticks. This chapter focuses on changing rules deliberately so that emergent behavior remains interesting, understandable, and fair.
Tune behavior, not isolated numbers
A parameter is a value that changes how a rule behaves. Examples include fire spread chance, movement cost, resource income, or the strength of a catch-up bonus. A rule may look harmless by itself, but its interactions with other rules determine the actual game.
Begin with a question about player experience:
- Should leaders keep an advantage, or should trailing players have a chance to recover?
- Should fire create a short tactical threat, or reshape the whole map?
- Should a resource shortage force a decision, or simply stop progress?
Then connect the question to an observable measure. Useful measures include:
| Design question | Measure to record |
|---|---|
| Does the leader stay ahead? | Average resource gap by turn |
| Does fire spread too far? | Burned cells after each tick |
| Do players have meaningful choices? | Percentage of turns using each action |
| Does a comeback remain possible? | Win rate for players behind at midpoint |
Do not tune from one memorable match. Emergent systems produce unusual outcomes naturally. Run several matches with different starting states, then compare distributions such as averages, ranges, and win rates.
A practical feedback example
Positive feedback strengthens an existing advantage. Negative feedback weakens a gap. This small model combines both effects:
def income(gold, leader_gold, base=10, interest=0.05, catch_up=0.1):
"""Return one player's income for the next turn."""
return base + interest * gold + catch_up * (leader_gold - gold)
def simulate(turns, start_gold, interest, catch_up):
gold = list(start_gold)
for _ in range(turns):
leader_gold = max(gold)
gold = [
value + income(value, leader_gold, interest=interest, catch_up=catch_up)
for value in gold
]
return gold
for catch_up in (0.0, 0.1, 0.3):
result = simulate(10, [200, 100], interest=0.05, catch_up=catch_up)
print(f"catch_up={catch_up}: {[round(value, 1) for value in result]}")The interest term rewards having more gold, so it is positive feedback. The catch-up term rewards being behind, so it is negative feedback. Increasing catch-up should reduce the final gap, but too much catch-up can make early success feel pointless.
Tune one parameter at a time first. Record the old value, the new value, and the effect you expected. If several values change together, you cannot tell which change caused the result.
Use a tuning loop
A reliable tuning loop has four stages:
- State the intended behavior in player terms.
- Choose a measure that reveals that behavior.
- Run repeatable tests with controlled starting states.
- Change one rule or parameter and compare the results.
A deterministic random seed helps reproduce a surprising match. After the system behaves well in controlled tests, vary the seed and starting conditions. A rule that works only on one map or one opening is not tuned yet.
Recognize failure patterns
A parameter is probably too strong when one strategy dominates across many starting states. It may be too weak when players ignore it or when changing it produces no measurable effect.
Watch for these patterns:
- Runaway leader: positive feedback compounds faster than opponents can respond.
- Flat outcomes: negative feedback erases useful differences, so choices barely matter.
- Threshold cliff: a small value change makes the system suddenly collapse or explode.
- Hidden dependency: a parameter appears balanced until another rule creates a rare combination.
- Oscillation: the system swings between two extreme states instead of settling into useful tension.
Prefer small changes near a known working value. If a change causes a threshold cliff, inspect the interaction rather than merely reducing the number. The problem may be an unbounded reward, an action that can repeat for free, or an update order that gives one rule an unintended advantage.
Exercise
Two players start with 200 and 100 gold. Interest is 0.05 and catchup is 0.1. What happens to the gap if catchup increases?
Show answer
The trailing player receives a larger bonus because the gold gap is larger, so the gap should shrink faster. Test whether a higher value makes comebacks possible without making the leader's early advantage irrelevant.