egttools.plotting.simplified.MatrixNPlayerGameHolder¶
- class MatrixNPlayerGameHolder(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, nb_strategies: SupportsInt | SupportsIndex, group_size: SupportsInt | SupportsIndex, payoff_matrix: Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]', 'flags.c_contiguous'])¶
Bases:
AbstractGameMatrix-based N-player game holder.
- Parameters:
nb_strategies (int) – Number of strategies in the game.
group_size (int) – Size of the interacting group.
payoff_matrix (numpy.ndarray) – Matrix 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.
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: SupportsInt | SupportsIndex, group_size: SupportsInt | SupportsIndex, payoff_matrix: Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]', 'flags.c_contiguous']) None¶
Matrix-based N-player game holder.
- Parameters:
nb_strategies (int) – Number of strategies in the game.
group_size (int) – Size of the interacting group.
payoff_matrix (numpy.ndarray) – Matrix 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: SupportsInt | SupportsIndex, pop_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.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.
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) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the internal matrix of precomputed payoffs.
- Return type:
- group_size(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int¶
- nb_group_configurations(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int¶
- nb_strategies(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) int¶
- payoff(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, strategy: SupportsInt | SupportsIndex, strategy_pair: collections.abc.Sequence[SupportsInt | SupportsIndex]) float¶
Returns the payoff for a strategy given a specific group configuration.
- payoffs(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the full payoff matrix.
- play(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, arg0: collections.abc.Sequence[SupportsInt | SupportsIndex], arg1: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None¶
Simulates the game based on a predefined payoff matrix.
- Parameters:
group_composition (numpy.ndarray) – Number of players using each strategy in the group.
game_payoffs (numpy.ndarray) – 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: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, n]']) None¶
Replaces the stored payoff matrix with a new one.
- __annotations__ = {}¶