egttools.games.AbstractReplicatorGame¶
- class AbstractReplicatorGame(self: egttools.numerical.numerical_.games.AbstractReplicatorGame)¶
Bases:
pybind11_objectBase class for games that define fitness in the infinite-population limit.
This abstract class defines the interface required for a game to be used with replicator dynamics in EGTtools. Concrete implementations must provide the number of strategies, the group size, a method to compute the fitness vector at a given population state, and access to the corresponding payoff table when available.
Methods
Returns the expected fitness of all strategies at a given population state.
Computes or refreshes the payoff table of the game.
Returns the group size of the game.
Returns the number of strategies available in the game.
Returns the currently stored payoff table of the game.
Returns the type of the game as a string.
- __init__(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) None¶
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) str¶
Returns a string representation of the game object.
- Returns:
A short description of the game.
- Return type:
- calculate_fitness(self: egttools.numerical.numerical_.games.AbstractReplicatorGame, frequencies: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']) Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']¶
Returns the expected fitness of all strategies at a given population state.
- Parameters:
frequencies (numpy.ndarray) – One-dimensional array containing the frequency of each strategy in the population.
- Returns:
One-dimensional array containing the expected fitness of each strategy.
- Return type:
- calculate_payoffs(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Computes or refreshes the payoff table of the game.
Implementations may use this method to lazily compute and cache the payoff structure associated with the game.
- Returns:
The payoff table of the game.
- Return type:
- group_size(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) int¶
Returns the group size of the game.
- Returns:
The number of individuals in each interacting group.
- Return type:
- nb_strategies(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) int¶
Returns the number of strategies available in the game.
- Returns:
The total number of strategies.
- Return type:
- payoffs(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']¶
Returns the currently stored payoff table of the game.
If the payoff table is computed lazily, calculate_payoffs() should be called first to ensure that the returned table is initialized and up to date.
- Returns:
The current payoff table of the game.
- Return type:
- type(self: egttools.numerical.numerical_.games.AbstractReplicatorGame) str¶
Returns the type of the game as a string.
- Returns:
A label identifying the game type.
- Return type:
- __annotations__ = {}¶