egttools.plotting.simplified.MatrixNPlayerGameHolder¶
- class MatrixNPlayerGameHolder(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, nb_strategies: int, group_size: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous])¶
Bases:
AbstractGame
Matrix-based N-Player Game Holder.
Stores a fixed matrix of expected payoffs for N-player games, where each entry corresponds to the expected payoff for a strategy across possible group configurations.
This class enables efficient fitness evaluations for evolutionary simulations without re-computing payoffs.
- Parameters:
nb_strategies (int) – Number of strategies in the game.
group_size (int) – Size of the interacting group.
payoff_matrix (numpy.ndarray[float64[m, n]]) – Matrix of shape (nb_strategies, nb_group_configurations) encoding payoffs for all strategy-group pairs.
Methods
Computes the fitness of a strategy based on the current population state.
Returns the internal matrix of precomputed payoffs.
Size of the player group.
Number of distinct group configurations supported by the matrix.
Number of strategies defined in the game.
Returns the payoff for a strategy given a specific group configuration.
Returns the full payoff matrix.
Simulates the game based on a predefined payoff matrix.
Saves the payoff matrix to a text file.
Replaces the stored payoff matrix with a new one.
- __init__(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, nb_strategies: int, group_size: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous]) None ¶
Matrix-based N-Player Game Holder.
Stores a fixed matrix of expected payoffs for N-player games, where each entry corresponds to the expected payoff for a strategy across possible group configurations.
This class enables efficient fitness evaluations for evolutionary simulations without re-computing payoffs.
- Parameters:
nb_strategies (int) – Number of strategies in the game.
group_size (int) – Size of the interacting group.
payoff_matrix (numpy.ndarray[float64[m, n]]) – Matrix of shape (nb_strategies, nb_group_configurations) encoding payoffs for all strategy-group pairs.
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) str ¶
- calculate_fitness(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, player_strategy: int, pop_size: int, population_state: numpy.ndarray[numpy.uint64[m, 1]]) float ¶
Computes the fitness of a strategy based on the current population state.
- Parameters:
player_strategy (int) – Index of the strategy used by the focal player.
pop_size (int) – Population size (excluding focal player).
population_state (numpy.ndarray) – Vector of strategy counts in the population.
- Returns:
Fitness of the focal strategy.
- Return type:
- calculate_payoffs(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) numpy.ndarray[numpy.float64[m, n]] ¶
Returns the internal matrix of precomputed payoffs.
- Returns:
Matrix of shape (nb_strategies, nb_group_configurations).
- Return type:
- group_size(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int ¶
Size of the player group.
- nb_group_configurations(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int ¶
Number of distinct group configurations supported by the matrix.
- nb_strategies(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int ¶
Number of strategies defined in the game.
- payoff(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, strategy: int, strategy pair: list[int]) float ¶
Returns the payoff for a strategy given a specific group configuration.
- payoffs(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) numpy.ndarray[numpy.float64[m, n]] ¶
Returns the full payoff matrix.
- play(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, arg0: list[int], arg1: list[float]) None ¶
Simulates the game based on a predefined payoff matrix.
- Parameters:
group_composition (list[int] or numpy.ndarray[int]) – Number of players using each strategy in the group.
game_payoffs (list[float] or numpy.ndarray[float]) – Output vector for storing player payoffs.
- save_payoffs(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, arg0: str) None ¶
Saves the payoff matrix to a text file.
- update_payoff_matrix(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, payoff_matrix: numpy.ndarray[numpy.float64[m, n]]) None ¶
Replaces the stored payoff matrix with a new one.
- __annotations__ = {}¶