This is intended to be a set of tools for analyzing normal-form games, particularly with an eye to simulating dynamics and learning.
Basic class for representing a game. Initialization tools exist in the subclass GameSimple()
.
n
number of playersplayers
vector of player indices, essentiallyrange(n)
actions
list of lists of player actionspmat
payoff matrix. Each of dimensions0
thrun-1
corresponds to a player ID, dimn
specifies which player's payoff is being described. Example:pmat[4,5,6,0]
represents player0
's payoff when players0,1,2
are playing actions4,5,6
respectively. Note thatprint(game.pmat)
is fairly unintelligible for games larger than 2x2.
payoffs(players,actionProfile)
returns the payoffs experienced byplayers
under mixed strategy action profileactionProfile
.players
is a list of player indices, andactionProfile
is a complete list of all players' mixed strategies, represented as a list-of-lists. This method outputs an array of floats of lengthlen(players)
.payoffVec(player,actionProfileReduced)
returns the payoffs experienced byplayer
when all others are playing mixed strategies given byactionProfileReduced
(which is of dimensionn-1
). The output is an array of floats of lengthlen(self.actions[player])
, i.e., it gives the payoff associated with each ofplayer
's possible actions.
Only difference from Game
is the __init()
method.
__init__(players,actions,pmat)
takes integerplayers
, length-n list of action setsactions
, and fully-specified payoff matricespmat
(format described above).