Sub topic 6
Covering States and Edge Cases
Assume you understand the roles of design, engineering, art, and QA, and that you have seen a game feature move through development. This chapter focuses on making a feature’s behavior precise when it changes state or receives unusual input.
Model the feature as states
A state describes what a feature is currently doing and which rules apply. A transition is a change from one state to another. A transition needs a trigger, such as player input, a timer, or damage.
For a dash ability, the main states might be:
- Ready: The player can start a dash.
- Dashing: The player is moving with dash behavior.
- Cooldown: The player cannot start another dash yet.
A state model prevents rules from being scattered across vague sentences. For each state, document:
- What the player can do.
- What the feature displays or plays.
- Which inputs are ignored or queued.
- Which events cause a transition.
- What data is reset or preserved.
State table
| State | Allowed input | Exit trigger | Result |
|---|---|---|---|
| Ready | Dash | Valid Dash press | Enter Dashing |
| Dashing | Movement input, if supported | Timer, wall hit, or damage | Enter Cooldown or Ready |
| Cooldown | No new dash | Cooldown timer ends | Enter Ready |
Define transitions precisely
A rule should identify the trigger, the condition, and the result. “The player can dash when available” leaves “available” undefined. A clearer rule is:
- When the player presses Dash, the system checks that the feature is in Ready.
- If the player is grounded, or has an unused air dash, the system enters Dashing.
- If neither condition is true, the input has no gameplay effect.
- When Dashing ends because its duration expires, the system enters Cooldown.
- When Dashing ends because of damage, the system enters Ready and does not start the cooldown.
The final rule matters because different interruptions can have different outcomes. Record those differences explicitly.
Find edge cases systematically
An edge case is an unusual situation that could expose an unclear rule. Review each transition with these questions:
- What if the trigger happens twice in one frame?
- What if two triggers happen together?
- What if the player enters a prohibited area?
- What if the required object, animation, or resource is missing?
- What happens when the feature is disabled, paused, or interrupted?
- Does the player keep progress, charges, or cooldown time after interruption?
- What happens at a boundary, such as exactly zero health or exactly one remaining charge?
Use a priority rule when events conflict. For example, “Damage cancellation takes priority over reaching the dash endpoint.” Without that statement, engineering and QA may implement or test different outcomes.
Make edge cases observable
Describe outcomes that QA can see or measure. “The dash handles walls correctly” is not testable enough. Specify the result:
- A wall collision ends Dashing on the collision frame.
- The player does not move through the wall.
- The dash charge is consumed.
- The player enters Cooldown only if the dash ended normally.
Avoid inventing behavior silently. If the design has not decided what happens when damage and a wall hit occur simultaneously, record it as an open question instead of hiding the ambiguity in implementation.
Exercise
A healing ability has Ready, Casting, and Cooldown states. What should a spec define for the case where the player takes damage during Casting?
Show answer
It should state whether damage cancels Casting, whether the resource is consumed, which state follows, and whether the cooldown starts. If the outcome is undecided, mark it as an open question rather than assuming a rule.