Social Dilemma

Class for a symmetric two-agent stateless social dilemma environment

Typical examples are the Prisoner’s Dilemma, Stag Hunt game, and the game of chicken/snowdrift/hawk-dove.


source

SocialDilemma

 SocialDilemma (R:float, T:float, S:float, P:float)

Symmetric 2-agent 2-action Social Dilemma Matrix Game.

Type Details
R float reward of mutual cooperation
T float temptation of unilateral defection
S float sucker’s payoff of unilateral cooperation
P float punsihment of mutual defection

source

SocialDilemma.TransitionTensor

 SocialDilemma.TransitionTensor ()

Get the Transition Tensor.


source

SocialDilemma.RewardTensor

 SocialDilemma.RewardTensor ()

Get the Reward Tensor R[i,s,a1,…,aN,s’].


source

SocialDilemma.actions

 SocialDilemma.actions ()

The action sets


source

SocialDilemma.states

 SocialDilemma.states ()

The states set


source

SocialDilemma.id

 SocialDilemma.id ()

Returns id string of environment

Example

env = SocialDilemma(R=1, T=2, S=-1, P=0)
env.id()
'SocialDilemma_2_1_0_-1'
env
SocialDilemma_2_1_0_-1

Reward matrix of agent 0:

env.RewardTensor()[0,0,:,:,0]
array([[ 1., -1.],
       [ 2.,  0.]])

Reward matrix of agent 1:

env.RewardTensor()[1,0,:,:,0]
array([[ 1.,  2.],
       [-1.,  0.]])
env.TransitionTensor()
array([[[[1.],
         [1.]],

        [[1.],
         [1.]]]])
env.actions()
[['c', 'd'], ['c', 'd']]
env.states()
['.']