from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) doc = '' class Constants(BaseConstants): name_in_url = 'blank_app2' players_per_group = 2 num_rounds = 1 class Subsession(BaseSubsession): groupcount = models.IntegerField(initial=0) class Group(BaseGroup): P1ChoiceA = models.BooleanField() P1ChoiceB = models.BooleanField() P2ChoiceA = models.BooleanField() P2ChoiceB = models.BooleanField() DiceA = models.IntegerField() DiceB = models.IntegerField() P1PayA = models.FloatField() P1PayB = models.FloatField() P2PayA = models.FloatField() P2PayB = models.FloatField() P1DiceA = models.IntegerField() P1DiceB = models.IntegerField() P2DiceA = models.IntegerField() P2DiceB = models.IntegerField() Treatment2 = models.IntegerField(initial=0) def Dice(self): import random self.DiceA = random.randrange(100)+1 self.DiceB = random.randrange(100)+1 def AssignTreatment2(self): if self.subsession.groupcount % 2 == self.session.config['Treatment2']: self.Treatment2 = 0 #0 is noinfo, 1 is info else: self.Treatment2 = 1 self.subsession.groupcount=self.subsession.groupcount+1 class Player(BasePlayer): ChoiceA = models.BooleanField(choices=[[True, 'Option A'], [False, 'Option B']], label='', widget=widgets.RadioSelect) ChoiceB = models.BooleanField(choices=[[True, 'Option A'], [False, 'Option B']], label='', widget=widgets.RadioSelect) PayA = models.FloatField() PayB = models.FloatField() WTP = models.FloatField(label='If you could see how your partner chose in each question before your decision, what is the maximum amount you are willing to pay (in cents)?', min=0) DiceA = models.IntegerField() DiceB = models.IntegerField() xyz = models.BooleanField(initial=False) Seq1 = models.IntegerField(choices=[[1, 'Yes - I wanted to follow her/him'], [2, 'Yes - I wanted to pick the opposite option'], [3, "No - it didn't matter to me"]], label="In the second task, did you use your partner's choice as a guidance? If so, how did it affect you?", widget=widgets.RadioSelect) Seq2 = models.IntegerField(choices=[[1, 'Yes - I thought he/she would pick the same option'], [2, 'Yes - I thought he/she would pick the opposite option'], [3, "No - didn't think about it"]], label="When you were making the first decision, did you expect that your partner's choice may be affected by yours?", widget=widgets.RadioSelect) Herd = models.IntegerField(choices=[[1, 'I would want to follow her/him'], [2, 'I would want to pick the opposite option'], [3, "It wouldn't matter to me"]], label='If you get how your partner chose in each question before you decide, how were you going to use that information?', widget=widgets.RadioSelect) def CalcPayoffs(self): if self.ChoiceA: self.PayA = 0.01*self.group.DiceA else: self.PayA = 0.5 if self.ChoiceB: self.PayB = 1*(self.group.DiceB < 41) + 0.1*(self.group.DiceB >= 41) else: self.PayB = 0.4 if self.id_in_group==1: self.group.P1ChoiceA = self.ChoiceA self.group.P1PayA = self.PayA self.group.P1ChoiceB =self.ChoiceB self.group.P1PayB = self.PayB if self.id_in_group==2: self.group.P2ChoiceA = self.ChoiceA self.group.P2PayA = self.PayA self.group.P2ChoiceB =self.ChoiceB self.group.P2PayB = self.PayB self.payoff = self.PayA + self.PayB def CalcPayoffsInd(self): import random self.DiceA=random.randrange(100)+1 self.DiceB=random.randrange(100)+1 if self.ChoiceA: self.PayA = 0.01*self.DiceA else: self.PayA = 0.5 if self.ChoiceB: self.PayB = 1*(self.DiceB < 41) + 0.1*(self.DiceB >= 41) else: self.PayB = 0.4 if self.id_in_group==1: self.group.P1ChoiceA = self.ChoiceA self.group.P1PayA = self.PayA self.group.P1DiceA = self.DiceA self.group.P1ChoiceB =self.ChoiceB self.group.P1PayB = self.PayB self.group.P1DiceB = self.DiceB if self.id_in_group==2: self.group.P2ChoiceA = self.ChoiceA self.group.P2PayA = self.PayA self.group.P2DiceA = self.DiceA self.group.P2ChoiceB =self.ChoiceB self.group.P2PayB = self.PayB self.group.P2DiceB = self.DiceB self.payoff = self.PayA + self.PayB def Upload(self): if self.id_in_group==1: self.group.P1ChoiceA = self.ChoiceA self.group.P1PayA = self.PayA self.group.P1DiceA = self.DiceA self.group.P1ChoiceB =self.ChoiceB self.group.P1PayB = self.PayB self.group.P1DiceB = self.DiceB if self.id_in_group==2: self.group.P2ChoiceA = self.ChoiceA self.group.P2PayA = self.PayA self.group.P2DiceA = self.DiceA self.group.P2ChoiceB =self.ChoiceB self.group.P2PayB = self.PayB self.group.P2DiceB = self.DiceB