from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Tobias Regner' doc = """ Simple trust game """ class Constants(BaseConstants): name_in_url = 'TGself' players_per_group = 2 num_rounds = 1 treatment = 2 endowment = 10 multiplier = 3 instructions_template = 'TGself/instructions.html' Overview = 'TGself/InstructionsOverview.html' instructions_decision = 'TGself/InstrucDecisionSituation.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): # sent_amount = models.CurrencyField( # min=c(0), # max=Constants.endowment, # doc="""Amount sent by P1""", # label="How much do you want to send to participant B?", # ) sent_amountA = models.FloatField( choices=[0, 2.5, 5, 7.5, 10], doc="""Amount sent by participant A""", label="How much do you want to send to participant B?", ) sent_amountB = models.FloatField( choices=[0, 2.5, 5, 7.5, 10], doc="""Amount sent by participant A""", label="How much do you want to send to participant B?", ) sent_back_amountA100 = models.FloatField( doc="""Amount sent back by participant B""", label="How much do you want to send back, " "if the back transfer will be implemented with certainty?" ) sent_back_amountA90 = models.FloatField( doc="""Amount sent back by participant B""", label="How much do you want to send back, " "if the back transfer will be implemented with 90%?" ) sent_back_amountB100 = models.FloatField( doc="""Amount sent back by participant B""", label="How much do you want to send back, " "if the back transfer will be implemented with certainty?" ) sent_back_amountB90 = models.FloatField( doc="""Amount sent back by participant B""", label="How much do you want to send back, " "if the back transfer will be implemented with 90%?" ) def sent_back_amount_choices(self): return currency_range(c(0), self.sent_amount * Constants.multiplier, c(1)) def set_payoffs(self): p1 = self.get_player_by_id(1) p2 = self.get_player_by_id(2) p1.payoff = Constants.endowment - self.sent_amountA + self.sent_back_amountB100 p2.payoff = self.sent_amountA * Constants.multiplier - self.sent_back_amountB100 class Player(BasePlayer): pass