Sub topic 7
How players, objectives, rules, and resources shape each other
This chapter assumes you know what each formal element is from the earlier chapters: players, objectives, rules, and resources. It also assumes you can read short Python functions. Here the focus changes from definitions to dependencies. In a working game the four elements constrain one another, so changing one often changes what the others mean.
Why the elements cannot be tuned independently
A game design is a set of linked decisions, not a checklist. Each element answers a different question:
| Element | Question it answers |
|---|---|
| Players | Who makes decisions, and how many of them are there? |
| Objective | What counts as success for a player? |
| Rules | Which actions and states are allowed? |
| Resources | What do players hold, spend, or compete for? |
None of these answers is complete alone. An objective such as "take the last stone" is meaningless until rules say how stones are taken. Rules about taking stones are meaningless until a resource (the pile) exists. The pile only creates tension when at least two players want something from it.
You can think of each element as supplying a different kind of constraint:
- Rules limit which actions exist.
- Resources limit how much of each action is possible.
- Objectives rank the outcomes, so some actions become better than others.
- Players decide which action actually happens.
Design problems usually come from a mismatch between these layers. A common example is an objective that no available action can advance, so players have nothing meaningful to decide.
The dependency map
Some influences are close to one-way. Other influences flow back. The diagram below shows the main ones.
Three things stand out in this map.
- Actions come from rules and resources together. Rules say what is permitted, and resources say what is affordable or available. In Nim, the rule "take 1 to 3" and the resource "stones remaining" jointly produce the legal moves.
- The objective does not produce actions. It produces preferences among outcomes. This is why changing an objective can change strategy without touching a single rule.
- Players are where all of it becomes behavior. The number of players changes whether a decision is a puzzle (one decision-maker against the system) or a strategic contest, where each choice depends on what others are likely to do.
Rules and resources: the action space
Look again at the legal-move function from the Nim model.
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 NoneThe expression min(MAX_TAKE, state.stones) shows the two elements meeting. The rule contributes MAX_TAKE. The resource contributes state.stones. When the pile is large, the rule is the binding limit. When the pile is small, the resource is. A good way to analyze any game is to ask, for each action, which element is currently the binding constraint. That tells you which element to adjust if you want more or fewer options.
Rules also determine how a resource may change hands. In Nim the only conversion is "pile to nothing." In a trading game, rules might let a resource of one type become another. The resource inventory stays the same while the rules decide how much of it can flow.
Objectives and rules: what the rules are for
An objective gives rules a purpose, and rules make an objective achievable. Check both directions when you design:
- Can the objective be reached through legal actions? If not, the game cannot end in a win.
- Do the rules allow a shortcut that reaches the objective too easily? If so, the middle of the game has no decisions.
The winner function is the objective. It reads only the state, so the objective is testable: given any state, it returns a player or None. If you cannot write a function like this for your objective, the objective is probably vague.
Players and objectives: what players want
An objective only shapes behavior through players. Two points matter here.
First, player count changes what an objective means. In a two-player game "win" and "the opponent loses" are the same thing. With three or more players they separate. A player who cannot win may still choose who does, which designers call kingmaking. The Nim analysis below relies on there being exactly two players, since every position is then simply good or bad for the player to move.
Second, players may not share an objective. Competitive games give each player an opposed objective. Cooperative games give one shared objective. Mixed designs give each player a private objective plus a shared one. The same rules and resources can support all three, but the decisions that result will be very different.
An experiment: change one element at a time
The best way to see the coupling is to hold three elements fixed and change one. The solver below labels each stone count as a win or loss for the player about to move, assuming both players choose perfectly. It takes the rule (max_take) and the objective (misere) as parameters.
from functools import lru_cache
def losing_positions(max_stones, max_take, misere):
"""Stone counts where the player to move loses with best play."""
@lru_cache(maxsize=None)
def mover_wins(n):
if n == 0:
# Normal play: the previous player took the last stone and won,
# so the mover loses. Misere play: the mover wins.
return misere
return any(not mover_wins(n - t)
for t in range(1, min(max_take, n) + 1))
return [n for n in range(1, max_stones + 1) if not mover_wins(n)]
for max_take in (3, 2):
for misere in (False, True):
goal = "last stone loses" if misere else "last stone wins"
print(max_take, goal, losing_positions(12, max_take, misere))Running it prints:
3 last stone wins [4, 8, 12]
3 last stone loses [1, 5, 9]
2 last stone wins [3, 6, 9, 12]
2 last stone loses [1, 4, 7, 10]Read the rows as follows.
- Changing the rule from
max_take = 3tomax_take = 2moves the losing positions from multiples of 4 to multiples of 3. The objective did not change, yet the key number in the strategy did. - Changing the objective alone shifts the losing positions by one stone. In the "last stone loses" version, the player to move loses at 1, 5, and 9 under the three-stone rule. The rule and resource are identical.
- Starting with 12 stones, the first player loses under both "last stone wins" rows, but wins in the misere rows. That is a resource and objective interaction: the same starting pile favors different players.
The first strategy function from the Nim model works only for the original objective:
def leave_multiple_of_four(state):
take = state.stones % 4
return take if take else 1It leaves the opponent a multiple of four. Under the misere objective, that is the wrong target. A player using it would hand over a position that is no longer losing. The strategy depends on the objective, the rule limit, and the resource count together.
What each change affects
You can use the experiment as a template for change analysis. Make one change, then trace its effects through the other elements.
| Change | Direct effect | Knock-on effect |
|---|---|---|
| Raise `MAX_TAKE` | More legal moves per turn | Losing positions move to multiples of a larger number, and games get shorter |
| Reverse the objective | Different outcomes rank highest | Good moves change, and rules and resources stay the same |
| Add a third player | The turn order has three seats | "Mover loses" no longer defines a good or bad position, and kingmaking appears |
| Give each player a private pile | Resources are no longer shared | Players stop affecting each other's options, so interaction nearly disappears |
| Hide the pile size | Players cannot compute the state | Strategy becomes estimation, and the game turns into one of incomplete information |
Notice the fourth row. A resource change removed an interaction pattern. This is why resource ownership (shared or private) deserves as much attention as resource quantity.
Common errors when analyzing coupled elements
- Treating a rule as an objective. "You must take at least one stone" is a rule. "Take the last stone" is the objective. A test: an objective can be satisfied or not at the end of the game, while a rule is checked at each action.
- Changing several elements at once. If you change the pile size, the move limit, and the objective in one pass, you cannot tell which change moved the balance. Change one, observe, then change the next.
- Assuming a fix in one element stays local. A rule added to stop a degenerate strategy can also remove a legitimate one. Re-run your analysis on all four elements after each change.
- Forgetting player count in the analysis. A strategy proven for two players says nothing about three.
- Confusing an unreachable objective with a hard one. A hard objective has a path through legal actions. An unreachable one has none. Check this by searching for a legal sequence that ends in the objective.
A short procedure for tracing a change
- State the change in one sentence, naming the single element you altered.
- List the legal actions before and after. This shows the effect on rules and resources.
- Rank the outcomes before and after. This shows the effect on the objective.
- Ask who now decides differently. This shows the effect on players.
- Check for new ways the game can fail to end or can end at once.
Applied to the misere change, step 2 shows no difference, step 3 shows reversed rankings of the final move, and step 4 shows that the winning player at a given pile size changes.
Exercise
In the solver, you change max_take from 3 to 4 and keep the normal objective (last stone wins). Which stone counts from 1 to 12 are losing for the player to move, and which two elements combine to produce that pattern?
Show answer
The losing positions are 5 and 10, since they are the multiples of max_take + 1 = 5. The rule (the move limit) and the objective (taking the last stone wins) combine to produce the pattern, and the resource count decides which player is at a losing position at the start.
Exercise
A designer adds a third player to Nim, with the objective "take the last stone." Name one problem this creates that did not exist with two players.
Show answer
With three players, a player who cannot win can choose which opponent wins by how they take stones (kingmaking). Also, "the player to move loses" no longer describes a bad position, because the loss might go to either of two opponents, so the simple win/lose labeling of positions no longer applies.