egttools.games.NormalFormNetworkGame¶
- class NormalFormNetworkGame(*args, **kwargs)¶
Bases:
AbstractSpatialGame
Overloaded function.
__init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, nb_rounds: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous]) -> None
Normal Form Network Game.
This class implements a networked version of a standard two-player normal form game. Agents are placed in a network or spatial structure and interact only with their neighbors, using a fixed payoff matrix to compute outcomes.
Each agent selects an action (or strategy), and receives payoffs based on pairwise interactions with all neighbors. Repeated interactions are supported, allowing for multi-round strategies and dynamic behaviors such as conditional cooperation.
- nb_roundsint
Number of repeated rounds for each pairwise encounter.
- payoff_matrixnumpy.ndarray[float64[m, m]]
Payoff matrix specifying the outcomes for all strategy pairs.
__init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, nb_rounds: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous], strategies: list) -> None
Normal Form Game with custom strategy list.
This constructor initializes a network game with a custom list of strategies. Each strategy must be a pointer to a subclass of AbstractNFGStrategy.
- nb_roundsint
Number of rounds of interaction.
- payoff_matrixnumpy.ndarray[float64[m, m]]
Payoff matrix used for each pairwise encounter.
- strategiesList[egttools.behaviors.AbstractNFGStrategy]
A list of strategy pointers.
Methods
Calculates the level of cooperation in a given neighborhood.
Computes fitness of a strategy given a neighborhood configuration.
Recalculates the expected payoff matrix based on current strategies.
Returns the expected payoffs for each strategy.
Number of repeated rounds per encounter.
Number of strategies available.
List of strategies currently active in the game.
Returns the type identifier of the game.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, nb_rounds: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous]) -> None
Normal Form Network Game.
This class implements a networked version of a standard two-player normal form game. Agents are placed in a network or spatial structure and interact only with their neighbors, using a fixed payoff matrix to compute outcomes.
Each agent selects an action (or strategy), and receives payoffs based on pairwise interactions with all neighbors. Repeated interactions are supported, allowing for multi-round strategies and dynamic behaviors such as conditional cooperation.
- nb_roundsint
Number of repeated rounds for each pairwise encounter.
- payoff_matrixnumpy.ndarray[float64[m, m]]
Payoff matrix specifying the outcomes for all strategy pairs.
__init__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, nb_rounds: int, payoff_matrix: numpy.ndarray[numpy.float64[m, n], flags.c_contiguous], strategies: list) -> None
Normal Form Game with custom strategy list.
This constructor initializes a network game with a custom list of strategies. Each strategy must be a pointer to a subclass of AbstractNFGStrategy.
- nb_roundsint
Number of rounds of interaction.
- payoff_matrixnumpy.ndarray[float64[m, m]]
Payoff matrix used for each pairwise encounter.
- strategiesList[egttools.behaviors.AbstractNFGStrategy]
A list of strategy pointers.
- __new__(**kwargs)¶
- __str__(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) str ¶
String representation of the game object.
- calculate_cooperation_level_neighborhood(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, strategy_index: int, state: numpy.ndarray[numpy.uint64[m, 1]]) float ¶
Calculates the level of cooperation in a given neighborhood.
Useful when using multi-round or conditional strategies where past actions may affect behavior.
- Parameters:
strategy_index (int) – Focal strategy.
state (numpy.ndarray[int]) – Neighbor strategy counts.
- Returns:
Level of cooperation.
- Return type:
- calculate_fitness(self: egttools.numerical.numerical_.games.NormalFormNetworkGame, strategy_index: int, state: numpy.ndarray[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[int]) – Vector representing neighborhood strategy counts.
- Returns:
Fitness value.
- Return type:
- 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) numpy.ndarray[numpy.float64[m, n]] ¶
Returns the expected payoffs for each strategy.
- nb_rounds(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) int ¶
Number of repeated rounds per encounter.
- nb_strategies(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) int ¶
Number of strategies available.
- strategies(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) list[egttools::FinitePopulations::behaviors::AbstractNFGStrategy] ¶
List of strategies currently active in the game.
- type(self: egttools.numerical.numerical_.games.NormalFormNetworkGame) str ¶
Returns the type identifier of the game.
- __annotations__ = {}¶