egttools.plotting.simplified.Matrix2PlayerGameHolder¶
- class Matrix2PlayerGameHolder(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, nb_strategies: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous])¶
Bases:
AbstractGame
Matrix-based 2-Player Game Holder.
Stores the expected payoffs between strategies in a 2-player game. This class is useful for simulations where the payoff matrix is externally computed and fixed, enabling fast fitness calculations without recomputation.
- Parameters:
nb_strategies (int) – Number of strategies used in the game.
payoff_matrix (numpy.ndarray[float64[m, m]]) – 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 number of strategies in the game.
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: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous]) None ¶
Matrix-based 2-Player Game Holder.
Stores the expected payoffs between strategies in a 2-player game. This class is useful for simulations where the payoff matrix is externally computed and fixed, enabling fast fitness calculations without recomputation.
- Parameters:
nb_strategies (int) – Number of strategies used in the game.
payoff_matrix (numpy.ndarray[float64[m, m]]) – 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: int, pop_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float ¶
Computes the fitness of a strategy given the population configuration.
Assumes the focal player is not included in the population state.
- Parameters:
player_type (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) numpy.ndarray[numpy.float64[m, n]] ¶
Returns the stored payoff matrix.
- Returns:
Payoff matrix of shape (nb_strategies, nb_strategies).
- Return type:
- nb_strategies(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) int ¶
Returns the number of strategies in the game.
- payoff(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, strategy: int, strategy pair: list[int]) float ¶
Returns the payoff for a given strategy pair.
- payoffs(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder) numpy.ndarray[numpy.float64[m, n]] ¶
Returns the expected payoff matrix.
- play(self: egttools.numerical.numerical_.games.Matrix2PlayerGameHolder, arg0: list[int], arg1: list[float]) None ¶
Executes a match given a group composition and stores the resulting payoffs.
- Parameters:
group_composition (list[int] or numpy.ndarray[int]) – Count of each strategy in the group (typically 2 players).
game_payoffs (list[float] or numpy.ndarray[float]) – 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: numpy.ndarray[numpy.float64[m, n]]) None ¶
Replaces the internal payoff matrix with a new one.
- __annotations__ = {}¶