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

calculate_fitness

Computes the fitness of a strategy based on the current population state.

calculate_payoffs

Returns the internal matrix of precomputed payoffs.

group_size

Size of the player group.

nb_group_configurations

Number of distinct group configurations supported by the matrix.

nb_strategies

Number of strategies defined in the game.

payoff

Returns the payoff for a strategy given a specific group configuration.

payoffs

Returns the full payoff matrix.

play

Simulates the game based on a predefined payoff matrix.

save_payoffs

Saves the payoff matrix to a text file.

type

update_payoff_matrix

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:

float

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:

numpy.ndarray

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:
save_payoffs(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder, arg0: str) None

Saves the payoff matrix to a text file.

type(self: egttools.numerical.numerical_.games.MatrixNPlayerGameHolder) str
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__ = {}