egttools.games.Matrix2PlayerGameHolder¶
- class Matrix2PlayerGameHolder(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, nb_strategies: SupportsInt | SupportsIndex, payoff_matrix: Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]', 'flags.c_contiguous'])¶
Bases:
AbstractGameMatrix-based 2-player game holder.
- Parameters:
nb_strategies (int) – Number of strategies used in the game.
payoff_matrix (numpy.ndarray) – Matrix containing the payoff of each strategy against all others.
Methods
Computes the fitness of a strategy given the population configuration.
Returns the stored payoff matrix.
Returns the payoff for a given strategy pair.
Returns the expected payoff matrix.
Executes a match given a group composition and stores the resulting payoffs.
Saves the current payoff matrix to a text file.
Replaces the internal payoff matrix with a new one.
- __init__(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, nb_strategies: SupportsInt | SupportsIndex, payoff_matrix: Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]', 'flags.c_contiguous']) None¶
Matrix-based 2-player game holder.
- Parameters:
nb_strategies (int) – Number of strategies used in the game.
payoff_matrix (numpy.ndarray) – Matrix containing the payoff of each strategy against all others.
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) str¶
- calculate_fitness(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, player_strategy: SupportsInt | SupportsIndex, pop_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.uint64], '[m, 1]']) float¶
Computes the fitness of a strategy given the population configuration.
- Parameters:
player_strategy (int) – Index of the focal strategy.
pop_size (int) – Size of the population.
population_state (numpy.ndarray) – Vector of counts of each strategy in the population.
- Return type:
- calculate_payoffs(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the stored payoff matrix.
- Returns:
Payoff matrix.
- Return type:
- nb_strategies(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) int¶
- payoff(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, strategy: SupportsInt | SupportsIndex, strategy_pair: collections.abc.Sequence[SupportsInt | SupportsIndex]) float¶
Returns the payoff for a given strategy pair.
- payoffs(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the expected payoff matrix.
- play(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, arg0: collections.abc.Sequence[SupportsInt | SupportsIndex], arg1: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None¶
Executes a match given a group composition and stores the resulting payoffs.
- Parameters:
group_composition (numpy.ndarray) – Count of each strategy in the group.
game_payoffs (numpy.ndarray) – Output vector to be filled with each player’s payoff.
- save_payoffs(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, arg0: str) None¶
Saves the current payoff matrix to a text file.
- update_payoff_matrix(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, payoff_matrix: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, n]']) None¶
Replaces the internal payoff matrix with a new one.
- __annotations__ = {}¶