egttools.games.NormalFormGame¶
- class NormalFormGame(*args, **kwargs)¶
Bases:
AbstractGameOverloaded function.
__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.
__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:
nb_rounds (int) – Number of rounds in the repeated game.
payoff_matrix (numpy.ndarray) – Payoff matrix.
strategies (list[AbstractNFGStrategy]) – List of strategy instances.
Methods
Computes the fitness of a strategy in a given population state.
Calculates the expected payoff matrix for all strategy pairs.
Returns the matrix of expected payoffs between strategies.
Returns the payoff for a given strategy in a specific match-up.
Returns the payoff matrix.
Executes a game round and stores the resulting payoffs.
Saves the payoff matrix to a text file.
Attributes
List of strategies participating in the game.
- __init__(*args, **kwargs)¶
Overloaded function.
__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.
__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:
nb_rounds (int) – Number of rounds in the repeated game.
payoff_matrix (numpy.ndarray) – Payoff matrix.
strategies (list[AbstractNFGStrategy]) – List of strategy instances.
- __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:
- 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:
- 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.
- 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:
- 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.
- __annotations__ = {}¶
- property nb_rounds¶
- property nb_states¶
- property strategies¶
List of strategies participating in the game.