Sub topic 2
Designing Clear Win Conditions
This chapter assumes you know the core gameplay loop of a game, can read short Python functions, and have played several genres. It covers what makes a win condition clear, the common types, how to make one measurable, and the errors that make wins confusing or hollow.
What a win condition is
A win condition is a rule that, once satisfied, tells the game the player has succeeded and the run should end in victory. It has two parts: a goal the player can understand, and a test the game can evaluate. If either part is missing, the win feels arbitrary. A goal without a test can't be shipped. A test without a goal leaves the player wondering why the game just ended.
A good win condition does three jobs:
- It gives the player direction. Every decision in the core loop can be judged against it.
- It gives the game a precise moment to stop and celebrate.
- It defines what "playing well" means, so mechanics, level layout, and rewards can all be tuned toward it.
Win conditions differ from fail states and lose conditions, which later chapters cover. Here the question is only: what must be true for the player to succeed?
Common types of win condition
Most games use one of a small set of patterns, often combined.
| Type | The player wins when... | Typical examples |
|---|---|---|
| Reach a place | They arrive at a location | Platformers, racing finish lines, escape rooms |
| Collect | They gather enough of something | Relic hunts, coin challenges |
| Eliminate | Opponents or threats are gone | Shooters, tower defense waves |
| Survive | They last a set time or number of waves | Horde modes, survival games |
| Accumulate | A score or resource passes a threshold | Arcade scoring, city builders with population goals |
| Complete a sequence | A set of ordered tasks is done | Quest chains, puzzle games |
| Reach a state | The world matches a target configuration | Sokoban, sliding puzzles, "connect all nodes" |
The examples in this tutorial use a collect condition: the player wins after gathering a number of relics. It is simple enough to show the structure clearly, and the same structure applies to the other types.
Clear means observable, measurable, and communicated
Intermediate designers usually get the idea of a goal right and still ship a vague one. Check any win condition against three properties.
- Observable. The player can see progress toward it. A relic counter in the HUD (heads-up display, the on-screen overlay for status information) makes a collect goal observable. A hidden counter does not.
- Measurable. The game can evaluate it with a definite test, such as
relics >= relics_needed. "Make the village feel safe" is a theme. "Reduce active raiders to zero" is a condition. - Communicated. The player learns the goal early, in words, visuals, or level design, and is reminded when it matters.
A useful exercise is to write the condition as one sentence in the form "You win when ___." If the blank takes a paragraph, the condition is probably several conditions bundled together, or a theme in disguise.
Writing the condition as code
Writing the test as code forces precision. Here is the evaluation function from the shared example. It maps game state to one of three outcomes.
from enum import Enum, auto
class Outcome(Enum):
PLAYING = auto()
WON = auto()
LOST = auto()
def evaluate(health, relics, relics_needed):
# Check the lose condition first, so a simultaneous win and loss
# resolves as a loss. Reverse the order to favor the player.
if health <= 0:
return Outcome.LOST
if relics >= relics_needed:
return Outcome.WON
return Outcome.PLAYINGThree details in this small function matter for win design.
- The comparison is
>=, not==. If the player can pick up two relics in one frame and the target is five, a count of four jumping to six would never equal five. Equality tests on counters that can skip values are a classic bug that leaves the game unwinnable. - The function returns a value instead of ending the game itself. Separating the decision from the reaction lets you test the rule without running the whole game, and lets the presentation layer decide how to celebrate.
- The order of the checks is a design decision. As written, a player who grabs the final relic on the same frame their health reaches zero loses. Moving the relic check first would grant the win. Neither is correct in general. Pick one on purpose and tell your team.
Here is a quick check of the behavior, which you can run as written together with the code above.
print(evaluate(health=3, relics=2, relics_needed=5)) # Outcome.PLAYING
print(evaluate(health=3, relics=5, relics_needed=5)) # Outcome.WON
print(evaluate(health=0, relics=5, relics_needed=5)) # Outcome.LOST (tie goes to loss)
print(evaluate(health=2, relics=6, relics_needed=5)) # Outcome.WON (overshoot still wins)Choosing the threshold
The number in a win condition is a tuning value. If five relics are needed, the whole pacing of a level follows from that choice. Three questions help set it.
- How long should the run be? Estimate the time per relic, including travel and risk, and multiply. If a relic takes about two minutes and you want a ten-minute level, five is a reasonable start.
- Is the count meaningful? Collecting 100 identical items turns the goal into a chore. Fewer, more distinct targets give each pickup weight.
- Does the number scale? If the goal changes by level or difficulty, store it as data, as the
relics_neededparameter does, rather than hard-coding it.
Treat the first number as a guess. Playtesting, covered in a later chapter, is how you correct it.
Single, multiple, and layered goals
Games often combine goals. Three structures are common.
- Single goal. One test ends the game. This is the clearest option and works well for short experiences.
- Alternative goals (any of). Several routes each lead to victory, such as winning a strategy game by conquest or by diplomacy. This supports different playstyles but requires each route to be communicated and balanced.
- Required goals (all of). Several tests must hold together, such as "collect five relics and reach the exit." This adds structure but raises a communication cost: the player must know which parts are done.
The diagram below shows a layered win condition where the player must satisfy two requirements before the game declares victory.
Notice that the exit unlocking is itself feedback. The game turns an invisible internal test into a visible change in the world, which makes the second step easy to understand.
Common errors
The hidden condition
The game ends in victory, but the player did not know the goal. This often happens when designers know the rules so well that they forget to teach them. Fix it by stating the goal in the first minute and keeping a progress indicator visible.
The unreachable condition
The test can never be true because of a bug or an oversight. Examples include an == check that gets skipped, a required item that can be destroyed or lost, or a relic placed behind a door that needs a key the player can no longer obtain. Defend against this by checking that the total supply of what the player needs always exceeds the requirement, and by testing soft locks, states from which the game cannot be completed.
The ambiguous tie
Two conditions become true together, and the outcome is undefined or inconsistent. The precedence rule in evaluate handles this for win and lose. For multiple win conditions, decide which one is reported. Document the rule so the behavior does not change by accident when someone reorders the code.
The moving goalpost
The condition changes mid-game without warning, such as a boss that revives after the player thought they had won. A fake-out can be a valid story beat, but it must not cancel progress feedback the game already gave. If you do it, signal the change clearly.
The hollow win
The condition is met, but the player feels nothing. Common causes are a goal that is too easy, a goal unrelated to the skill the game builds, or an abrupt end with no acknowledgment. A win should follow effort the player can recall. Feedback and presentation of outcomes get their own chapter, but at minimum, mark the moment visibly and audibly.
The dominant strategy exploit
A cheap action satisfies the condition faster than the intended play. If the goal is "reach the exit," a player who finds a way to skip the level has won in a way the design did not intend. Whether to block it depends on the game. In a speedrun community, it may become celebrated. In a puzzle game, it removes the point. Decide deliberately.
Matching the condition to the game's fantasy
A win condition tells the player what the game is about. A stealth game that ends when you reach the exit, regardless of whether you were seen, tells players that stealth is optional. If the point of the game is quiet infiltration, add a stealth requirement or a ranking that rewards it. A good test is whether a player who follows the win condition literally ends up doing the thing the game was meant to be about. If not, the condition and the fantasy disagree, and players will follow the condition.
Design checklist
Use this list when you review a win condition.
- Can you state it in one sentence starting "You win when"?
- Can the player see progress toward it at any time?
- Does the code use a comparison that cannot skip the target?
- Is the total supply of required items always at least the requirement?
- Is the order of simultaneous outcomes defined and documented?
- Is the threshold stored as data so it can be tuned?
- Does meeting the condition require the skill the game is about?
- Does the game mark the moment of victory clearly?
Exercise
A level requires five relics to win. Your code checks relics == relics_needed. A new double-relic pickup lets players gain two relics at once. A tester at four relics grabs a double pickup and nothing happens. What is wrong, how do you fix it, and what other check on the level data should you add?
Show answer
The player now holds six relics, which skips over the exact value five, so the equality test never becomes true and the game cannot be won. Change the test to relics >= relics_needed. Also verify that the level's total relic supply is at least the requirement, and check that no sequence of events can destroy or strand relics so that the supply falls below five.
Exercise
In the evaluate function, the player collects the last relic on the same frame their health reaches 0. State the result, then describe how you would change the function to give the player the win, and give one design reason to prefer each ordering.
Show answer
As written, the result is Outcome.LOST because the health check runs first. To favor the player, move the relics >= relics_needed check above the health <= 0 check. Loss-first suits games where the stakes are tense and the designer wants "you must survive to win" to be strict. Win-first suits games where players would feel cheated after clearly completing the goal, and it forgives frame-level timing the player cannot perceive.
Exercise
Write a one-sentence win condition for a stealth game whose fantasy is "never be seen," and name one way a player could satisfy a poorly written version while ignoring that fantasy.
Show answer
"You win when you reach the exit without having been detected by any guard." A poorly written version, "You win when you reach the exit," lets a player sprint through alarms and combat to the exit, which satisfies the condition while ignoring stealth.