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: AbstractGame

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.

Methods

calculate_fitness

Computes the fitness of a strategy given the population configuration.

calculate_payoffs

Returns the stored payoff matrix.

nb_strategies

payoff

Returns the payoff for a given strategy pair.

payoffs

Returns the expected payoff matrix.

play

Executes a match given a group composition and stores the resulting payoffs.

save_payoffs

Saves the current payoff matrix to a text file.

type

update_payoff_matrix

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:

float

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:

numpy.ndarray

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.

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