Sub topic 9
Separating Tuning Values from Rules
This chapter assumes you have read the chapters on writing rules and acceptance criteria. You should know what a rule is and what a Given/When/Then scenario looks like. You do not need to know any programming language, but you should be able to read a short YAML file.
Why the split matters
A feature spec contains two kinds of statements that change at very different speeds.
- A rule says what the feature does. "The player cannot dash while a dash cooldown is active."
- A tuning value says how much, how long, or how often. "The cooldown is 0.8 seconds."
Rules change rarely. A change to a rule is a design decision that engineering, animation, and QA all need to hear about. Tuning values change constantly. During playtesting, a designer may adjust the dash duration ten times in one afternoon.
If the numbers sit inside the rule text, every adjustment edits the spec. Each edit creates a new version, a review question ("did the rules change?"), and a chance that the spec and the game disagree. If a number appears in three places and a designer updates only two, the team now has conflicting sources.
The fix is to state each rule in terms of a named value, and to keep the value in one separate place.
Rules refer to names, not numbers
Compare two versions of the same rule.
- Mixed: "The player cannot dash again until 0.8 seconds after the previous dash starts."
- Separated: "The player cannot dash again until the dash cooldown has elapsed since the previous dash started."
The second version is stable. It stays true if the cooldown becomes 0.6 or 1.2 seconds. It also states something the first version leaves vague: the cooldown is measured from the start of the previous dash, not from its end.
The numbers then live in a tuning file. This one comes from the dash spec used throughout this tutorial.
# dash_tuning.yaml
dash:
speed: 18.0 # units per second
duration: 0.2 # seconds
cooldown: 0.8 # seconds
air_dashes_per_jump: 1The spec points to it with a single line: "Tuning values: see dash_tuning.yaml." The rule text uses the names dash speed, dash duration, dash cooldown, and air dashes per jump.
What counts as a tuning value
Not every number is tuning. Use this test: if a playtest suggested a different number, would the design still be the same feature?
- Dash speed of 18 or 22 units per second: same feature. This is tuning.
- One air dash per jump or two: probably still the same feature, but it changes how the player moves through the level. It is tuning, but a sensitive one, and the spec should say so.
- "The player can dash in the air" versus "the player can only dash on the ground": different feature. This is a rule.
Some numbers are structural and belong in the rules even though they are numbers. "A party has up to four players" may drive the UI layout, the network design, and the level layouts. Changing it is a design change, not a tweak. Record it as a constraint or rule, and say that changing it requires review.
| Kind of statement | Example | Where it belongs |
|---|---|---|
| Rule | Damage cancels a dash | Spec text |
| Tuning value | Cooldown is 0.8 s | Tuning file |
| Structural number | Maximum four players | Spec text, marked as a constraint |
| Derived value | Dash distance = speed × duration | Spec text as a formula, never stored as a number |
Derived values
Some numbers follow from others. With the values above, the dash covers 18.0 × 0.2 = 3.6 units. If the spec states "the dash covers 3.6 units" and also lists speed and duration, then changing one of them silently makes the 3.6 wrong.
Write the relationship instead: "Dash distance is dash speed multiplied by dash duration." Level designers who need the current distance can compute it, and the spec stays correct when the inputs change.
If a derived value matters to another discipline, such as a gap that must be crossable, put the requirement in terms of the relationship: "Every gap marked as dash-crossable must be shorter than the dash distance."
Describing each tuning value
A name and a number are not enough. A tuning file entry should come with enough information that someone other than the author can change it safely. For each value, record:
- Unit. Seconds, units per second, percent, count. A value of
0.2with no unit is ambiguous. - Starting value. The number used for the first implementation.
- Safe range. The range inside which the feature still works as designed. A cooldown of 0 may break a rule or an animation.
- What it affects. Which feel, balance, or other systems respond to it.
A table in the spec keeps this readable without putting numbers in the rules:
| Name | Unit | Start | Safe range | Notes |
|---|---|---|---|---|
| Dash speed | units/s | 18.0 | 12 to 24 | Higher values make dashes harder to control |
| Dash duration | s | 0.2 | 0.1 to 0.3 | Must not exceed the dash animation length |
| Dash cooldown | s | 0.8 | 0.4 to 1.5 | Below 0.4 allows near-continuous dashing |
| Air dashes per jump | count | 1 | 1 to 2 | Two requires level review for gap sizes |
The table shows starting values for convenience, but the tuning file is the source of truth once the game runs. State this in the spec, or the table and file will drift apart.
Single source of truth
A value should be defined in exactly one place. Several arrangements work, and the best one depends on the team.
- Data file read by the game. Engineers load the YAML, JSON, or a spreadsheet export at startup. Designers change numbers without a code change. This is the most common choice.
- Engine-side assets. Many engines have editable data objects. The spec then names the asset instead of a file.
- Spec table only. Acceptable for a prototype, but engineers must copy numbers by hand, which invites mistakes.
Whichever you pick, make the spec say where the truth lives. If a number is hard-coded in the source, a designer cannot change it. Raise this with engineering during review.
Workflow when a value changes
The safe range turns a vague question ("do we need to tell everyone?") into a check. Inside the range, the designer changes the file and logs it. Outside the range, the change goes to review.
Acceptance criteria and tuning
Acceptance criteria should also avoid hard-coded numbers where the number is tuning. Compare:
Scenario: Dash is blocked during cooldown
Given the player has dashed less than the dash cooldown ago
When the player presses Dash
Then no dash startsThis scenario passes whether the cooldown is 0.8 or 1.2. QA reads the current value from the tuning file when they need an exact timing for a test. If the scenario used "0.8 seconds", it would fail every time the number changed, even though the feature worked.
There are exceptions. When the number itself is the requirement, such as a performance target, state it. "The dash starts within 100 ms of the button press" is a requirement on responsiveness, not a tuning knob.
Common mistakes
- Numbers in prose. A value written in a rule and again in the tuning file will diverge.
- Unnamed values. "Short cooldown" gives engineers nothing to name in code.
- No safe range. Without it, nobody knows when a change needs review.
- Tuning file with no owner. Decide who may edit it and who is told.
- Treating structural numbers as tuning. The party size example above is the typical case.
- Stale tables. Declare the file as the source of truth, or generate the table from it.
Exercises
Exercise
A spec rule reads: "After a dash, the player is immune to damage for 0.15 seconds." Rewrite it so the rule and the tuning value are separated. Then write the entry for the tuning file, using the style of dash_tuning.yaml.
Show answer
Rule: "After a dash starts, the player is immune to damage for the dash immunity duration." Tuning entry: under the dash section, add immunity_duration: 0.15 # seconds. A good answer also states when the immunity starts (here, at dash start) and notes a safe range, for example 0.05 to the dash duration, so immunity cannot outlast the dash by accident.
Exercise
A spec states speed is 18 units per second, duration is 0.2 seconds, and "the dash covers 3.6 units." A designer changes the duration to 0.25 seconds. What goes wrong, and how should the spec have been written?
Show answer
The distance becomes 4.5 units, but the spec still says 3.6, so the spec contradicts the game and anything built from the 3.6 figure, such as gap widths, may be wrong. The spec should state the relationship instead: "Dash distance is dash speed multiplied by dash duration." Any level requirement should refer to the dash distance, not to a fixed number.
Exercise
For each item, say whether it is a rule, a tuning value, or a structural number, and give a one-line reason: (a) the player can carry up to three keys, (b) the player cannot dash while carrying a heavy object, (c) the dash lasts 0.2 seconds.
Show answer
(a) Structural number if it drives UI slots or save data, so it goes in the spec marked as a constraint. If nothing else depends on it, it can be tuning. (b) Rule, because it changes when the feature is available. (c) Tuning value, because a different duration leaves the feature the same.