egttools.games.NormalFormGame

class NormalFormGame(*args, **kwargs)

Bases: AbstractGame

Overloaded function.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormGame, nb_rounds: typing.SupportsInt | typing.SupportsIndex, payoff_matrix: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.c_contiguous”]) -> None

Normal-form game with repeated pairwise interactions.

Parameters:
  • nb_rounds (int) – Number of rounds played by each strategy pair.

  • payoff_matrix (numpy.ndarray) – Payoff matrix where entry (i, j) gives the payoff of strategy i against j.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormGame, nb_rounds: typing.SupportsInt | typing.SupportsIndex, payoff_matrix: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.c_contiguous”], strategies: list) -> None

Normal-form game initialized with custom strategy classes.

Parameters:

Methods

calculate_fitness

Computes the fitness of a strategy in a given population state.

calculate_payoffs

Calculates the expected payoff matrix for all strategy pairs.

expected_payoffs

Returns the matrix of expected payoffs between strategies.

nb_strategies

payoff

Returns the payoff for a given strategy in a specific match-up.

payoffs

Returns the payoff matrix.

play

Executes a game round and stores the resulting payoffs.

save_payoffs

Saves the payoff matrix to a text file.

type

Attributes

nb_rounds

nb_states

strategies

List of strategies participating in the game.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormGame, nb_rounds: typing.SupportsInt | typing.SupportsIndex, payoff_matrix: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.c_contiguous”]) -> None

Normal-form game with repeated pairwise interactions.

Parameters:
  • nb_rounds (int) – Number of rounds played by each strategy pair.

  • payoff_matrix (numpy.ndarray) – Payoff matrix where entry (i, j) gives the payoff of strategy i against j.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormGame, nb_rounds: typing.SupportsInt | typing.SupportsIndex, payoff_matrix: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.c_contiguous”], strategies: list) -> None

Normal-form game initialized with custom strategy classes.

Parameters:
__new__(**kwargs)
__str__(self: egttools.numerical.numerical_.games.NormalFormGame) str
calculate_fitness(self: egttools.numerical.numerical_.games.NormalFormGame, player_strategy: SupportsInt | SupportsIndex, population_size: SupportsInt | SupportsIndex, population_state: Annotated[numpy.typing.NDArray[numpy.uint64], '[m, 1]']) float

Computes the fitness of a strategy in a given population state.

Parameters:
  • player_strategy (int) – Index of the focal strategy.

  • population_size (int) – Total number of individuals.

  • population_state (numpy.ndarray) – Strategy counts in the population.

Returns:

Fitness of the focal strategy.

Return type:

float

calculate_payoffs(self: egttools.numerical.numerical_.games.NormalFormGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Calculates the expected payoff matrix for all strategy pairs.

Returns:

Matrix of expected payoffs between strategies.

Return type:

numpy.ndarray

expected_payoffs(self: egttools.numerical.numerical_.games.NormalFormGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Returns the matrix of expected payoffs between strategies.

nb_strategies(self: egttools.numerical.numerical_.games.NormalFormGame) int
payoff(self: egttools.numerical.numerical_.games.NormalFormGame, strategy: SupportsInt | SupportsIndex, strategy_pair: collections.abc.Sequence[SupportsInt | SupportsIndex]) float

Returns the payoff for a given strategy in a specific match-up.

Parameters:
  • strategy (int) – Index of the strategy used by the player.

  • strategy_pair (list[int]) – Pair of strategy indices in the match-up.

Return type:

float

payoffs(self: egttools.numerical.numerical_.games.NormalFormGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Returns the payoff matrix.

Returns:

Matrix of expected payoffs between strategies.

Return type:

numpy.ndarray

play(self: egttools.numerical.numerical_.games.NormalFormGame, group_composition: collections.abc.Sequence[SupportsInt | SupportsIndex], game_payoffs: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None

Executes a game round and stores the resulting payoffs.

Parameters:
  • group_composition (numpy.ndarray) – Composition of the pairwise game.

  • game_payoffs (numpy.ndarray) – Output array to store individual payoffs.

save_payoffs(self: egttools.numerical.numerical_.games.NormalFormGame, arg0: str) None

Saves the payoff matrix to a text file.

Parameters:

file_name (str) – File path where the matrix will be saved.

type(self: egttools.numerical.numerical_.games.NormalFormGame) str
__annotations__ = {}
property nb_rounds
property nb_states
property strategies

List of strategies participating in the game.