egttools.games.OneShotCRD¶
- class OneShotCRD(self: egttools.numerical.numerical_.games.OneShotCRD, endowment: SupportsFloat | SupportsIndex, cost: SupportsFloat | SupportsIndex, risk: SupportsFloat | SupportsIndex, group_size: SupportsInt | SupportsIndex, min_nb_cooperators: SupportsInt | SupportsIndex)¶
Bases:
AbstractGameOne-shot collective risk dilemma.
- Parameters:
endowment (float) – Initial endowment received by all players.
cost (float) – Fraction of the endowment contributed by cooperators.
risk (float) – Probability of collective loss if the group fails to reach the threshold.
group_size (int) – Number of players in the group.
min_nb_cooperators (int) – Minimum number of cooperators needed to avoid risk.
Methods
Calculates the fitness of a strategy given a population state.
Computes group achievement from a stationary distribution.
Updates the payoff matrix and cooperation level matrix for all strategy pairs.
Computes the group achievement for the given population state.
Returns the payoff for a given strategy and group composition.
Returns the expected payoff matrix.
Executes a one-shot CRD round and updates payoffs for the given group composition.
Saves the payoff matrix to a text file.
Attributes
- __init__(self: egttools.numerical.numerical_.games.OneShotCRD, endowment: SupportsFloat | SupportsIndex, cost: SupportsFloat | SupportsIndex, risk: SupportsFloat | SupportsIndex, group_size: SupportsInt | SupportsIndex, min_nb_cooperators: SupportsInt | SupportsIndex) None¶
One-shot collective risk dilemma.
- Parameters:
endowment (float) – Initial endowment received by all players.
cost (float) – Fraction of the endowment contributed by cooperators.
risk (float) – Probability of collective loss if the group fails to reach the threshold.
group_size (int) – Number of players in the group.
min_nb_cooperators (int) – Minimum number of cooperators needed to avoid risk.
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical_.games.OneShotCRD) str¶
- calculate_fitness(self: egttools.numerical.numerical_.games.OneShotCRD, player_strategy: SupportsInt | SupportsIndex, pop_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.uint64], '[m, 1]']) float¶
Calculates the fitness of a strategy given a population state.
- Parameters:
player_strategy (int) – Index of the focal strategy.
pop_size (int) – Population size.
population_state (numpy.ndarray) – Vector of strategy counts in the population.
- Return type:
- calculate_group_achievement(self: egttools.numerical.numerical_.games.OneShotCRD, population_size: SupportsInt | SupportsIndex, stationary_distribution: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']) float¶
Computes group achievement from a stationary distribution.
- calculate_payoffs(self: egttools.numerical.numerical_.games.OneShotCRD) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Updates the payoff matrix and cooperation level matrix for all strategy pairs.
- calculate_population_group_achievement(self: egttools.numerical.numerical_.games.OneShotCRD, population_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.uint64], '[m, 1]']) float¶
Computes the group achievement for the given population state.
- nb_strategies(self: egttools.numerical.numerical_.games.OneShotCRD) int¶
- payoff(self: egttools.numerical.numerical_.games.OneShotCRD, strategy: SupportsInt | SupportsIndex, strategy_pair: collections.abc.Sequence[SupportsInt | SupportsIndex]) float¶
Returns the payoff for a given strategy and group composition.
- payoffs(self: egttools.numerical.numerical_.games.OneShotCRD) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the expected payoff matrix.
- play(self: egttools.numerical.numerical_.games.OneShotCRD, arg0: collections.abc.Sequence[SupportsInt | SupportsIndex], arg1: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None¶
Executes a one-shot CRD round and updates payoffs for the given group composition.
- Parameters:
group_composition (numpy.ndarray) – Number of players per strategy.
game_payoffs (numpy.ndarray) – Output vector to store payoffs for each player.
- save_payoffs(self: egttools.numerical.numerical_.games.OneShotCRD, arg0: str) None¶
Saves the payoff matrix to a text file.
- type(self: egttools.numerical.numerical_.games.OneShotCRD) str¶
- __annotations__ = {}¶
- property cost¶
- property endowment¶
- property group_achievement_per_group¶
- property group_size¶
- property min_nb_cooperators¶
- property nb_states¶
- property risk¶