Sub topic 5
Resources: the assets players gain, spend, and protect
This chapter assumes you have read the earlier chapters on players, objectives, and rules. You should be able to tell an objective from a rule. Reading short Python snippets helps, but it is optional.
What counts as a resource
A resource is anything a player can hold, gain, spend, or lose that affects what they can do or how close they are to the objective. Resources are part of the game's structure, not its theme. A "gold coin" and a "wood token" differ in art. Mechanically each is a countable quantity that rules let players change.
An element is a resource when it passes three checks:
- It belongs to a player or to the shared game state.
- Its quantity or status can change during play.
- Changing it changes what a player can do, or changes the outcome.
A thing that never changes, like the board's printed size, is a constant of the rules, not a resource. A thing that changes but affects nothing, like a score nobody uses, is a record, not a resource.
In Nim, the pile of stones is the only resource. It is shared. Every move removes stones, and the number left decides which moves are legal.
Kinds of resources
Resources come in several forms. Naming the form helps you decide how the rules should handle it.
| Kind | Example | Typical rule concern |
|---|---|---|
| Countable tokens | Coins, wood, ammunition | Limits on gaining and spending |
| Positions and territory | Board squares, controlled regions | Who may occupy or contest them |
| Time and turns | Actions per turn, a turn limit, a clock | How many actions fit before the game ends |
| Information | Cards in hand, fog of war | Who may see what, and when |
| Units and pieces | Soldiers, pawns, characters | Movement, loss, and replacement |
| Status and health | Hit points, lives, reputation | Thresholds that trigger elimination or bonuses |
Time is the resource designers most often overlook. In chess, each side has exactly one move per turn. That fixed allowance makes tempo, the speed at which you build a position, a real resource that players trade off.
Ownership and visibility
Two properties describe how a resource sits in the game.
Ownership says who controls the resource. It can be private (a hand of cards), shared (Nim's pile), or contested (a neutral territory either player may claim). Ownership decides which interactions are possible. A shared pile forces players to affect each other. A private store lets players act independently.
Visibility says who can see the quantity. Public resources support planning and calculation. Hidden resources support bluffing and inference. Poker depends on hidden cards and public chip stacks.
State both properties when you describe a resource. "Gold: private to each player, public count" is more useful than "gold".
How resources flow
Every resource has a source and a sink.
- A source adds the resource: income each turn, a reward for an action, a starting allotment.
- A sink removes it: a cost, a decay, a penalty, a conversion.
When sources outpace sinks, the resource inflates and stops mattering. When sinks outpace sources, it becomes scarce and every spend becomes a decision. Later chapters treat scarcity, trade-offs, and conversion in detail. Here the goal is to be able to list a game's flows.
A simple inventory has four columns: the resource, how it starts, how it is gained, and how it is spent or lost.
| Resource | Start | Gained | Spent or lost |
|---|---|---|---|
| Nim stones | Agreed pile size | Never | Each move removes 1 to 3 |
| Chess pieces | 16 per side | Pawn promotion | Capture |
| Monopoly cash | Fixed bank amount | Passing Go, rent | Purchases, rent, fees |
Nim has a sink and no source. The resource only shrinks, so the game must end. That is a structural guarantee that comes from the resource flow, and it is why the objective "take the last stone" can always be reached.
Resources and rules
Rules and resources depend on each other. Rules define how resources change, and resources decide which rules apply right now.
In the Nim model from this tutorial, the rule "take 1 to 3 stones" refers to the resource. The number of legal moves depends on how many stones remain:
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 None
print(legal_moves(State(2, 0)))
print(legal_moves(State(10, 0)))The first call prints [1, 2] and the second prints [1, 2, 3]. The min(MAX_TAKE, state.stones) expression is where the resource limits the rule. With two stones left, taking three is impossible, even though the rule normally allows it.
Three things to notice in this code:
- The resource is data in the state, not a global.
Stateis frozen, soapply_movereturns a new state instead of changing the old one. This makes the flow explicit: one move maps one resource level to another. - Spending is validated.
apply_moveraises an error when the cost cannot be paid. Most games need a rule for this case: forbid the action, allow it with a penalty, or allow debt. - The objective reads the resource.
winnerchecksstones == 0. Many objectives are thresholds on a resource: reach 10 points, deplete the opponent's health, hold three regions.
Protecting resources
The chapter title says players gain, spend, and protect resources. Protection is the third verb, and it exists only when another player can take the resource away.
A game offers protection mechanics when it gives players ways to keep a resource safe: walls, defensive pieces, hidden information, insurance, or a rule that bars certain captures. Protection costs something, usually another resource, so it turns into a trade-off. A player who spends actions on defense has fewer actions for attack.
Ask these questions about any resource:
- Can an opponent reduce it directly?
- If so, what can its owner spend to prevent that?
- Is the cost of protection lower or higher than the value protected?
If protection is too cheap, attacking is pointless and the game stalls. If it is too expensive or impossible, a player who falls behind cannot recover. Nim has no protection at all, because the pile is shared and nobody can take stones away from the other player. That is one reason Nim has no conflict beyond the turn order.
Common errors
- Confusing resources with objectives. Points can be both. If a player wins by collecting the most points, points are the objective measure. If points can also be spent on upgrades, they are a resource too. Specify which role applies at each moment.
- Leaving out time. If a turn limit or action allowance is not listed, an analysis misses a key constraint.
- Ignoring hidden resources. Information that only one player has is a resource. Leaving it out makes bluffing games look like they have no depth.
- Writing an unpayable cost without a rule. If a card costs 3 and the player has 2, say what happens. Silence creates arguments at the table and bugs in code.
- Treating the theme as the resource. "Magic crystals" tells you nothing. List the quantity, the rule that changes it, and who sees it.
Changing a resource and watching the system
Resource changes ripple into the other elements. Consider changing the Nim pile or the take limit while keeping the objective the same. A strategy exists that leaves the opponent a multiple of four stones. It depends on the pair of numbers (MAX_TAKE + 1 = 4) and on the starting count.
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))With 10 stones, the first player takes 2 and leaves 8. The strategy is applied by both players here, so the second player takes 1 from 8, and play continues. Because the starting count is not a multiple of four, the first player is the one who benefits from the strategy. The program prints 0, meaning player 0 wins. If you start with 8 stones, the first player has no good move, because every move leaves a non-multiple of four for the opponent's strategy to answer. Both players here use the same function, so with 8 stones the first player takes 1 (the fallback) and player 1 then wins by following the pattern correctly.
That is the point: a single resource number, the starting pile, decides who has the advantage. Designers call this a first-player advantage or disadvantage that is built into the resource setup. Changing the starting count, or the take limit, changes who wins under good play without touching players, objective, or the rule's wording.
A change to the objective gives a different effect. In the misère variant, 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 resource flow is identical. Players still remove 1 to 3 stones. But the best moves change, because players now want to leave exactly one stone for the opponent. Resource and rules are the same, yet the resource now has a different meaning: the last stone was a prize and is now a penalty.
Checklist for inventorying resources
When you analyze a game, work through these steps.
- List every quantity that changes during play, including time, position, and information.
- For each, record the owner (private, shared, contested) and the visibility (public or hidden).
- Record the sources and sinks, including starting amounts.
- Note any thresholds the objective or rules read from the resource.
- Note how the resource can be protected or taken.
- Check what happens when a cost cannot be paid.
Exercise
A two-player card game gives each player 5 energy at the start, adds 1 energy at the start of each turn, and charges energy to play cards. Hand contents are hidden. Energy is shown to both players. List the resources, with ownership and visibility, and name one source and one sink for energy.
Show answer
Resources: energy (private to each player, public count), cards in hand (private, hidden), and turns or actions (shared allowance, public). Energy sources: the starting 5 and the +1 per turn. Energy sink: the cost of playing a card. The hand also counts as hidden information, which supports bluffing and inference.
Exercise
In the Nim model, explain why changing MAX_TAKE from 3 to 4 changes which starting pile sizes favor the first player, even though no other element changes.
Show answer
The winning strategy leaves the opponent a multiple of MAXTAKE + 1. With MAXTAKE = 3 that multiple is 4, so a pile that is a multiple of 4 favors the second player. With MAX_TAKE = 4 the multiple is 5, so piles that are multiples of 5 favor the second player and all other sizes favor the first. The resource limit in the rule, not the players or objective, moves the balance.
Exercise
A strategy game lets players spend gold to build walls that stop enemy raids. Raids steal gold. Describe the protection trade-off and one way it could break the game.
Show answer
Walls convert gold into safety, so gold spent on walls cannot be spent on growth. The trade-off is growth versus security. If walls are cheap and fully block raids, raiding becomes pointless and the game stalls. If walls are expensive or weak, a player who loses gold early cannot afford walls and falls further behind, which creates a runaway loss.