Sub topic 5
Specifying a Verb: Preconditions, Costs, and Outcomes
Assume you understand a basic game loop or turn structure. You should also be comfortable reading simple pseudocode or Python. This chapter uses a verb in the game-design sense: an action the player chooses, such as grab, throw, or jump.
A verb specification turns a vague idea into a rule that the game can evaluate. A useful specification answers four questions:
- Precondition: When is the verb allowed?
- Cost: What does using it consume or risk?
- Cooldown: How long must the player wait before using it again?
- Outcome: What changes when the verb succeeds?
For example, “throw the crate” is incomplete. A precise version might say: the player can throw a crate while standing near it, the action costs 15 stamina, it cannot be repeated for one second, and the crate moves in the aimed direction.
Preconditions decide when a verb is legal
A precondition is a rule that must be true before the game accepts an action. Common preconditions include:
- The player is close enough to a target.
- The player has a required item.
- The player has enough health, stamina, or action points.
- The target is in a valid state.
- The verb is not on cooldown.
- The player is not already performing another incompatible action.
Preconditions should describe the game state, not the control used to request the action. Pressing a button is an input. “The player is within two meters of the crate” is a precondition.
from dataclasses import dataclass
@dataclass(frozen=True)
class Verb:
name: str
stamina_cost: int
cooldown: float
VERBS = {
"grab": Verb("grab", stamina_cost=5, cooldown=0.5),
"throw": Verb("throw", stamina_cost=15, cooldown=1.0),
}
def can_use(verb, stamina, now, last_used, near_target):
last = last_used.get(verb.name, float("-inf"))
off_cooldown = now - last >= verb.cooldown
enough_stamina = stamina >= verb.stamina_cost
return near_target and off_cooldown and enough_staminaThe function checks three preconditions: proximity, cooldown, and stamina. A real game would usually return a reason for failure as well as a Boolean result, so the interface can explain why the action did not work.
Costs and cooldowns shape decisions
A cost makes a verb compete with other uses of the same resource. If grabbing costs stamina, the player must decide whether the immediate benefit is worth losing stamina needed for movement or escape.
A cooldown limits frequency over time. Costs and cooldowns are different:
| Rule | Main question | Typical design effect |
|---|---|---|
| Cost | Can I afford this action? | Creates resource management |
| Cooldown | Can I use it again yet? | Controls timing and repetition |
| Both | Is this action affordable and available? | Creates stronger trade-offs |
Do not add a cost merely to slow the player down. The cost should support a decision. If players always have enough stamina, the cost is decoration. If the cooldown prevents all useful responses, the verb feels unreliable.
Outcomes should change the game state
An outcome is the observable result of a successful verb. State it as a change:
- The crate moves from one position to another.
- The lever changes from
offtoon. - The player gains a carried item.
- An enemy loses balance for two seconds.
Separate success from request. The player may request grab, but the game should resolve it only after checking the preconditions. This prevents invalid state changes, such as collecting an object through a wall.
Write each verb in a compact specification before implementing it:
- Name the verb.
- List the valid actor and target states.
- Define the resource cost.
- Define the cooldown.
- Describe the state change.
- Describe feedback for success and failure.
Exercise
The player can pull a lever only while nearby. Pulling it costs 3 stamina and has a 2-second cooldown. What are its precondition, cost, cooldown, and outcome?
Show answer
The precondition is that the player is near the lever and the verb is off cooldown with at least 3 stamina. The cost is 3 stamina. The cooldown is 2 seconds. The outcome is that the lever changes to its pulled state and triggers its connected game effect.