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
Calculates the fitness of a strategy in a given population state.
Calculates group achievement given a stationary distribution.
Computes the expected payoffs for each strategy under all group configurations.
Computes contribution polarization relative to the fair contribution (E/2).
Computes contribution polarization among successful groups.
Calculates group achievement for the population at a given state.
Number of strategies in the game.
Returns the payoff of a strategy in a given group composition.
Returns the payoff matrix for all strategies and group configurations.
Plays a single round of the CRD game for the specified group composition.
Saves the payoff matrix to a file.
Returns the type of the game.
Attributes
Initial endowment for each player.
Multiplier applied to payoffs if the target is met.
Number of players per group.
Number of rounds in the game.
Number of distinct population states.
Probability of losing endowment if the target is not met.
List of strategy instances in the game.
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:
- 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.
- 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:
group_composition (list[int] or numpy.ndarray[int]) – Number of players using each strategy.
game_payoffs (list[float] or numpy.ndarray[float]) – Output vector to store player payoffs.
- 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.