from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) doc = '\nThis is a standard 2-player trust game where the amount sent by player 1 gets\ntripled. The trust game was first proposed by\n\n Berg, Dickhaut, and McCabe (1995)\n.\n' class Constants(BaseConstants): name_in_url = 'trust_emc' players_per_group = None num_rounds = 1 endowment = c(50) multiplier = 3 instructions_template = 'trust_emc/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): sent = models.IntegerField(choices=[[0, 'You send 0, the other receives 0'], [10, 'You send 10, the other receives 30'], [20, 'You send 20, the other receives 60'], [30, 'You send 30, the other receives 90'], [40, 'You send 40, the other receives 120'], [50, 'You send 50, the other receives 150']], widget=widgets.RadioSelect) sent_back_30 = models.IntegerField(label='What is the amount you are returning back to the sender?', max=30, min=0) sent_back_60 = models.IntegerField(label='What is the amount you are returning back to the sender?', max=60, min=0) sent_back_90 = models.IntegerField(label='What is the amount you are returning back to the sender?', max=90, min=0) sent_back_120 = models.IntegerField(label='What is the amount you are returning back to the sender?', max=120, min=0) sent_back_150 = models.IntegerField(label='What is the amount you are returning back to the sender?', max=150, min=0) other_received = models.CurrencyField(initial=0) payoff_whensender = models.CurrencyField(initial=0) payoff_whenreceived30 = models.CurrencyField(initial=0) payoff_otherwhen30 = models.CurrencyField(initial=0) payoff_whenreceived60 = models.CurrencyField(initial=0) payoff_otherwhen60 = models.CurrencyField(initial=0) payoff_whenreceived90 = models.CurrencyField(initial=0) payoff_otherwhen90 = models.CurrencyField(initial=0) payoff_whenreceived120 = models.CurrencyField(initial=0) payoff_otherwhen120 = models.CurrencyField(initial=0) payoff_whenreceived150 = models.CurrencyField(initial=0) payoff_otherwhen150 = models.CurrencyField(initial=0) def set_payoff(self): self.payoff_whensender= (Constants.endowment - self.sent) self.other_received = self.sent * 3 def set_payoff_whenreceived30(self): self.payoff_whenreceived30 = 30 - self.sent_back_30 self.payoff_otherwhen30 = 50 - 10 + self.sent_back_30 def set_payoff_whenreceived60(self): self.payoff_whenreceived60 = 60 - self.sent_back_60 self.payoff_otherwhen60 = 50 - 20 + self.sent_back_60 def set_payoff_whenreceived90(self): self.payoff_whenreceived90 = 90 - self.sent_back_90 self.payoff_otherwhen90 = 50 - 30 + self.sent_back_90 def set_payoff_whenreceived120(self): self.payoff_whenreceived120 = 120 - self.sent_back_120 self.payoff_otherwhen120 = 50 - 40 + self.sent_back_120 def set_payoff_whenreceived150(self): self.payoff_whenreceived150 = 150 - self.sent_back_150 self.payoff_otherwhen150 = 50 - 50 + self.sent_back_150