Sub topic 11
Outcomes in Multiplayer and Competitive Games
This chapter assumes you know the difference between win, lose, and fail states. It also assumes you can read simple Python conditionals and functions, and that you have seen the outcome state machine from earlier in this tutorial. Here we extend those ideas to games with more than one player. Multiplayer changes the problem in three ways. One player's win can be another player's loss. Outcomes can be partial, shared, or contested. Some outcomes must be decided by a server, not by a single local game.
Why multiplayer changes outcome design
In a single-player game, the game is the opponent. The player wins or loses against rules and systems, and the designer controls both sides of the contest. In a multiplayer game, other people supply much of the challenge, and the outcome depends on what they do.
Three questions come up that a single-player design rarely has to answer:
- Who is the outcome for? Each player, each team, or the whole match may have its own result.
- Are outcomes zero-sum? In a zero-sum game, one side's gain is exactly the other side's loss. In a non-zero-sum game, several sides can gain or lose together.
- Who decides? Each client (the program on a player's device) may see a slightly different game. Something must declare one result that everyone accepts.
The rest of the chapter works through these questions.
Outcome structures
The structure of a game's outcomes shapes how players behave. The common structures are below.
| Structure | How it ends | Example | Main design risk |
|---|---|---|---|
| Head-to-head | One winner, one loser, or a draw | Chess, a fighting game round | Draws and stalling |
| Free-for-all | One winner, many losers, often ranked | Battle royale, racing | Early losers wait with nothing to do |
| Team versus team | One team wins, the other loses | Capture the flag, 5v5 shooters | Blame inside a team, one weak player |
| Cooperative | The whole group wins or loses together | Raid bosses, survival games | One player carrying, or one quitting |
| Asymmetric | Sides have different goals and win conditions | One hunter against four survivors | Balancing two unlike objectives |
| Ranked placement | Everyone gets a position or score | Racing finishes, score attack | Players ignore the objective to chase score |
A single game can combine structures. A team shooter is team versus team overall, but each player also sees a personal score.
Win conditions for several sides
A multiplayer win condition has to be checked for each side, and the checks can interact. Two sides may satisfy their win conditions on the same tick (one update step of the game). That is the multiplayer version of the simultaneous win and loss problem from the state machine chapter.
You have three main ways to resolve it:
- Precedence. Define a fixed order. For example, the defending team's loss check runs first, or the side that reached the goal earlier in the tick wins.
- Tiebreaker. Compare a secondary measure such as score, damage dealt, or time to objective.
- Draw. Declare no winner. This is honest but can feel unsatisfying, so many games add an overtime or sudden-death round.
The code below evaluates a two-team capture game. It handles simultaneous completion with a tiebreaker and then a draw.
from enum import Enum, auto
class Result(Enum):
ONGOING = auto()
TEAM_A_WINS = auto()
TEAM_B_WINS = auto()
DRAW = auto()
def evaluate_match(score_a, score_b, target, time_a, time_b):
"""Decide a two-team match.
time_a and time_b are the times each team reached the target,
or None if the team has not reached it.
"""
a_done = score_a >= target
b_done = score_b >= target
if a_done and b_done:
# Both reached the target in the same update.
# First tiebreaker: who got there first.
if time_a < time_b:
return Result.TEAM_A_WINS
if time_b < time_a:
return Result.TEAM_B_WINS
# Second tiebreaker: higher final score.
if score_a > score_b:
return Result.TEAM_A_WINS
if score_b > score_a:
return Result.TEAM_B_WINS
return Result.DRAW
if a_done:
return Result.TEAM_A_WINS
if b_done:
return Result.TEAM_B_WINS
return Result.ONGOING
print(evaluate_match(10, 10, 10, 41.2, 40.8))
print(evaluate_match(10, 7, 10, 41.2, None))
print(evaluate_match(5, 5, 10, None, None))The first call prints Result.TEAM_B_WINS because team B reached the target 0.4 seconds earlier. The second prints Result.TEAM_A_WINS. The third prints Result.ONGOING.
Whatever rule you pick, publish it. Players accept a strict tiebreaker much more readily when the rules screen states it than when they discover it after a loss.
Lose conditions and elimination
In multiplayer, a lose condition for one player is often not the end of the match. This creates the elimination problem: a player who is out must wait for others to finish.
Common responses:
- Short matches. If rounds last under two minutes, waiting costs little.
- Respawn. Eliminated players return after a delay, which turns a lose state into a fail state for that player. The match itself still has a win condition.
- Spectating. Eliminated players watch teammates or opponents, ideally with useful camera tools.
- Ghost roles. Eliminated players can still help in a limited way, such as marking enemies or placing traps.
- Fast requeue. The player can leave and join a new match immediately.
Respawning shows how fail and lose states relate in multiplayer. An individual death is a fail state: the player loses time and position and then returns. The team's loss is a separate, higher-level state. Keep the two layers apart in your design and in your code.
Layered outcomes
Most multiplayer games track outcomes at more than one level at once. Each level has its own state machine.
A player's death changes only the first layer, and only until the respawn timer ends. A round result feeds the match, and the match result feeds the rating. Each layer needs its own win condition, its own precedence rules, and its own feedback to the player.
Team outcomes and shared blame
When a team shares one result, individual players need a way to see their own contribution. Without it, a strong player on a losing team gets no reward, and a weak player on a winning team gets credit they did not earn. Both cases weaken the link between effort and result.
Ways to handle this:
- Personal metrics next to the team result. Show damage, objectives completed, and assists on the results screen.
- Partial rewards for losers. Give some progression for a loss so that effort always counts for something.
- Most valuable player recognition. Name standout players on both teams.
- Careful language. A message like "Your team was defeated" frames the loss as collective. A message that singles out one person invites blame and toxic behavior.
Be cautious with individual statistics. If players see a kill count, they may chase kills instead of the objective. The metrics you display tell players what you value, so display the ones that match the win condition.
Edge cases that only exist with other people
These cases are common in live games and need explicit rules.
Disconnection and abandonment
A player who leaves mid-match breaks the fairness of the result for everyone else. Options include:
- Replace the player with a bot.
- Let the match continue short-handed, with a penalty to the leaver.
- Cancel the match without rating changes if it is early enough.
- Give a win to the remaining team if the opposing side forfeits.
Decide on a grace period after a disconnect, since connections often return within seconds. Track the leaver's state as its own value, such as DISCONNECTED, so the outcome logic can treat it differently from DEAD.
Forfeit and surrender
A surrender option lets a team end a hopeless match. It shortens the match for everyone but can be abused or trigger early. Typical safeguards are a minimum match time and a vote threshold, for example a majority of the team.
Stalling and degenerate strategies
If a lead can be protected by doing nothing, a leading player or team may stall. Designers counter this with a match timer, shrinking play areas, rising stakes over time, or an overtime rule. Always ask what a player in the lead should do, and make sure the answer is "keep playing the game."
Kingmaking
In a free-for-all, a player who cannot win may decide who does. Their choices then reflect their mood or friendships and not skill. Reducing it is hard. Common mitigations are hiding some information, ending the match sooner for eliminated players, and scoring so that all positions matter.
Authority and cheating
When results affect ranking, the final outcome should come from a trusted source, usually the server. A client can report what it saw, but the server decides. The state machine from earlier chapters then runs on the server, and clients receive the result.
class MatchAuthority:
"""The server owns the outcome. Clients only report events."""
def __init__(self, players):
self.players = set(players)
self.result = None # Set once, then final.
def report_win(self, player):
if self.result is not None:
return self.result # Ignore late or duplicate claims.
if player not in self.players:
raise ValueError("unknown player")
# In a real game, verify the claim against server state here.
self.result = ("WIN", player)
return self.result
match = MatchAuthority(["ana", "ben"])
print(match.report_win("ana"))
print(match.report_win("ben"))Both calls print ('WIN', 'ana'). The second claim arrives after the result is fixed, so it is ignored. Making the result write-once avoids two clients each believing they won.
Ratings and the meaning of a loss
In competitive games, the outcome often feeds a rating system, a number that estimates a player's skill. The match result moves the number. Here the stakes of a loss are social and long-term, which connects to the earlier chapter on stakes.
Several design points follow:
- Match quality. Matchmaking that pairs players of similar skill keeps outcomes uncertain. A match whose result is obvious teaches nothing and feels unfair to both sides.
- Win rate near 50 percent. When pairing is good, most players win about half of their matches. A player who loses much more than that for a long stretch is likely to quit.
- Loss protection. Some games reduce or remove rating loss in the first matches, or after a long losing streak.
- Transparency. Showing how much rating a match was worth helps players see a loss as fair.
This is also where adaptive help appears in competitive form. You cannot quietly make the game easier for one human without making it harder for another, so competitive games adapt through matchmaking and not through changing the rules for one side.
Playtesting multiplayer outcomes
Multiplayer outcome rules need a different kind of test than single-player ones. Check these:
- Sample size. One match tells you little. Gather many matches and look at win rates by side, map, and role.
- Side balance. In an asymmetric or two-sided map, if one side wins well beyond a balanced rate over many matches, the design or map favors it.
- Match length. Compare how long matches last. A long tail of very long matches often means stalling.
- Quit rate. Track at what point in a match players leave. Spikes after a particular event show where a loss feels decided too early.
- Edge-case drills. Deliberately test ties, simultaneous completion, disconnects at the final second, and surrender votes.
Common mistakes
- Resolving ties by accident, because two checks run in whatever order the code happened to be written.
- Using one state for both "dead until respawn" and "eliminated for the match."
- Showing individual statistics that reward behavior opposed to the win condition.
- Trusting the client for the final result.
- Giving eliminated players nothing to do for long periods.
- Leaving disconnect handling for after launch.
Exercise
Two teams in a capture game both reach the target score in the same update, with equal final scores and equal completion times. Using the evaluate_match function from this chapter, what is the result, and name two design options that would avoid ending in that result?
Show answer
The result is Result.DRAW, because every tiebreaker is equal. The design could add an overtime or sudden-death round so that a winner is always found, or add a further tiebreaker such as total damage dealt or objective progress. A fixed precedence rule, such as the defending team winning ties, would also remove the draw.
Exercise
In a five-player team game, a player dies and returns after a ten-second respawn timer. Another player's connection drops and does not return. Which of these is a fail state and which should be handled as a separate state, and why does the distinction matter for the match outcome?
Show answer
The death is a fail state because the player is set back and then recovers. The dropped connection should be tracked as its own state, such as DISCONNECTED, because it does not recover on a timer and may need a bot replacement, a penalty, or a canceled match. If both were stored as one "out" state, the outcome logic could not apply the right rule to each.