egttools.games.CRDGame

class CRDGame(self: egttools.numerical.numerical_.games.CRDGame, endowment: int, threshold: int, nb_rounds: int, group_size: int, risk: float, enhancement_factor: float, strategies: list)

Bases: AbstractGame

Collective Risk Dilemma (CRD) Game.

This implementation allows defining arbitrary strategies using instances of AbstractCRDStrategy.

Based on: Milinski et al. (2008). The collective-risk social dilemma and the prevention of simulated dangerous climate change. PNAS, 105(7), 2291–2294.

Parameters:
  • endowment (int) – Initial endowment of each player.

  • threshold (int) – Collective target the group must achieve to avoid risk.

  • nb_rounds (int) – Number of rounds in the game.

  • group_size (int) – Number of players in each group.

  • risk (float) – Probability of losing remaining endowment if the target is not met.

  • enhancement_factor (float) – Multiplier for successful cooperation (may add surplus).

  • strategies (list[AbstractCRDStrategy]) – List of strategy instances.

Methods

calculate_fitness

Calculates the fitness of a strategy in a given population state.

calculate_group_achievement

Calculates group achievement given a stationary distribution.

calculate_payoffs

Computes the expected payoffs for each strategy under all group configurations.

calculate_polarization

Computes contribution polarization relative to the fair contribution (E/2).

calculate_polarization_success

Computes contribution polarization among successful groups.

calculate_population_group_achievement

Calculates group achievement for the population at a given state.

nb_strategies

Number of strategies in the game.

payoff

Returns the payoff of a strategy in a given group composition.

payoffs

Returns the payoff matrix for all strategies and group configurations.

play

Plays a single round of the CRD game for the specified group composition.

save_payoffs

Saves the payoff matrix to a file.

type

Returns the type of the game.

Attributes

endowment

Initial endowment for each player.

enhancement_factor

Multiplier applied to payoffs if the target is met.

group_size

Number of players per group.

nb_rounds

Number of rounds in the game.

nb_states

Number of distinct population states.

risk

Probability of losing endowment if the target is not met.

strategies

List of strategy instances in the game.

target

Collective target to avoid risk.

__init__(self: egttools.numerical.numerical_.games.CRDGame, endowment: int, threshold: int, nb_rounds: int, group_size: int, risk: float, enhancement_factor: float, strategies: list) None

Collective Risk Dilemma (CRD) Game.

This implementation allows defining arbitrary strategies using instances of AbstractCRDStrategy.

Based on: Milinski et al. (2008). The collective-risk social dilemma and the prevention of simulated dangerous climate change. PNAS, 105(7), 2291–2294.

Parameters:
  • endowment (int) – Initial endowment of each player.

  • threshold (int) – Collective target the group must achieve to avoid risk.

  • nb_rounds (int) – Number of rounds in the game.

  • group_size (int) – Number of players in each group.

  • risk (float) – Probability of losing remaining endowment if the target is not met.

  • enhancement_factor (float) – Multiplier for successful cooperation (may add surplus).

  • strategies (list[AbstractCRDStrategy]) – List of strategy instances.

__new__(**kwargs)
__str__(self: egttools.numerical.numerical_.games.CRDGame) str

Returns a string representation of the CRDGame.

calculate_fitness(self: egttools.numerical.numerical_.games.CRDGame, player_strategy: int, pop_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float

Calculates the fitness of a strategy in a given population state.

Parameters:
  • player_strategy (int) – Index of the focal strategy.

  • pop_size (int) – Total population size (excluding focal).

  • population_state (numpy.ndarray[numpy.uint64]) – Vector of strategy counts.

Return type:

float

calculate_group_achievement(self: egttools.numerical.numerical_.games.CRDGame, population_size: int, stationary_distribution: numpy.ndarray[numpy.float64[m, 1]]) float

Calculates group achievement given a stationary distribution.

calculate_payoffs(self: egttools.numerical.numerical_.games.CRDGame) numpy.ndarray[numpy.float64[m, n]]

Computes the expected payoffs for each strategy under all group configurations.

Return type:

numpy.ndarray of shape (nb_strategies, nb_group_configurations)

calculate_polarization(self: egttools.numerical.numerical_.games.CRDGame, population_size: int, population_state: numpy.ndarray[numpy.float64[m, 1]]) numpy.ndarray[numpy.float64[3, 1]]

Computes contribution polarization relative to the fair contribution (E/2).

calculate_polarization_success(self: egttools.numerical.numerical_.games.CRDGame, population_size: int, population_state: numpy.ndarray[numpy.float64[m, 1]]) numpy.ndarray[numpy.float64[3, 1]]

Computes contribution polarization among successful groups.

calculate_population_group_achievement(self: egttools.numerical.numerical_.games.CRDGame, population_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float

Calculates group achievement for the population at a given state.

nb_strategies(self: egttools.numerical.numerical_.games.CRDGame) int

Number of strategies in the game.

payoff(self: egttools.numerical.numerical_.games.CRDGame, strategy: int, group_composition: list[int]) float

Returns the payoff of a strategy in a given group composition.

Parameters:
  • strategy (int) – Index of the strategy.

  • group_composition (list[int]) – Group composition vector.

Return type:

float

payoffs(self: egttools.numerical.numerical_.games.CRDGame) numpy.ndarray[numpy.float64[m, n]]

Returns the payoff matrix for all strategies and group configurations.

play(self: egttools.numerical.numerical_.games.CRDGame, arg0: list[int], arg1: list[float]) None

Plays a single round of the CRD game for the specified group composition.

Parameters:
save_payoffs(self: egttools.numerical.numerical_.games.CRDGame, arg0: str) None

Saves the payoff matrix to a file.

Parameters:

file_name (str) – Output file path.

type(self: egttools.numerical.numerical_.games.CRDGame) str

Returns the type of the game.

__annotations__ = {}
property endowment

Initial endowment for each player.

property enhancement_factor

Multiplier applied to payoffs if the target is met.

property group_size

Number of players per group.

property nb_rounds

Number of rounds in the game.

property nb_states

Number of distinct population states.

property risk

Probability of losing endowment if the target is not met.

property strategies

List of strategy instances in the game.

property target

Collective target to avoid risk.