The Prisoner’s Dilemma: Cooperation, Trust, and Strategic Decision-Making

Last Updated May 20, 2026

The prisoner’s dilemma is one of the most influential models in modern social science because it reveals how individually rational choices can produce collectively worse outcomes. In its simplest form, two actors must independently choose whether to cooperate or defect. Mutual cooperation would leave both better off than mutual defection, yet each actor has an incentive to defect because defection protects against exploitation and can produce the highest individual payoff when the other actor cooperates.

The model has become foundational across game theory, economics, political science, evolutionary biology, international relations, environmental governance, organizational studies, and social psychology. Its social-psychological importance lies in showing that cooperation is not only a question of morality or goodwill. It is also a question of trust, expectation, identity, communication, fairness, reputation, reciprocity, institutional design, and perceived risk.

At its core, the prisoner’s dilemma captures a recurring structure of social life: people may recognize that cooperation would benefit everyone, yet still defect because they fear being the one who cooperates while others exploit them. This is why the model matters for understanding arms races, climate agreements, market competition, political polarization, workplace collaboration, public-goods provision, social trust, and collective action. Cooperation is fragile when incentives reward defensive behavior. It becomes more stable when relationships, norms, institutions, and accountability systems change the strategic environment.

Minimal institutional research illustration showing two separated decision-makers facing simultaneous choices to cooperate or defect, with a central outcome matrix, trust and broken-trust symbols, and arrows showing strategic interdependence.
The Prisoner’s Dilemma shows how individual choices to cooperate or defect can produce outcomes shaped by trust, incentives, uncertainty, and strategic interdependence.

The prisoner’s dilemma connects directly to collective action, prosocial behavior, altruism, social norms, intergroup conflict, cooperation, trust, and behavioral economics. Together these topics show why cooperation depends on both human psychology and the structures that make trust credible.


What is the prisoner’s dilemma?

The prisoner’s dilemma describes a strategic interaction in which two actors each choose between cooperation and defection. Each actor’s outcome depends not only on their own choice but also on the choice of the other actor. The dilemma arises because defection is individually tempting even though mutual cooperation would produce a better joint result.

The canonical story involves two suspects questioned separately by authorities. Each has two choices: cooperate with the other suspect by remaining silent, or defect by betraying the other. If both remain silent, both receive moderate punishment. If one betrays while the other remains silent, the defector receives the best individual outcome and the cooperator receives the worst. If both betray, both receive an outcome worse than mutual cooperation but better than being the only one who cooperates.

The paradox is that defection can appear rational for each actor regardless of what the other does. If the other cooperates, defection produces the highest payoff. If the other defects, defection avoids the worst payoff. Yet when both reason this way, they arrive at mutual defection, which is worse for both than mutual cooperation.

The model therefore captures a conflict between individual rationality and collective welfare. It shows how a social system can generate poor collective outcomes even when each actor follows a strategy that appears individually reasonable.

Back to top ↑


Origins and development of the model

The prisoner’s dilemma emerged from early game-theoretic research in the mid-twentieth century, especially work associated with Merrill Flood and Melvin Dresher at RAND. The formal structure became widely known through later exposition and experimentation, including the work of Albert Tucker, Anatol Rapoport, Albert Chammah, Robert Axelrod, and many others.

The model became influential because it distilled a broad class of cooperation problems into a compact structure. It was not only a puzzle about two prisoners. It was a general model of social interdependence: actors can benefit from mutual cooperation, but each faces incentives to defect when cooperation is uncertain.

Early experimental work showed that people do not behave as purely abstract payoff maximizers. Trust, communication, reputation, expectation, fairness, and repeated interaction matter. Some people cooperate even in risky settings. Others cooperate conditionally, depending on what they expect their partner to do. Still others defect quickly when trust breaks down.

This is why the prisoner’s dilemma became central to social psychology as well as economics. The formal game clarifies the incentive structure, but human behavior inside that structure depends on interpretation. People ask: Can I trust this person? Are they like me? Will I see them again? Is cooperation fair? Is defection justified? Will institutions punish exploitation? Will my reputation matter?

The model remains powerful because it links mathematical clarity to social complexity. It shows why cooperation cannot be understood only by studying individual virtue; it must also be understood through incentives, expectations, institutions, and relationships.

Back to top ↑


The payoff structure

The prisoner’s dilemma is defined by four possible outcomes. These outcomes are usually represented by the values temptation, reward, punishment, and sucker’s payoff.

  • Temptation: the payoff from defecting while the other actor cooperates.
  • Reward: the payoff each actor receives from mutual cooperation.
  • Punishment: the payoff each actor receives from mutual defection.
  • Sucker’s payoff: the payoff from cooperating while the other actor defects.

The dilemma requires a specific ordering of incentives. Temptation must be greater than reward, reward must be greater than punishment, and punishment must be greater than the sucker’s payoff. This ordering means unilateral defection is attractive, mutual cooperation is better than mutual defection, and unilateral cooperation against a defector is the worst outcome.

The model is psychologically powerful because it does not require hatred or irrationality. Defection can arise from caution, fear, mistrust, defensive reasoning, or anticipation that the other actor may exploit cooperation. A person may prefer cooperation in principle but still defect because the risk of being exploited feels too high.

This makes the prisoner’s dilemma a model of trust under vulnerability. Cooperation requires one actor to accept risk in expectation that the other actor will not exploit them. Defection is safer in the narrow individual sense, but destructive when generalized across both actors.

Back to top ↑


Formalizing the prisoner’s dilemma

The prisoner’s dilemma is typically defined by four payoff values: temptation \(T\), reward \(R\), punishment \(P\), and sucker’s payoff \(S\). The defining inequality is:

\[
T>R>P>S
\]

Interpretation: The best individual outcome is unilateral defection, followed by mutual cooperation, mutual defection, and finally unilateral cooperation against a defector.

A standard two-player payoff matrix can be written as:

\[
\begin{array}{c|cc}
& \text{Cooperate} & \text{Defect} \\\hline
\text{Cooperate} & (R,R) & (S,T) \\
\text{Defect} & (T,S) & (P,P)
\end{array}
\]

Interpretation: Each cell gives the payoffs for the row player and column player given their choices to cooperate or defect.

Defection is individually attractive because it yields a better payoff whether the other actor cooperates or defects:

\[
T>R \quad \text{and} \quad P>S
\]

Interpretation: Defection dominates cooperation from the standpoint of immediate individual payoff.

Yet mutual cooperation is collectively superior to mutual defection:

\[
R>P
\]

Interpretation: Both actors would be better off if both cooperated than if both defected.

A common additional condition is that mutual cooperation should be better than alternating exploitation:

\[
2R>T+S
\]

Interpretation: Sustained mutual cooperation creates more total welfare than a pattern in which actors alternate between exploiting and being exploited.

In repeated interactions, the value of future cooperation matters. If \(\delta\) is the discount factor, cooperation can be sustained when future losses from retaliation outweigh the short-term gain from defection. A simplified threshold is:

\[
\delta \geq \frac{T-R}{T-P}
\]

Interpretation: Cooperation becomes more plausible when actors care enough about future interaction to avoid the short-term temptation to defect.

These equations clarify the central paradox. The structure rewards individual defection in the short term, but societies often need institutions and relationships that make cooperation rational over time.

Back to top ↑


Dominant strategy and Nash equilibrium

In the one-shot prisoner’s dilemma, defection is a dominant strategy because it produces a better immediate payoff regardless of the other actor’s choice. If the other cooperates, defection gives the temptation payoff. If the other defects, defection avoids the sucker’s payoff. In both cases, defection appears individually rational.

The resulting Nash equilibrium is mutual defection: neither actor can improve their payoff by unilaterally changing strategy, given the other actor’s choice. Yet this equilibrium is collectively inferior to mutual cooperation. The actors are stable in a bad outcome.

This distinction is crucial. An equilibrium is not necessarily desirable. It is a state from which no actor has an individual incentive to deviate. Social systems can become trapped in equilibria that are stable and harmful at the same time.

Many real-world cooperation failures have this structure. States arm because rivals arm. Firms pollute because competitors pollute. Political parties escalate because opponents escalate. Workers withhold effort because institutions feel exploitative. Platforms optimize for engagement because competitors do. Each actor can describe their own behavior as defensive, necessary, or rational. The collective result may still be destructive.

Social psychology enters by asking how people interpret these equilibria. Do they perceive the other actor as trustworthy? Do they expect reciprocity? Do they see defection as betrayal or protection? Do norms make cooperation honorable? Do institutions make exploitation costly? These perceptions shape whether actors experience the game as a dilemma, a threat, a partnership, or a competition.

Back to top ↑


Why the prisoner’s dilemma matters in social psychology

The prisoner’s dilemma matters in social psychology because it shows that cooperation is not merely a personal virtue. It is a social achievement. People cooperate when they believe cooperation is safe, reciprocated, fair, expected, legitimate, and supported by social or institutional structures.

Human cooperation is shaped by more than payoffs. Experimental and applied research shows that people respond to trust, communication, reputation, social identity, moral norms, fairness, prior behavior, emotion, punishment, and legitimacy. The same payoff matrix can produce different behavior depending on how actors interpret one another and the situation.

Several social-psychological questions are central:

  • Do people expect others to cooperate?
  • Do they identify with the other actor?
  • Do they believe the interaction will continue?
  • Can they communicate intentions?
  • Do they see the rules as fair?
  • Are defections punished or forgiven?
  • Does reputation matter?
  • Do institutions make cooperation credible?
  • Do group norms make cooperation expected?

The prisoner’s dilemma therefore bridges formal game theory and social psychology. Game theory clarifies the incentive structure. Social psychology explains how humans perceive, interpret, and respond to that structure.

Back to top ↑


Trust, expectation, and conditional cooperation

Trust is central to prisoner’s dilemma behavior because cooperation makes actors vulnerable. To cooperate is to accept the risk that the other actor may defect. A cooperative choice therefore depends partly on the expectation that the other actor will also cooperate, either now or in the future.

Many people are conditional cooperators. They are willing to cooperate when they believe others will cooperate, but they withdraw cooperation when they expect exploitation. This makes expectations self-reinforcing. If people expect defection, they defect defensively. Their defection then confirms others’ mistrust. If people expect cooperation, they may cooperate, making cooperation more credible for others.

Fairness judgments also matter. Actors are more likely to cooperate when they believe the rules, payoffs, and behavior of others are fair. When people perceive unfairness, they may defect not only for material gain but as retaliation, protest, or self-protection.

This is why institutions that aim to promote cooperation must build trust and not merely punish defection. People need evidence that cooperation will not make them fools. Trust is not only an attitude; it is a judgment about the reliability of a social environment.

Back to top ↑


Repeated interaction and the evolution of cooperation

Repeated interaction changes the prisoner’s dilemma. In a one-shot game, defection is difficult to resist because the future does not matter. In a repeated game, today’s defection can damage tomorrow’s trust. Actors who expect future interaction may cooperate to preserve a beneficial relationship.

Repeated games allow reciprocity to become a cooperation mechanism. If cooperation is rewarded with cooperation and defection is answered with defection, actors learn that exploitation has future costs. This can stabilize cooperation even among self-interested actors.

Robert Axelrod’s work on repeated prisoner’s dilemma tournaments made this point influential. Strategies that were simple, reciprocal, and not needlessly hostile performed well in repeated environments. The broader lesson was not that cooperation is automatic, but that cooperation can emerge when actors interact repeatedly, recognize one another, and can condition future behavior on past behavior.

Repeated interaction also introduces new vulnerabilities. Retaliation can spiral. Misunderstandings can create cycles of defection. Noise can make a cooperative actor appear to defect. This is why successful cooperation often requires not only reciprocity, but also forgiveness and error correction.

Back to top ↑


Strategies: tit for tat, generosity, and forgiveness

A classic repeated-game strategy is tit for tat. It begins by cooperating, then copies the partner’s previous move. If the partner cooperates, it cooperates. If the partner defects, it defects in response. The strategy is simple, transparent, reciprocal, and not the first to defect.

Tit for tat illustrates several principles of cooperation:

  • Niceness: begin cooperatively rather than exploitively.
  • Retaliation: respond to defection so exploitation is costly.
  • Forgiveness: return to cooperation when the partner cooperates again.
  • Clarity: make behavior predictable enough for the partner to understand.

However, tit for tat is not universally optimal. In noisy environments, strict retaliation can lock actors into cycles of mutual defection after accidental errors. More forgiving strategies may perform better when miscommunication, mistakes, or imperfect monitoring are common.

This has institutional implications. Systems that punish every apparent defection harshly may deter exploitation, but they may also escalate conflict when errors occur. Systems that forgive too easily may invite exploitation. Cooperation requires a balance between accountability and repair.

In social terms, successful cooperation often requires three capacities: willingness to begin in good faith, ability to respond to exploitation, and ability to restore trust after breakdown.

Back to top ↑


Communication, reputation, and social norms

Communication often increases cooperation because it allows actors to signal intentions, coordinate expectations, make promises, clarify misunderstanding, and establish shared norms. Even when communication is cheap talk, it can affect trust if actors believe commitments are meaningful or reputationally consequential.

Reputation also changes the game. If defection is visible beyond the immediate interaction, actors may cooperate to preserve future opportunities. Reputation links present behavior to future consequences. It makes trust more portable across interactions.

Social norms further stabilize cooperation by defining what behavior is expected and legitimate. A norm of reciprocity can make cooperation feel appropriate and defection feel shameful or blameworthy. Norms also influence interpretation: the same act may be seen as strategic self-protection in one context and betrayal in another.

Communication, reputation, and norms work because they transform the prisoner’s dilemma from an isolated choice into a social relationship. The actor is no longer deciding only against a payoff matrix. They are deciding within a community of expectation, memory, and evaluation.

Back to top ↑


Social identity and group boundaries

Social identity affects prisoner’s dilemma behavior because people do not interpret all partners the same way. Actors may cooperate more readily with in-group members, trusted communities, allies, teammates, or people seen as sharing a common fate. They may defect more readily against out-groups, rivals, strangers, or actors perceived as threatening.

This can support cooperation inside groups while intensifying competition between groups. Strong in-group trust may coexist with out-group suspicion. A group may cooperate internally in order to defect externally. This is why cooperation itself is not always morally benign; it depends on who is included in the circle of cooperation and who is excluded.

Intergroup prisoner’s dilemmas are especially important in politics, international relations, and institutional life. Groups may defect because they expect hostile behavior from opponents, even when mutual cooperation would benefit both sides. Identity can make mistrust durable by turning strategic caution into moralized group conflict.

A research-grade account of the prisoner’s dilemma must therefore ask not only whether people cooperate, but with whom, under what identity conditions, and at whose expense.

Back to top ↑


International relations and arms races

International politics often exhibits prisoner’s dilemma dynamics. States may prefer mutual restraint, but each fears vulnerability if the other side defects. Arms races are a classic example. Mutual restraint would reduce costs and danger, yet each state may expand military capacity to avoid being exploited by a rival.

The result can be a stable but dangerous equilibrium. Each side describes its own behavior as defensive while interpreting the other side’s behavior as threatening. Mutual defection may emerge even when neither side wants war or instability.

International institutions attempt to reduce these dilemmas by making behavior more observable, commitments more credible, and defection more costly. Verification regimes, treaties, inspections, transparency measures, diplomatic channels, and repeated negotiations all seek to change the strategic environment.

The prisoner’s dilemma does not explain all international conflict. Some conflicts are driven by ideology, territory, domination, asymmetric power, domestic politics, or genuine incompatibility. But the model is useful where mutual cooperation is possible yet undermined by fear of exploitation.

Back to top ↑


Economics, markets, and destructive competition

Markets can generate prisoner’s dilemma dynamics when firms would collectively benefit from restraint but individually benefit from undercutting, overproducing, polluting, misleading, or exploiting. Each firm may say it has no choice because competitors would gain advantage if it acted responsibly alone.

Examples include price wars, environmental noncompliance, low labor standards, unsafe cost-cutting, data extraction, deceptive marketing, and destructive platform competition. In each case, cooperation may be collectively preferable, but unilateral restraint may be costly without shared rules or enforcement.

This is why markets often require institutions. Rules, monitoring, transparency, consumer protection, labor standards, antitrust law, environmental regulation, and professional norms can change the payoff structure. They make harmful defection less attractive and responsible cooperation more viable.

The prisoner’s dilemma is especially useful because it avoids simplistic moralism. It shows how actors can be trapped by incentives. But it should not be used to excuse harmful conduct. Instead, it should direct attention toward institutional design: what rules make cooperation possible, and who benefits when defection remains profitable?

Back to top ↑


Environmental cooperation and collective risk

Environmental governance is one of the most important domains for prisoner’s dilemma analysis. Climate mitigation, biodiversity protection, pollution control, water management, and resource conservation often require actors to bear costs now for shared benefits later. Each actor may prefer that others reduce harm while they continue benefiting from short-term extraction or emissions.

This creates free-riding pressure. If others cooperate, a defector may gain advantage by avoiding costs. If others defect, cooperation may appear futile. When many actors reason this way, collective risk increases.

Climate change is not only a two-player prisoner’s dilemma. It involves many actors, deep inequality, historical responsibility, uncertainty, power asymmetry, and intergenerational consequences. But prisoner’s dilemma logic helps explain why voluntary cooperation can be fragile without monitoring, credible commitments, finance, enforcement, technology transfer, and legitimacy.

Environmental cooperation also requires justice. Actors do not enter the game with equal histories, equal resources, or equal vulnerability. A strong institutional solution must account for differentiated responsibility and capacity, not simply demand symmetrical cooperation from unequal participants.

Back to top ↑


Organizations and workplace cooperation

Prisoner’s dilemma dynamics appear inside organizations whenever teams, departments, or employees must decide whether to cooperate under conditions of uncertainty. Collaboration can benefit the organization, but individuals or units may withhold information, protect resources, shift blame, compete for credit, or defect from shared norms when they fear exploitation.

Examples include:

  • teams hoarding information because other teams might take credit;
  • departments protecting budgets instead of sharing resources;
  • employees withholding effort because they believe others are free-riding;
  • managers competing destructively for visibility;
  • units blaming one another rather than solving cross-functional problems;
  • organizations underinvesting in safety because competitors do the same;
  • platform teams optimizing local metrics while harming system-level trust.

Workplace cooperation depends on credible reciprocity. People cooperate when they believe effort will be recognized, exploitation will be constrained, and shared success will not be captured by others. When institutions reward defection, cooperation becomes fragile.

Organizational design can reduce these dilemmas through shared goals, transparent accountability, cross-functional incentives, fair recognition, conflict-resolution procedures, and leadership norms that reward cooperation rather than internal competition.

Back to top ↑


Institutional solutions to prisoner’s dilemma problems

Institutions help solve prisoner’s dilemma problems by changing incentives, expectations, and information. They do not eliminate self-interest; they reshape the conditions under which self-interest operates.

Effective institutional solutions often include:

  • Monitoring: making defection visible.
  • Sanctions: making exploitation costly.
  • Reputation systems: linking present behavior to future trust.
  • Communication channels: allowing actors to coordinate expectations.
  • Repeated interaction: making future consequences matter.
  • Norms of reciprocity: making cooperation socially expected.
  • Dispute resolution: preventing breakdown after conflict.
  • Fair distribution: reducing resentment and perceived exploitation.
  • Transparency: reducing uncertainty about partner behavior.
  • Legitimacy: increasing compliance because rules are seen as fair.

Institutions can also fail. If monitoring is weak, sanctions are biased, rules are illegitimate, or powerful actors defect without consequence, cooperation can collapse. People are less likely to cooperate when they believe the system protects defectors.

The deepest lesson is that cooperation is not sustained by incentives alone. It requires credible institutions that are perceived as fair, enforceable, and legitimate.

Back to top ↑


The prisoner’s dilemma in the architecture of social influence

Within the broader architecture of social influence, the prisoner’s dilemma helps explain why cooperation is often fragile even when all parties recognize its value. Social norms stabilize expectations. Prosocial behavior identifies actions that support collective welfare. Altruism examines other-regarding motivation. Collective action shows how groups coordinate around shared interests. Intergroup conflict explains how mistrust and identity can intensify defection.

The prisoner’s dilemma adds the strategic insight that cooperation can fail even without irrationality. Actors may defect because the structure rewards defensive behavior. Trust becomes difficult when exploitation is possible and future interaction is uncertain.

This makes the model a bridge between formal reasoning and social psychology. It shows why norms, identity, communication, fairness, and institutions matter. They are not decorative additions to the game. They are the conditions that change how the game is perceived and whether cooperation can survive.

Seen this way, the prisoner’s dilemma is not merely a game-theoretic curiosity. It is a compact representation of a broad class of social problems in which trust, reciprocity, and institutional design determine whether collective welfare can be sustained.

Back to top ↑


Interpretive cautions and limits

The prisoner’s dilemma is powerful, but it should not be treated as a universal model of all cooperation problems. Some situations are better described as coordination games, assurance games, public-goods dilemmas, chicken games, stag hunts, bargaining problems, asymmetric power struggles, or coercive domination.

Several cautions are essential:

  • Do not assume all social conflict is a prisoner’s dilemma.
  • Do not ignore unequal power, history, coercion, or structural injustice.
  • Do not treat payoff matrices as objective when actors experience costs and benefits differently.
  • Do not reduce human cooperation to self-interest alone.
  • Do not assume defection is always immoral; it may be defensive under exploitation.
  • Do not assume cooperation is always good; groups can cooperate to harm outsiders.
  • Do not ignore communication, identity, legitimacy, and institutional context.
  • Do not treat formal equilibrium as a moral recommendation.

The strongest use of the prisoner’s dilemma combines formal clarity with social interpretation. The model identifies an incentive structure. Social psychology explains how people experience that structure, and institutions determine whether the structure can be changed.

Back to top ↑


Measurement, data, and research design

Prisoner’s dilemma research uses one-shot games, repeated games, dyadic experiments, communication manipulations, reputation designs, punishment conditions, monitoring and enforcement studies, social-identity manipulations, cross-cultural comparison, computational simulation, and institutional modeling.

Key variables include:

  • participant and dyad identifiers;
  • round number;
  • own choice and partner choice;
  • cooperation and partner cooperation indicators;
  • temptation, reward, punishment, and sucker payoffs;
  • own payoff and partner payoff;
  • cumulative payoff;
  • trust score;
  • fairness score;
  • expected partner cooperation;
  • communication access;
  • punishment availability;
  • reputation visibility;
  • monitoring strength;
  • institutional enforcement;
  • social identity salience;
  • response time.

Strong research designs should verify that participants understand the payoff structure. If participants misunderstand the incentives, observed cooperation or defection may reflect confusion rather than strategic behavior. Studies should also distinguish one-shot from repeated-game contexts, because the meaning of cooperation changes when future interaction is expected.

Researchers should measure expectations directly. Cooperation often depends not only on preference, but on what participants believe the other actor will do. Trust, expected partner cooperation, perceived fairness, and prior partner behavior should therefore be included in analysis.

Repeated-game studies should include lagged partner behavior. A cooperation decision on round \(t\) is often shaped by what the partner did on round \(t-1\). This allows researchers to measure reciprocity, retaliation, forgiveness, and recovery from defection.

Back to top ↑


R code for prisoner’s dilemma research

The following R workflow models cooperation, payoffs, trust, fairness, reciprocity, and response time in one-shot and repeated prisoner’s dilemma experiments. It is designed for dyadic designs with repeated rounds.

# Install packages if needed:
# pak::pak(c("tidyverse", "lme4", "lmerTest", "emmeans", "broom.mixed", "performance"))

library(tidyverse)
library(lme4)
library(lmerTest)
library(emmeans)
library(broom.mixed)
library(performance)

# Expected columns:
# participant, dyad_id, site_id, condition, round, horizon_type,
# own_choice, partner_choice, cooperate, partner_cooperate,
# own_payoff, partner_payoff, cumulative_payoff,
# temptation_payoff, reward_payoff, punishment_payoff, sucker_payoff,
# trust_score, fairness_score, expected_partner_cooperation,
# communication_access, punishment_available, reputation_visibility,
# monitoring_strength, institutional_enforcement,
# social_identity_salience, response_time_ms

dat <- read_csv("prisoners_dilemma_trials.csv") %>%
  arrange(dyad_id, participant, round) %>%
  mutate(
    participant = factor(participant),
    dyad_id = factor(dyad_id),
    site_id = factor(site_id),
    condition = factor(condition),
    horizon_type = factor(horizon_type),
    cooperate = as.integer(cooperate),
    partner_cooperate = as.integer(partner_cooperate),
    previous_partner_cooperate = lag(partner_cooperate),
    previous_own_cooperate = lag(cooperate),
    temptation_gap = temptation_payoff - reward_payoff,
    cooperation_surplus = 2 * reward_payoff -
      (temptation_payoff + sucker_payoff),
    log_response_time = log(response_time_ms),
    .by = c(dyad_id, participant)
  )

# -----------------------------
# 1. Descriptive summary
# -----------------------------

summary_table <- dat %>%
  group_by(condition, round) %>%
  summarise(
    n = n(),
    participants = n_distinct(participant),
    dyads = n_distinct(dyad_id),
    cooperation_rate = mean(cooperate, na.rm = TRUE),
    partner_cooperation_rate = mean(partner_cooperate, na.rm = TRUE),
    mean_payoff = mean(own_payoff, na.rm = TRUE),
    mean_cumulative_payoff = mean(cumulative_payoff, na.rm = TRUE),
    mean_trust = mean(trust_score, na.rm = TRUE),
    mean_fairness = mean(fairness_score, na.rm = TRUE),
    mean_expected_partner_cooperation =
      mean(expected_partner_cooperation, na.rm = TRUE),
    .groups = "drop"
  )

print(summary_table)

# -----------------------------
# 2. Cooperation model
# -----------------------------

coop_model <- glmer(
  cooperate ~
    round +
    previous_partner_cooperate +
    trust_score +
    fairness_score +
    expected_partner_cooperation +
    communication_access +
    reputation_visibility +
    monitoring_strength +
    institutional_enforcement +
    social_identity_salience +
    temptation_gap +
    condition +
    (1 | dyad_id) +
    (1 | participant) +
    (1 | site_id),
  data = dat,
  family = binomial(),
  control = glmerControl(optimizer = "bobyqa")
)

summary(coop_model)
emmeans(coop_model, ~ condition, type = "response")

# -----------------------------
# 3. Payoff model
# -----------------------------

payoff_model <- lmer(
  own_payoff ~
    cooperate * partner_cooperate +
    round +
    trust_score +
    fairness_score +
    institutional_enforcement +
    condition +
    (1 | dyad_id) +
    (1 | participant) +
    (1 | site_id),
  data = dat,
  REML = FALSE
)

summary(payoff_model)

# -----------------------------
# 4. Trust model
# -----------------------------

trust_model <- lmer(
  trust_score ~
    previous_partner_cooperate +
    communication_access +
    reputation_visibility +
    institutional_enforcement +
    social_identity_salience +
    condition +
    (1 | dyad_id) +
    (1 | participant) +
    (1 | site_id),
  data = dat,
  REML = FALSE
)

summary(trust_model)

# -----------------------------
# 5. Fairness model
# -----------------------------

fairness_model <- lmer(
  fairness_score ~
    own_payoff +
    partner_cooperate +
    cooperate +
    institutional_enforcement +
    condition +
    (1 | dyad_id) +
    (1 | participant) +
    (1 | site_id),
  data = dat,
  REML = FALSE
)

summary(fairness_model)

# -----------------------------
# 6. Reciprocity summary
# -----------------------------

reciprocity_summary <- dat %>%
  filter(!is.na(previous_partner_cooperate)) %>%
  group_by(condition, previous_partner_cooperate) %>%
  summarise(
    n = n(),
    cooperation_rate = mean(cooperate, na.rm = TRUE),
    mean_trust = mean(trust_score, na.rm = TRUE),
    mean_payoff = mean(own_payoff, na.rm = TRUE),
    .groups = "drop"
  )

print(reciprocity_summary)

# -----------------------------
# 7. Response-time model
# -----------------------------

rt_model <- lmer(
  log_response_time ~
    round +
    cooperate +
    partner_cooperate +
    trust_score +
    fairness_score +
    expected_partner_cooperation +
    condition +
    (1 | dyad_id) +
    (1 | participant) +
    (1 | site_id),
  data = dat %>% filter(response_time_ms >= 150),
  REML = FALSE
)

summary(rt_model)

# -----------------------------
# 8. Export outputs
# -----------------------------

write_csv(summary_table, "prisoners_dilemma_summary.csv")
write_csv(reciprocity_summary, "prisoners_dilemma_reciprocity_summary.csv")

write_csv(
  tidy(coop_model, effects = "fixed", conf.int = TRUE),
  "prisoners_dilemma_cooperation_coefficients.csv"
)

write_csv(
  tidy(payoff_model, effects = "fixed", conf.int = TRUE),
  "prisoners_dilemma_payoff_coefficients.csv"
)

write_csv(
  tidy(trust_model, effects = "fixed", conf.int = TRUE),
  "prisoners_dilemma_trust_coefficients.csv"
)

# -----------------------------
# 9. Visualization
# -----------------------------

ggplot(summary_table, aes(x = round, y = cooperation_rate, color = condition)) +
  geom_line() +
  geom_point() +
  labs(
    title = "Cooperation across repeated prisoner’s dilemma rounds",
    x = "Round",
    y = "Cooperation rate"
  ) +
  theme_minimal()

This workflow supports repeated-game analysis by estimating how cooperation depends on partner history, trust, fairness, communication, reputation, monitoring, enforcement, identity, and payoff temptation.

Back to top ↑


Python code for prisoner’s dilemma research

The Python workflow below parallels the R analysis and adds a strategy-tournament simulation. It is useful for comparing always-cooperate, always-defect, tit-for-tat, generous tit-for-tat, and win-stay/lose-shift strategies under repeated interaction.

import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.api as sm
import matplotlib.pyplot as plt

# Expected columns:
# participant, dyad_id, site_id, condition, round, horizon_type,
# own_choice, partner_choice, cooperate, partner_cooperate,
# own_payoff, partner_payoff, cumulative_payoff,
# temptation_payoff, reward_payoff, punishment_payoff, sucker_payoff,
# trust_score, fairness_score, expected_partner_cooperation,
# communication_access, punishment_available, reputation_visibility,
# monitoring_strength, institutional_enforcement,
# social_identity_salience, response_time_ms

df = pd.read_csv("prisoners_dilemma_trials.csv")

categorical_cols = [
    "participant",
    "dyad_id",
    "site_id",
    "condition",
    "horizon_type"
]

for col in categorical_cols:
    df[col] = df[col].astype("category")

df = df.sort_values(["dyad_id", "participant", "round"]).copy()

df["previous_partner_cooperate"] = (
    df.groupby(["dyad_id", "participant"])["partner_cooperate"].shift(1)
)

df["previous_own_cooperate"] = (
    df.groupby(["dyad_id", "participant"])["cooperate"].shift(1)
)

df["temptation_gap"] = (
    df["temptation_payoff"]
    - df["reward_payoff"]
)

df["cooperation_surplus"] = (
    2 * df["reward_payoff"]
    - (df["temptation_payoff"] + df["sucker_payoff"])
)

df["log_response_time"] = np.log(df["response_time_ms"])

# -----------------------------
# 1. Descriptive summary
# -----------------------------

summary_table = (
    df.groupby(["condition", "round"], observed=True)
    .agg(
        n=("cooperate", "size"),
        participants=("participant", "nunique"),
        dyads=("dyad_id", "nunique"),
        cooperation_rate=("cooperate", "mean"),
        partner_cooperation_rate=("partner_cooperate", "mean"),
        mean_payoff=("own_payoff", "mean"),
        mean_cumulative_payoff=("cumulative_payoff", "mean"),
        mean_trust=("trust_score", "mean"),
        mean_fairness=("fairness_score", "mean"),
        mean_expected_partner_cooperation=(
            "expected_partner_cooperation",
            "mean"
        ),
    )
    .reset_index()
)

print(summary_table)

# -----------------------------
# 2. Cooperation model
# -----------------------------

cooperation_model = smf.glm(
    "cooperate ~ round + previous_partner_cooperate "
    "+ trust_score + fairness_score "
    "+ expected_partner_cooperation "
    "+ communication_access + reputation_visibility "
    "+ monitoring_strength + institutional_enforcement "
    "+ social_identity_salience + temptation_gap + condition",
    data=df,
    family=sm.families.Binomial(),
)

cooperation_result = cooperation_model.fit(
    cov_type="cluster",
    cov_kwds={"groups": df["participant"]},
)

print(cooperation_result.summary())

# -----------------------------
# 3. Payoff model
# -----------------------------

payoff_model = smf.ols(
    "own_payoff ~ cooperate * partner_cooperate "
    "+ round + trust_score + fairness_score "
    "+ institutional_enforcement + condition",
    data=df,
)

payoff_result = payoff_model.fit(
    cov_type="cluster",
    cov_kwds={"groups": df["participant"]},
)

print(payoff_result.summary())

# -----------------------------
# 4. Trust and fairness models
# -----------------------------

trust_model = smf.ols(
    "trust_score ~ previous_partner_cooperate "
    "+ communication_access + reputation_visibility "
    "+ institutional_enforcement + social_identity_salience "
    "+ condition",
    data=df,
)

trust_result = trust_model.fit(
    cov_type="cluster",
    cov_kwds={"groups": df["participant"]},
)

print(trust_result.summary())

fairness_model = smf.ols(
    "fairness_score ~ own_payoff + partner_cooperate "
    "+ cooperate + institutional_enforcement + condition",
    data=df,
)

fairness_result = fairness_model.fit(
    cov_type="cluster",
    cov_kwds={"groups": df["participant"]},
)

print(fairness_result.summary())

# -----------------------------
# 5. Reciprocity summary
# -----------------------------

reciprocity_summary = (
    df.dropna(subset=["previous_partner_cooperate"])
    .groupby(["condition", "previous_partner_cooperate"], observed=True)
    .agg(
        n=("cooperate", "size"),
        cooperation_rate=("cooperate", "mean"),
        mean_trust=("trust_score", "mean"),
        mean_payoff=("own_payoff", "mean"),
    )
    .reset_index()
)

print(reciprocity_summary)

# -----------------------------
# 6. Strategy tournament
# -----------------------------

def payoff(own_coop, partner_coop, T=5, R=3, P=1, S=0):
    if own_coop == 1 and partner_coop == 1:
        return R
    if own_coop == 1 and partner_coop == 0:
        return S
    if own_coop == 0 and partner_coop == 1:
        return T
    return P

def choose(strategy, own_history, partner_history, rng):
    if strategy == "always_cooperate":
        return 1
    if strategy == "always_defect":
        return 0
    if strategy == "tit_for_tat":
        return 1 if len(partner_history) == 0 else partner_history[-1]
    if strategy == "generous_tit_for_tat":
        if len(partner_history) == 0:
            return 1
        if partner_history[-1] == 0 and rng.random() < 0.15:
            return 1
        return partner_history[-1]
    if strategy == "win_stay_lose_shift":
        if len(own_history) == 0:
            return 1
        last_payoff = payoff(own_history[-1], partner_history[-1])
        return own_history[-1] if last_payoff >= 3 else 1 - own_history[-1]
    return 0

def simulate_strategy_tournament(rounds=200, seed=42):
    rng = np.random.default_rng(seed)
    strategies = [
        "always_cooperate",
        "always_defect",
        "tit_for_tat",
        "generous_tit_for_tat",
        "win_stay_lose_shift",
    ]

    rows = []

    for strategy_a in strategies:
        for strategy_b in strategies:
            history_a = []
            history_b = []
            cumulative_a = 0
            cumulative_b = 0

            for round_number in range(1, rounds + 1):
                choice_a = choose(strategy_a, history_a, history_b, rng)
                choice_b = choose(strategy_b, history_b, history_a, rng)

                payoff_a = payoff(choice_a, choice_b)
                payoff_b = payoff(choice_b, choice_a)

                cumulative_a += payoff_a
                cumulative_b += payoff_b

                history_a.append(choice_a)
                history_b.append(choice_b)

                rows.append({
                    "strategy_a": strategy_a,
                    "strategy_b": strategy_b,
                    "round": round_number,
                    "choice_a": choice_a,
                    "choice_b": choice_b,
                    "payoff_a": payoff_a,
                    "payoff_b": payoff_b,
                    "cumulative_a": cumulative_a,
                    "cumulative_b": cumulative_b,
                })

    tournament = pd.DataFrame(rows)

    tournament_summary = (
        tournament.groupby("strategy_a")
        .agg(
            total_payoff=("payoff_a", "sum"),
            mean_payoff=("payoff_a", "mean"),
            cooperation_rate=("choice_a", "mean"),
        )
        .reset_index()
        .sort_values("total_payoff", ascending=False)
    )

    return tournament, tournament_summary

tournament, tournament_summary = simulate_strategy_tournament()

print(tournament_summary)

# -----------------------------
# 7. Visualization
# -----------------------------

fig, ax = plt.subplots(figsize=(8, 5))

for condition, group in summary_table.groupby("condition", observed=True):
    ax.plot(
        group["round"],
        group["cooperation_rate"],
        marker="o",
        label=condition
    )

ax.set_xlabel("Round")
ax.set_ylabel("Cooperation rate")
ax.set_title("Cooperation across repeated prisoner’s dilemma rounds")
ax.legend()
plt.tight_layout()
plt.show()

# -----------------------------
# 8. Export summaries
# -----------------------------

summary_table.to_csv("prisoners_dilemma_summary.csv", index=False)
reciprocity_summary.to_csv("prisoners_dilemma_reciprocity_summary.csv", index=False)
tournament.to_csv("strategy_tournament_rounds.csv", index=False)
tournament_summary.to_csv("strategy_tournament_summary.csv", index=False)

This Python workflow supports experimental and simulation-based analysis. It estimates cooperation as a function of partner history, trust, fairness, expectations, communication, reputation, enforcement, identity, and payoff temptation, then compares repeated-game strategies under tournament conditions.

Back to top ↑


Research data architecture

Prisoner’s dilemma research often depends on relational data: participants, dyads, sites, conditions, rounds, horizons, choices, payoffs, trust scores, fairness scores, expected partner cooperation, communication access, punishment availability, reputation visibility, monitoring strength, institutional enforcement, social identity salience, and response time. Rather than embedding executable database code directly in the WordPress article body, the companion GitHub repository includes the full SQL schema and example queries for researchers who want to reproduce or extend the data model.

The research data model is designed to support questions such as:

  • Does cooperation differ between one-shot and repeated games?
  • Does prior partner cooperation predict current cooperation?
  • Does communication increase cooperation through trust?
  • Does reputation visibility stabilize cooperation?
  • Does monitoring reduce the expected benefit of defection?
  • Does institutional enforcement increase cooperation?
  • Does social identity salience affect cooperation with in-group and out-group partners?
  • Do fairness judgments mediate cooperation after unequal payoffs?
  • Which repeated-game strategies perform best under different conditions?

The GitHub repository contains the full database schema, example analytical queries, validation logic, and reproducible data workflow. Keeping executable SQL in GitHub avoids WordPress hosting restrictions while preserving the research-grade infrastructure for readers who want to inspect or reuse the model.

View the SQL research data architecture in GitHub.

Back to top ↑


GitHub repository

The companion repository provides reusable code and research scaffolding for studying the prisoner’s dilemma, including workflows for cooperation, defection, trust, fairness, expected partner cooperation, repeated interaction, reciprocity, reputation, monitoring, institutional enforcement, social identity, payoff analysis, response time, and strategy tournaments.

Back to top ↑


Why the prisoner’s dilemma remains foundational

The prisoner’s dilemma remains foundational because it shows that cooperation problems are often structural, not merely personal. People may defect not because they are irrational or malicious, but because the situation rewards defensive behavior and makes trust risky. Mutual defection can emerge from rational caution, even when all parties would prefer mutual cooperation.

This makes the model indispensable for social psychology. It explains why trust matters, why expectations shape behavior, why communication can transform outcomes, why repeated relationships stabilize cooperation, why institutions are necessary, and why social norms can make cooperation more credible.

Its lesson is also institutional. If a society wants cooperation, it cannot simply ask people to be better. It must build conditions in which cooperation is not naïve: credible commitments, fair rules, transparent monitoring, legitimate enforcement, reputation systems, protected communication, and norms of reciprocity.

Read alongside collective action, prosocial behavior, social norms, behavioral economics, and Institutions & Governance, the prisoner’s dilemma becomes more than a formal game. It becomes a model of how fragile cooperation is — and how carefully trust must be built, protected, and repaired.

Back to top ↑


Further reading

Back to top ↑

References

Back to top ↑

Scroll to Top