The replicator_game.c and replicator_game.h files handle the functionality of defining the game being played for replicator dynamics simulations.
This constant indicates that only the strategy profiles should be cached. It is a cache_mask.
- double *(*payoff_function)(int players, int *strategy_profile)¶
This type defines the signature for a payoff function that takes a strategy profile and returns an array of payoff values.
- struct StrategyProfiles¶
This struct holds the information for strategy profiles (tuples of interaction possibility)
- int StrategyProfiles.count¶
This is the number of profiles the struct holds.
- int StrategyProfiles.size¶
This is the size of each profile.
- int* StrategyProfiles.types¶
This is an array of types (the number of types for player i is in the ith entry). The size member indicates the size of this array.
- int StrategyProfiles.has_cached_info¶
This is a flag to indicate whether the struct has cached information stored. It is used for the StrategyProfiles_destroy() function.
- int** StrategyProfiles.profiles¶
This is an array of the possible strategy profiles. It has size stored in count and each element has size from the size member.
- int*** StrategyProfiles.player_strategy_profiles¶
This is an array of the possible strategy profiles sorted by players participating in them. It has the size defined by the size member. The first dimension corresponds to the player. The second dimension corresponds to the number of strategies for that player (size count/types[i]). The third dimension is a list of the profiles in which that strategy participates, represented by indices referring to the StrategyProfiles.profiles list.
- struct Game¶
- This struct holds data about the game being played under the dynamics.
- int Game.populations¶
This is how many populations the game has.
- int Game.players¶
This is how many players there are in the game.
- int* Game.types¶
This is a list, for each player, how many strategies that player has.
- struct PayoffCache¶
This is a struct that holds a cache of pre-calculated payoff vectors.
- int PayoffCache.count¶
This is how many items are in the cache.
- int PayoffCache.has_cached_info¶
This is a flag to indicate that the cache has information in it that should be freed.
- int PayoffCache.free_profiles¶
This is a flag to indicate that the profiles are cached and should be freed.
- double** PayoffCache.payoff_cache¶
This is the cache of payoff vectors. Each payoff vector is an array of doubles, and the collection is an array of those arrays.
- strategyprofiles_t * StrategyProfiles_create(int players, int *types, cache_mask cache)¶
This creates a strategyprofiles_t struct for the requisite number of players.
The types parameter is a list of number of strategies that each player has.
The cache parameter is how much of the profiles and payoffs to cache.
- int * StrategyProfiles_getProfile(strategyprofiles_t *sprofs, int num)¶
This returns the strategy profile corresponding to the num`th entry in the :c:data:`sprofs array.
- int * StrategyProfiles_getPlayerProfile(strategyprofiles_t *sprofs, int player, int strategy, int num)¶
This returns the num`th strategy profile that player :c:data:`player‘s strategy strategy is involved in.
- int StrategyProfiles_getPlayerProfileNumber(strategyprofiles_t *sprofs, int player, int strategy, int num)¶
This returns the index in the profile list of sprofs that the num`th strategy profile of player :c:data:`player‘s strategy strategy is involved in.
- game_t * Game_create(int players, int populations, int *types, payoff_function payoffs)¶
This creates a game_t struct based on the requested data.
The number of populations must either be 1 or equal to the number of players.
The parameter types is a list of the number of strategies for each player.
The parameter payoffs is the payoff function for the game.
- payoffcache_t * PayoffCache_create(game_t *game, strategyprofiles_t *profiles, cache_mask do_cache)¶
This creates a payoffcache_t struct based on the provided information.
- double * PayoffCache_getPayoffs(payoffcache_t *cache, int profile_index)¶
This returns the payoffs for the cached profile index profile_index.