egttools.games.OneShotCRD¶
- class OneShotCRD(self: egttools.numerical.numerical.games.OneShotCRD, endowment: float, cost: float, risk: float, group_size: int, min_nb_cooperators: int)¶
Bases:
AbstractGame
One-Shot Collective Risk Dilemma (CRD).
The full description of the One-shot CRD can be found in: Santos and Pacheco, ‘Risk of Collective Failure Provides an Escape from the Tragedy of the Commons’.
- Parameters
endowment (float) – Initial endowment for all players. This is parameter
b
in the mentioned article.cost (float) – Cost of cooperation.
risk (float) – The probability that all members will lose their remaining endowment if the threshold is not achieved.
group_size (int) – Size of the group that will play the CRD.
min_nb_cooperators (int) – Minimum number of cooperators required to avoid the risk of collective loss.
Methods
calculates the fitness of an individual of a given strategy given a population state.It always assumes that the population state does not contain the current individual
calculates the group achievement for a given stationary distribution.
updates the internal payoff and coop_level matrices by calculating the payoff of each strategy given any possible strategy pair
calculates the group achievement in the population at a given state.
Number of different strategies which are playing the game.
returns the payoff of a strategy given a group composition.
returns the expected payoffs of each strategy vs each possible game state
Saves the payoff matrix in a txt file.
Attributes
Cost of cooperation.
Initial endowment for all players.
Size of the group which will play the game.
Minimum number of cooperators to reach the target.
Number of combinations of Cs and Ds that can be matched in the game.
Probability that all players will lose their remaining endowment if the target si not achieved.
- __init__(self: egttools.numerical.numerical.games.OneShotCRD, endowment: float, cost: float, risk: float, group_size: int, min_nb_cooperators: int) None ¶
One-Shot Collective Risk Dilemma (CRD).
The full description of the One-shot CRD can be found in: Santos and Pacheco, ‘Risk of Collective Failure Provides an Escape from the Tragedy of the Commons’.
- Parameters
endowment (float) – Initial endowment for all players. This is parameter
b
in the mentioned article.cost (float) – Cost of cooperation.
risk (float) – The probability that all members will lose their remaining endowment if the threshold is not achieved.
group_size (int) – Size of the group that will play the CRD.
min_nb_cooperators (int) – Minimum number of cooperators required to avoid the risk of collective loss.
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical.games.OneShotCRD) str ¶
- calculate_fitness(self: egttools.numerical.numerical.games.OneShotCRD, player_strategy: int, pop_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float ¶
calculates the fitness of an individual of a given strategy given a population state.It always assumes that the population state does not contain the current individual
- calculate_group_achievement(self: egttools.numerical.numerical.games.OneShotCRD, population_size: int, stationary_distribution: numpy.ndarray[numpy.float64[m, 1]]) float ¶
calculates the group achievement for a given stationary distribution.
- calculate_payoffs(self: egttools.numerical.numerical.games.OneShotCRD) numpy.ndarray[numpy.float64[m, n]] ¶
updates the internal payoff and coop_level matrices by calculating the payoff of each strategy given any possible strategy pair
- calculate_population_group_achievement(self: egttools.numerical.numerical.games.OneShotCRD, population_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float ¶
calculates the group achievement in the population at a given state.
- nb_strategies(self: egttools.numerical.numerical.games.OneShotCRD) int ¶
Number of different strategies which are playing the game.
- payoff(self: egttools.numerical.numerical.games.OneShotCRD, strategy: int, strategy pair: List[int]) float ¶
returns the payoff of a strategy given a group composition.
- payoffs(self: egttools.numerical.numerical.games.OneShotCRD) numpy.ndarray[numpy.float64[m, n]] ¶
returns the expected payoffs of each strategy vs each possible game state
- play(self: egttools.numerical.numerical.games.OneShotCRD, arg0: List[int], arg1: List[float]) None ¶
- save_payoffs(self: egttools.numerical.numerical.games.OneShotCRD, arg0: str) None ¶
Saves the payoff matrix in a txt file.
- type(self: egttools.numerical.numerical.games.OneShotCRD) str ¶
- property cost¶
Cost of cooperation.
- property endowment¶
Initial endowment for all players.
- property group_achievement_per_group¶
- property group_size¶
Size of the group which will play the game.
- property min_nb_cooperators¶
Minimum number of cooperators to reach the target.
- property nb_states¶
Number of combinations of Cs and Ds that can be matched in the game.
- property risk¶
Probability that all players will lose their remaining endowment if the target si not achieved.