Sub topic 12
Outcome: how a game resolves
This chapter assumes you know the other formal elements (players, objectives, rules, resources) and can read short Python. The earlier chapters defined what players are trying to do and what limits them. This one covers the last step: how the game decides that play is over and what that ending means for each player.
What an outcome is
An outcome is the result a game assigns to each player when play stops. It is a function of the final state of the game and the objectives. The rules fix when play stops, and the objectives fix how to read the final state.
Three terms need separating:
- Objective: what a player is trying to achieve ("take the last stone").
- End condition: the rule that stops play ("the pile is empty").
- Outcome: the result assigned to each player once play has stopped ("player 0 wins, player 1 loses").
An objective is a goal players pursue during play. An outcome is a verdict the game delivers after play. A player can pursue an objective and fail to reach it, so the outcome is what actually happened.
Terminal states and end conditions
A game state is terminal if no further moves are possible or the rules declare play finished. Every game needs at least one reachable terminal state, or it never resolves. Common end conditions are:
- A target state is reached (checkmate, a captured flag, a finished track).
- A resource runs out (an empty pile, an empty deck, no turns left).
- A limit is reached (a time limit, a round limit, a score threshold).
- A player can no longer act (no legal moves, elimination).
- Players agree to stop (a draw offer, a surrender).
State the end condition as a test on the state, so you can check it mechanically. "The game ends when it feels finished" is untestable. "The game ends when the draw pile is empty at the end of a round" is testable.
Sudden end versus accumulated end
Some games end the moment a condition is met. Others end on a condition but then compute the result from accumulated data, such as a final scoring phase. These differ in what players can do about the ending.
| Style | Example | Outcome known when | Effect on play |
|---|---|---|---|
| Sudden | Chess checkmate, Nim | The terminal move is made | Players track the exact threat of ending |
| Accumulated | Point-scoring board games | After final scoring | Players optimize totals and may misjudge who is ahead |
| Threshold race | First to 10 points | The first player reaches the threshold | Leader pressure and tempo matter |
| Timed | Fixed number of rounds | The last round ends | Players plan for the known horizon |
A known horizon changes behavior. When players know the last round is coming, they spend resources they would otherwise save, because saved resources are worth nothing after the end. That is the rules and resources elements feeding back into outcome.
Kinds of outcome
The objectives determine which kinds of outcome are possible. Four patterns cover most games.
| Kind | Result shape | Example |
|---|---|---|
| Win/loss | One winner, the rest lose | Nim, chess |
| Draw | No winner, or a shared result | Chess stalemate |
| Ranking or score | Ordered places or numeric totals | Racing games, point-scoring board games |
| Shared (cooperative) | One result for the whole team | A co-op game where everyone wins or loses together |
A draw deserves its own rule. If your game can reach a position where nobody can win, say what happens there. Chess uses stalemate and repetition rules for this. If you leave it out, the game has a terminal-state gap.
A ranking raises a question the win/loss form hides: do players care about second place? If only first place matters, the later places are just losses, and players behind have little reason to keep playing carefully. If every place carries a reward, trailing players still have decisions that matter.
In a cooperative game the outcome applies to a team, so players share one result. The tension then moves from "who wins" to "do we win", and the game often has a scalable difficulty.
Modeling outcome in code
The Nim model from earlier chapters can name each part of this chapter separately. The code below separates the end condition (is_terminal) from the outcome (outcome). It also adds a misere flag, so you can see that changing the objective changes the outcome without touching the rules.
from dataclasses import dataclass
PLAYERS = 2
MAX_TAKE = 3
@dataclass(frozen=True)
class State:
stones: int
current: int
def legal_moves(state):
return list(range(1, min(MAX_TAKE, state.stones) + 1))
def apply_move(state, take):
if take not in legal_moves(state):
raise ValueError("illegal move")
return State(state.stones - take, (state.current + 1) % PLAYERS)
def is_terminal(state):
# end condition: the pile is empty
return state.stones == 0
def outcome(state, misere=False):
# outcome: a verdict for every player, or None while play continues
if not is_terminal(state):
return None
last_taker = (state.current - 1) % PLAYERS
other = state.current
winner = other if misere else last_taker
return {winner: "win", 1 - winner: "loss"}
def play(stones, choose, misere=False):
state = State(stones, 0)
while not is_terminal(state):
state = apply_move(state, choose(state))
return outcome(state, misere)
always_one = lambda state: 1
print(play(5, always_one))
print(play(5, always_one, misere=True))The play-through is identical in both calls: player 0 takes the last stone. The first call prints {0: 'win', 1: 'loss'} and the second prints {1: 'win', 0: 'loss'}. The same final state produces different outcomes because the objective changed.
Notice what outcome returns while the game continues: None. A game that has no verdict yet should not return a made-up result.
Ties and tie-breakers
Score-based games produce ties. A tie rule is a rule, so it needs the same precision as any other rule. Options are:
- Accept the tie as a shared result.
- Apply an ordered list of tie-breakers (leftover resources, fewer turns taken, a secondary score).
- Replay or extend the game (sudden-death overtime).
The code below ranks players by score, then by a tie-breaker. Players who tie on both share a rank.
def rank(scores, tiebreaks):
keys = {p: (scores[p], tiebreaks[p]) for p in scores}
order = sorted(keys, key=lambda p: keys[p], reverse=True)
places = {}
place = 0
for i, player in enumerate(order):
if i == 0 or keys[player] != keys[order[i - 1]]:
place = i + 1
places[player] = place
return places
print(rank({"A": 10, "B": 10, "C": 7}, {"A": 2, "B": 3, "C": 0}))
print(rank({"A": 10, "B": 10, "C": 7}, {"A": 2, "B": 2, "C": 0}))The first call prints {'B': 1, 'A': 2, 'C': 3}: B wins the tie-break. The second prints {'A': 1, 'B': 1, 'C': 3}: A and B share first place and C is third. Each tie-breaker is a design decision. A tie-breaker that rewards something players can easily game, such as leftover resources, changes how they play the whole game.
The resolution loop
Most games check for resolution after every action. The diagram shows the usual cycle.
The order matters. The state updates before the end check, and the outcome is computed from the final state, not from the last action alone. If a single action can both satisfy two players' objectives at once, you need a rule for which one counts. Some games solve this with a priority order, such as "the active player wins ties".
Edge cases and failure modes
Non-terminating games
A game can loop forever if players can repeat positions and no rule stops them. Chess has repetition and move-count rules for this reason. In your own designs, check that every play sequence either reaches a terminal state or is cut off by a limit. A round counter is the cheapest guard.
Stalemate and no legal moves
When a player has no legal moves, the rules must say what happens: skip the turn, lose, or end in a draw. If the rules are silent, the game stops working at that point.
Kingmaking
A kingmaker is a player who can no longer win but can decide which other player does. This happens in games with three or more players when the trailing player's last decision favors one rival. It is an outcome problem: the outcome depends on a player who has no stake in it. Fixes include reducing late-game choices that target specific players, or giving trailing players their own reachable goal, such as a secondary ranking.
Early decided games
A game can be decided long before it ends. If the outcome is certain at turn 10 of 30, the remaining turns carry no tension. Designers address this with catch-up mechanics, a shorter end condition when a lead is large, or a concession rule. A concession is a rule that lets a player end the game by forfeiting.
Hidden outcomes
If players cannot tell who is winning until final scoring, they may play poorly or feel cheated. Showing progress toward the outcome during play, such as a visible score track, helps.
Outcome and the other elements
Outcome ties the earlier elements together:
- Players decide the shape of the outcome: one winner, a ranking, or a shared result.
- Objectives supply the evaluation: what counts as a good final state.
- Rules supply the end condition and the tie-breakers.
- Resources often trigger the end (an empty pile) or provide the tie-breaker (leftovers).
Changing any one of these changes outcomes elsewhere. The misère change above altered only the objective, yet it reversed who wins and, in Nim, reverses which moves are good.
Specifying an outcome clearly
A usable outcome specification answers these questions:
- What exactly ends the game? State it as a test on the state.
- Can the game end in a way that no objective covers? If so, what happens?
- What is the result shape: win/loss, draw, ranking, or shared?
- How are ties broken, in what order?
- What happens when a player has no legal moves?
- Can every play sequence reach an end, or is there a guard?
Exercise
In the Nim code, outcome returns None when the pile is not empty. Suppose you add a rule that the game also ends after 20 turns, and in that case player 1 wins. Which functions must change, and which can stay the same?
Show answer
is_terminal must change, because the end condition now includes "20 turns played", and State needs a turn counter for that test. outcome must change because a turn-limit ending needs its own verdict (player 1 wins) in addition to the last-taker rule. legal_moves and the stone-taking part of apply_move can stay the same, though apply_move must increment the turn counter. The players, resource, and move-limit rule are unchanged. Only the end condition and the outcome mapping change.
Exercise
A three-player scoring game ends after eight rounds. In the last round, player C is far behind but chooses whether to give a bonus to A or to B, who are tied for first. Name the problem and give one design fix.
Show answer
This is kingmaking: C cannot win, yet C's choice decides the outcome. One fix is to give C a reachable goal, such as a ranking where third place is better than last, so C's choice is about C's own result. Another fix is to remove or limit choices in the final round that favor a specific rival.