egttools.games.CRDGame

class CRDGame(self: egttools.numerical.numerical_.games.CRDGame, endowment: SupportsInt | SupportsIndex, threshold: SupportsInt | SupportsIndex, nb_rounds: SupportsInt | SupportsIndex, group_size: SupportsInt | SupportsIndex, risk: SupportsFloat | SupportsIndex, enhancement_factor: SupportsFloat | SupportsIndex, strategies: list)

Bases: AbstractGame

Collective risk dilemma game.

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.

  • 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.

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

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

Attributes

__init__(self: egttools.numerical.numerical_.games.CRDGame, endowment: SupportsInt | SupportsIndex, threshold: SupportsInt | SupportsIndex, nb_rounds: SupportsInt | SupportsIndex, group_size: SupportsInt | SupportsIndex, risk: SupportsFloat | SupportsIndex, enhancement_factor: SupportsFloat | SupportsIndex, strategies: list) None

Collective risk dilemma game.

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.

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

__new__(**kwargs)
__str__(self: egttools.numerical.numerical_.games.CRDGame) str
calculate_fitness(self: egttools.numerical.numerical_.games.CRDGame, 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 in a given population state.

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

  • pop_size (int) – Total population size.

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

Return type:

float

calculate_group_achievement(self: egttools.numerical.numerical_.games.CRDGame, population_size: SupportsInt | SupportsIndex, stationary_distribution: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']) float

Calculates group achievement given a stationary distribution.

calculate_payoffs(self: egttools.numerical.numerical_.games.CRDGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

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

Return type:

numpy.ndarray

calculate_polarization(self: egttools.numerical.numerical_.games.CRDGame, population_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']

Computes contribution polarization relative to the fair contribution.

calculate_polarization_success(self: egttools.numerical.numerical_.games.CRDGame, population_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']

Computes contribution polarization among successful groups.

calculate_population_group_achievement(self: egttools.numerical.numerical_.games.CRDGame, population_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.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
payoff(self: egttools.numerical.numerical_.games.CRDGame, strategy: SupportsInt | SupportsIndex, group_composition: collections.abc.Sequence[SupportsInt | SupportsIndex]) 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) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Returns the payoff matrix for all strategies and group configurations.

play(self: egttools.numerical.numerical_.games.CRDGame, arg0: collections.abc.Sequence[SupportsInt | SupportsIndex], arg1: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None

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

Parameters:
  • group_composition (numpy.ndarray) – Number of players using each strategy.

  • game_payoffs (numpy.ndarray) – 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
__annotations__ = {}
property endowment
property enhancement_factor
property group_size
property nb_rounds
property nb_states
property risk
property strategies

List of strategy instances in the game.

property target