egttools.games.CRDGameTU

class CRDGameTU(self: egttools.numerical.numerical_.games.CRDGameTU, endowment: int, threshold: int, nb_rounds: int, group_size: int, risk: float, tu: egttools.numerical.numerical_.distributions.TimingUncertainty, strategies: list)

Bases: AbstractGame

Collective Risk Dilemma with Timing Uncertainty (CRDGameTU).

This game extends the CRD setting proposed by Milinski et al. (2008) by introducing uncertainty about the number of rounds before a potential disaster. Timing uncertainty is captured using a TimingUncertainty object.

In this version, players contribute resources over multiple rounds to a common pool. If the collective threshold is reached before the disaster occurs, the group avoids the risk. Otherwise, each player faces a predefined probability of losing their remaining endowment.

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

  • threshold (int) – Collective target required to avoid risk.

  • nb_rounds (int) – Maximum number of rounds (before which a disaster may occur).

  • group_size (int) – Number of players per group.

  • risk (float) – Probability of failure if the target is not met.

  • tu (TimingUncertainty) – An object modeling timing uncertainty.

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

Methods

calculate_fitness

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

calculate_group_achievement

Calculates group achievement based on a stationary distribution.

calculate_payoffs

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

calculate_polarization

Computes contribution polarization in a given population state.

calculate_polarization_success

Computes contribution polarization among successful groups.

calculate_population_group_achievement

Calculates group achievement for a given population state.

nb_strategies

Number of strategies in the game.

payoff

Returns the payoff of a strategy given a group composition.

payoffs

Returns the matrix of expected payoffs.

play

Executes one iteration of the CRD game using a specific group composition.

save_payoffs

Saves the payoff matrix to a text file.

type

Returns the type identifier of the game.

Attributes

endowment

Initial endowment per player.

group_size

Size of the group.

min_rounds

Minimum number of rounds the game will run.

nb_states

Number of possible population states.

risk

Probability of losing endowment if the target is not met.

strategies

List of strategy objects participating in the game.

target

Target that the group must reach.

__init__(self: egttools.numerical.numerical_.games.CRDGameTU, endowment: int, threshold: int, nb_rounds: int, group_size: int, risk: float, tu: egttools.numerical.numerical_.distributions.TimingUncertainty, strategies: list) None

Collective Risk Dilemma with Timing Uncertainty (CRDGameTU).

This game extends the CRD setting proposed by Milinski et al. (2008) by introducing uncertainty about the number of rounds before a potential disaster. Timing uncertainty is captured using a TimingUncertainty object.

In this version, players contribute resources over multiple rounds to a common pool. If the collective threshold is reached before the disaster occurs, the group avoids the risk. Otherwise, each player faces a predefined probability of losing their remaining endowment.

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

  • threshold (int) – Collective target required to avoid risk.

  • nb_rounds (int) – Maximum number of rounds (before which a disaster may occur).

  • group_size (int) – Number of players per group.

  • risk (float) – Probability of failure if the target is not met.

  • tu (TimingUncertainty) – An object modeling timing uncertainty.

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

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

Returns a string representation of the CRDGameTU.

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

Computes 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.CRDGameTU, population_size: int, stationary_distribution: numpy.ndarray[numpy.float64[m, 1]]) float

Calculates group achievement based on a stationary distribution.

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

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

Returns:

Matrix of shape (nb_strategies, nb_group_configurations).

Return type:

numpy.ndarray

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

Computes contribution polarization in a given population state.

calculate_polarization_success(self: egttools.numerical.numerical_.games.CRDGameTU, 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.CRDGameTU, population_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float

Calculates group achievement for a given population state.

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

Number of strategies in the game.

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

Returns the payoff of a strategy given a group composition.

Parameters:
  • strategy (int) – Strategy index.

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

Return type:

float

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

Returns the matrix of expected payoffs.

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

Executes one iteration of the CRD game using a specific group composition.

This method calculates the payoffs for each player based on their strategy and the current group composition under timing uncertainty.

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

Saves the payoff matrix to a text file.

Parameters:

file_name (str) – Path to the output file.

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

Returns the type identifier of the game.

__annotations__ = {}
property endowment

Initial endowment per player.

property group_size

Size of the group.

property min_rounds

Minimum number of rounds the game will run.

property nb_states

Number of possible population states.

property risk

Probability of losing endowment if the target is not met.

property strategies

List of strategy objects participating in the game.

property target

Target that the group must reach.