from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) doc = """ This is a one-shot "Prisoner's Dilemma". Two players are asked separately whether they want to cooperate or defect. Their choices directly determine the payoffs. """ class Constants(BaseConstants): name_in_url = 'matrixinfo1' players_per_group = 2 num_rounds = 1 instructions_template = 'matrixinfo1/instructions.html' # payoff if 1 player defects and the other cooperates""", both_A_payoff = c(110) both_B_payoff = c(105) both_C_payoff = c(90) both_D_payoff = c(80) both_E_payoff = c(70) # payoff if both players cooperate or both defect A_B_payoff = c(90) A_C_payoff = c(70) A_D_payoff = c(50) A_E_payoff = c(30) B_A_payoff = c(123) B_C_payoff = c(80) B_D_payoff = c(60) B_E_payoff = c(40) C_A_payoff = c(132) C_B_payoff = c(110) C_D_payoff = c(70) C_E_payoff = c(50) D_A_payoff = c(140) D_B_payoff = c(123) D_C_payoff = c(105) D_E_payoff = c(60) E_A_payoff = c(145) E_B_payoff = c(132) E_C_payoff = c(110) E_D_payoff = c(90) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision = models.StringField( choices=[['A', 'A'], ['B', 'B'], ['C', 'C'], ['D', 'D'], ['E', 'E']], doc="""This player's decision""", widget=widgets.RadioSelect, ) def other_player(self): return self.get_others_in_group()[0] def set_payoff(self): self.payoff = 0