egttools.games.NormalFormNetworkGame

class NormalFormNetworkGame(*args, **kwargs)

Bases: AbstractSpatialGame

Overloaded function.

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

Normal-form network game.

Parameters:
  • nb_rounds (int) – Number of repeated rounds for each pairwise encounter.

  • payoff_matrix (numpy.ndarray) – Payoff matrix specifying the outcomes for all strategy pairs.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, 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 with custom strategy list.

Parameters:
  • nb_rounds (int) – Number of rounds of interaction.

  • payoff_matrix (numpy.ndarray) – Payoff matrix used for each pairwise encounter.

  • strategies (list[AbstractNFGStrategy]) – List of strategy instances.

Methods

calculate_cooperation_level_neighborhood

Calculates the level of cooperation in a given neighborhood.

calculate_fitness

Computes fitness of a strategy given a neighborhood configuration.

calculate_payoffs

Recalculates the expected payoff matrix based on current strategies.

expected_payoffs

Returns the expected payoffs for each strategy.

nb_rounds

nb_strategies

strategies

List of strategies currently active in the game.

type

__init__(*args, **kwargs)

Overloaded function.

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

Normal-form network game.

Parameters:
  • nb_rounds (int) – Number of repeated rounds for each pairwise encounter.

  • payoff_matrix (numpy.ndarray) – Payoff matrix specifying the outcomes for all strategy pairs.

  1. __init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, 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 with custom strategy list.

Parameters:
  • nb_rounds (int) – Number of rounds of interaction.

  • payoff_matrix (numpy.ndarray) – Payoff matrix used for each pairwise encounter.

  • strategies (list[AbstractNFGStrategy]) – List of strategy instances.

__new__(**kwargs)
__str__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) str
calculate_cooperation_level_neighborhood(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, strategy_index: SupportsInt | SupportsIndex, state: Annotated[numpy.typing.NDArray[numpy.uint64], '[m, 1]']) float

Calculates the level of cooperation in a given neighborhood.

Parameters:
  • strategy_index (int) – Focal strategy.

  • state (numpy.ndarray) – Neighbor strategy counts.

Returns:

Level of cooperation.

Return type:

float

calculate_fitness(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, strategy_index: SupportsInt | SupportsIndex, state: Annotated[numpy.typing.ArrayLike, numpy.uint64, '[m, 1]']) float

Computes fitness of a strategy given a neighborhood configuration.

Parameters:
  • strategy_index (int) – Strategy whose fitness will be computed.

  • state (numpy.ndarray) – Vector representing neighborhood strategy counts.

Returns:

Fitness value.

Return type:

float

calculate_payoffs(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) None

Recalculates the expected payoff matrix based on current strategies.

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

Returns the expected payoffs for each strategy.

nb_rounds(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) int
nb_strategies(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) int
strategies(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) list

List of strategies currently active in the game.

type(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) str
__annotations__ = {}