egttools.plotting.simplified.AbstractReplicatorGame

class AbstractReplicatorGame(self: egttools.numerical.numerical_.games.AbstractReplicatorGame)

Bases: pybind11_object

Base 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

calculate_fitness

Returns the expected fitness of all strategies at a given population state.

calculate_payoffs

Computes or refreshes the payoff table of the game.

group_size

Returns the group size of the game.

nb_strategies

Returns the number of strategies available in the game.

payoffs

Returns the currently stored payoff table of the game.

type

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:

str

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:

numpy.ndarray

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:

numpy.ndarray

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:

int

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:

int

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:

numpy.ndarray

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:

str

__annotations__ = {}