from otree.api import ( <<<<<<< HEAD models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) ======= models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 doc = """ This is a standard 2-player trust game where the amount sent by player 1 gets tripled. The trust game was first proposed by Berg, Dickhaut, and McCabe (1995) . """ class Constants(BaseConstants): name_in_url = 'trust' players_per_group = 2 num_rounds = 1 <<<<<<< HEAD instructions_template = 'trust/instructions.html' ======= instructions_template = 'trust/Instructions.html' >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 # Initial amount allocated to each player endowment = c(100) multiplier = 3 class Subsession(BaseSubsession): pass class Group(BaseGroup): sent_amount = models.CurrencyField( <<<<<<< HEAD min=0, max=Constants.endowment, doc="""Amount sent by P1""", label="Please enter an amount from 0 to 100:", ) sent_back_amount = models.CurrencyField(doc="""Amount sent back by P2""", min=c(0)) def sent_back_amount_max(self): return self.sent_amount * Constants.multiplier ======= min=0, max=Constants.endowment, doc="""Amount sent by P1""", ) sent_back_amount = models.CurrencyField( doc="""Amount sent back by P2""", min=c(0), ) >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 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): <<<<<<< HEAD pass ======= def role(self): return {1: 'A', 2: 'B'}[self.id_in_group] >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3