Sub topic 3
Objectives: what players are trying to achieve
An objective is the condition a player is trying to bring about in order to succeed in the game. This chapter assumes you have read the overview of formal elements and the chapter on players. You should also be comfortable reading short Python functions. By the end you should be able to separate an objective from a rule, write an objective that can be tested, and see how an objective changes the value of a move without changing anything else.
What an objective is
Every game gives players something to aim at. In chess it is checkmate. In Nim it is taking the last stone. In a cooperative game such as Pandemic it is curing all four diseases before the team loses. These aims are the objectives.
An objective does three jobs:
- It tells players what "winning" or "doing well" means.
- It gives moves their value. A move is good or bad because of how it affects the objective.
- It tells the game when to stop, because a game with a reachable objective can end.
The objective is a formal element, so it belongs to the structure of the game and not to its theme. "Escape the haunted house" is a theme. "Reach the exit tile with at least one key token before the timer track runs out" is an objective.
Objective versus rule
Beginners often mix up objectives and rules, and the two do different work.
- A rule limits or defines what players may do. "Take 1 to 3 stones per turn" is a rule.
- An objective states what players are trying to achieve. "Take the last stone" is an objective.
A useful check is to ask what happens if you break it. If you break a rule, you have cheated or made an illegal move. If you ignore the objective, you are still playing legally, but you are playing badly or you are not playing the game at all. A player who never tries to take the last stone in Nim breaks no rule. They simply lose.
| Question | Rule | Objective |
|---|---|---|
| What does it do? | Defines what is allowed | Defines what counts as success |
| What if a player ignores it? | The move is illegal or penalized | The player plays poorly |
| Does it end the game? | Sometimes, through an end condition | Yes, when it is reached |
| Example in Nim | Take 1 to 3 stones | Take the last stone |
The two connect at the point where the game checks whether the objective has been met. The rule that says "the game ends when the pile is empty" is what turns the objective into something the game can detect.
Kinds of objectives
Objectives come in several shapes. Many games combine them.
- Reach a state. Get a piece to a place or a board to a configuration. Checkmate, getting a token to the finish square, and completing a pattern are examples.
- Accumulate a quantity. Hold the most points, money, or territory when the game ends. This kind is common in Eurogames, where the winner is whoever has the highest score.
- Eliminate or survive. Remove opponents or outlast them. Battle royale games work this way.
- Race. Reach a state before the others do. Speed is the real contest even when the state itself is simple.
- Collective. All players win or lose together, as in cooperative games.
- Individual with a secret component. Each player has a hidden goal, as in games with secret roles or secret mission cards.
A game can also have layered objectives. A long-term objective such as "win the campaign" sits above short-term ones such as "capture this fortress". Short-term goals matter because they give players something to do on each turn. If players have only a distant objective, early moves can feel meaningless.
What makes an objective testable
A good objective is one that you could check with a function. Given a game state, the function returns whether the objective has been met and, in competitive games, for whom. If you cannot write that function, the objective is probably vague.
Compare these two statements:
- "Build the best city." This is not testable. "Best" depends on opinion.
- "Have the most points when the last building card is placed." This is testable. Points and the end trigger are both defined.
A clear objective has four properties:
- It is observable. Every player can see, or at least verify, whether it has been reached.
- It is unambiguous. Two players looking at the same state agree on the result.
- It is reachable. Some sequence of legal moves can satisfy it.
- It is decidable at a known time. The game specifies when the check occurs, at the end of each turn, at the end of the game, or immediately.
The fourth property causes more trouble than people expect. Suppose two players reach the objective during the same turn. If your rules do not say which check comes first, you have a tie-break problem hidden inside the objective.
Modeling an objective in code
The Nim model below separates the objective from the rules. The rules live in legal_moves and apply_move. The objective lives in winner, which looks at a state and returns the winning player's index or None.
from dataclasses import dataclass
PLAYERS = 2 # players: two alternating players
MAX_TAKE = 3 # rule: take 1 to 3 stones per turn
@dataclass(frozen=True)
class State:
stones: int # resource: a shared pile of stones
current: int # index of the player whose turn it is
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 winner(state):
# objective: take the last stone
if state.stones == 0:
return (state.current - 1) % PLAYERS
return NoneNotice that winner returns the player who moved before the current one. After a move empties the pile, apply_move has already advanced current to the next player, so the player who took the last stone is current - 1. This is a common source of off-by-one errors when you model objectives. The objective is stated in terms of who acted, while the state records whose turn comes next.
Notice also that winner is a pure function of the state. It does not change anything. That is a good design habit, because you can call it at any time to test whether the game is over.
How the objective drives play
Once the objective is fixed, the value of each move follows from it. The next example runs a full game and uses a simple strategy: leave the opponent a multiple of four stones.
def play(stones, choose):
state = State(stones, 0)
while winner(state) is None:
take = choose(state)
state = apply_move(state, take)
return winner(state)
def leave_multiple_of_four(state):
take = state.stones % 4
return take if take else 1
print(play(10, leave_multiple_of_four))This prints 0. The first player takes 2 stones from 10, which leaves 8. Both players then use the same strategy. The second player faces a multiple of four, so they take 1 and leave 7. The first player takes 3 and leaves 4, and the pile keeps shrinking until the first player takes the last stone.
The strategy works because of the objective together with the rule. Since a player can take at most 3, a pile of 4 is a loss for the player who faces it. Whatever they take, the opponent can finish the pile. Piles of 8, 12, and so on are losses for the same reason. The objective "take the last stone" is what makes 4 a bad number to face.
Changing only the objective
The clearest way to see what an objective does is to change it and hold everything else still. Here is the misère version of Nim, in which taking the last stone loses.
def winner_misere(state):
# objective changed: whoever takes the last stone loses
if state.stones == 0:
return state.current
return NoneThe players, the move limit, and the stone pile are all unchanged. Only the objective differs, and winner_misere now returns state.current, the player who did not take the last stone.
Moves that were good are now bad. Under the original objective, leaving a multiple of four is the winning plan. Under the misère objective, the winning plan shifts to leaving the opponent a pile of one more than a multiple of four (1, 5, 9, and so on). When the opponent faces a pile of 1, they must take it and lose.
This is the core lesson of the chapter. The rules did not change, yet the best strategy did. Objectives are what make rules matter in a particular way.
Common errors when specifying objectives
- Describing the theme instead of the goal. "Be the greatest merchant" does not tell players how success is measured. Replace it with a condition: "Hold 20 gold at the end of any round."
- Hiding the end check. If the objective is met in the middle of a turn but the rules check only at the end of the turn, players will dispute what happened.
- Unreachable or trivial objectives. If no legal sequence reaches the objective, the game cannot be won. If one player can reach it on the first move, there is no game.
- Conflicting objectives in one game. If a game gives two win conditions, say whether they are equal, which has priority, and what happens when both are met.
- Objectives that encourage no interaction with the rules. If a player can win by ignoring every rule except one, the other rules are decoration.
- Confusing score with objective. Points are usually a resource or a measure. The objective is "have the most points at the end". Keeping them separate lets you change the scoring without rewriting the goal.
A short procedure for writing an objective
- Name the unit that wins: one player, a team, or everyone together.
- State the condition as a measurable fact about the game state.
- State when the condition is checked.
- State what happens if several players meet it at once.
- Write the check as a function, even if only on paper, and run a few example states through it.
Step 5 finds most problems. If an example state leaves you unsure what the function should return, the objective needs more work.
Exercise
In the Nim model, the pile starts with 9 stones and each player may take 1 to 3. Under the misère objective (taking the last stone loses), which pile size should the first player leave for the opponent after their first move, and how many stones should they take?
Show answer
The first player should leave a pile of 1 more than a multiple of four. From 9 stones, leaving 5 means taking 4, which is not allowed. Leaving 1 would need taking 8, which is also not allowed. So the first player cannot reach such a pile and is in a losing position against perfect play. If they take 1, 2, or 3, they leave 8, 7, or 6. The best practical choice is to take 1 and leave 8, then hope the opponent makes a mistake. Note that 9 is itself 1 more than a multiple of four (8 + 1), which is why the player facing it is the one in trouble.
Exercise
A designer writes the objective "Players try to build the most impressive kingdom." List two problems with this objective and rewrite it so it can be tested.
Show answer
Problems: "most impressive" is subjective, so players could disagree about the result, and no moment is given for deciding. A testable rewrite is: "When the last province card is claimed, the player with the highest total of victory points wins. If players tie, the tied player with the most gold wins." This names a measurable quantity, a check time, and a tie-break.