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' players_per_group = 2 num_rounds = 1 endowment = c(100) multiplier = 3 instructions_template = 'trust/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): sent_amount = models.CurrencyField(doc='Amount sent by P1', label='Please enter an amount from 0 to 100', max=Constants.endowment, min=0) sent_back_amount = models.CurrencyField(doc='Amount sent back by P2', min=0) def sent_back_amount_max(self): return self.sent_amount * Constants.multiplier def set_payoffs(self): p1 = self.get_player_by_id(1) p2 = self.get_player_by_id(2) p1.payoff = Constants.endowment - self.sent_amount + self.sent_back_amount p2.payoff = self.sent_amount * Constants.multiplier - self.sent_back_amount class Player(BasePlayer): pass