from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Round6_agent1' players_per_group = None num_rounds = 1 roundnumber = 6 pot = c(130) highpayoff = c(340) lowpayoff = c(0) outcome = '$0' probability_c0 = 5 probability_c0com = 95 probability_c1 = 30 probability_c1com = 70 probability_c2 = 45 probability_c2com = 55 probability_c3 = 55 probability_c3com = 45 randomnumber_lottery = random.randint(0, 100) nameperformer = 'Priya' pronounperformer = 'She' pronounperformer1 = 'she' Pronounperformer = 'her' ageperformer = '20' Pronounperformer1 = 'her' correct_Puzzles1 = c(4) correct_Puzzles2 = c(2) correct_Puzzles3 = c(3) class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): p.randomnumber_lottery = random.randint(0, 100) def set_gender(self): self.Gender = self.participant.vars['gender1'] def set_age(self): self.Age = self.participant.vars['age'] class Group(BaseGroup): pass class Player(BasePlayer): randomnumber_lottery = models.IntegerField() genderap = models.IntegerField() ageap = models.IntegerField() def genderapp(self): self.genderap = self.participant.vars['gender1'] def ageapp(self): self.ageap = self.participant.vars['age'] Puzzles1 = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8], blank=True ) Puzzles2 = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8], blank=True ) Puzzles3 = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8], blank=True ) SelfBelief1 = models.IntegerField( choices=[0, 1, 2, 3] ) SelfBelief2 = models.IntegerField( choices=[ [1, Constants.lowpayoff], [2, Constants.highpayoff], ], widget=widgets.RadioSelectHorizontal ) SelfBelief3 = models.FloatField(min=0, max=100) problottery = models.IntegerField() profitP = models.CurrencyField() correctQ = models.CurrencyField() final_pay_ran = models.CurrencyField() profitB = models.CurrencyField() final_payoff = models.CurrencyField() Puzzles_Q1_correct = models.IntegerField(initial=0) Puzzles_Q2_correct = models.IntegerField(initial=0) Puzzles_Q3_correct = models.IntegerField(initial=0) total = models.IntegerField(initial=0) def set_payoff1(self): if Constants.correct_Puzzles1 == self.Puzzles1: self.Puzzles_Q1_correct = 1 * 1 if not Constants.correct_Puzzles1 == self.Puzzles1: self.Puzzles_Q1_correct = 0 * 0 def set_payoff2(self): if Constants.correct_Puzzles2 == self.Puzzles2: self.Puzzles_Q2_correct = 1 * 1 if not Constants.correct_Puzzles2 == self.Puzzles2: self.Puzzles_Q2_correct = 0 * 0 def set_payoff3(self): if Constants.correct_Puzzles3 == self.Puzzles3: self.Puzzles_Q3_correct = 1 * 1 if not Constants.correct_Puzzles2 == self.Puzzles2: self.Puzzles_Q3_correct = 0 * 0 def set_payoff_total(self): if self.Puzzles_Q1_correct + self.Puzzles_Q2_correct + self.Puzzles_Q3_correct == 3: self.total = 3 if self.Puzzles_Q1_correct + self.Puzzles_Q2_correct + self.Puzzles_Q3_correct == 2: self.total = 2 if self.Puzzles_Q1_correct + self.Puzzles_Q2_correct + self.Puzzles_Q3_correct == 1: self.total = 1 if self.Puzzles_Q1_correct + self.Puzzles_Q2_correct + self.Puzzles_Q3_correct == 0: self.total = 0 def set_lottery(self): if self.total == 3: self.problottery = Constants.probability_c3 if self.total == 2: self.problottery = Constants.probability_c2 if self.total == 1: self.problottery = Constants.probability_c1 if self.total == 0: self.problottery = Constants.probability_c0 if self.total == None: self.problottery = Constants.probability_c0 def set_profitp1(self): if self.problottery >= self.randomnumber_lottery: self.profitP = Constants.highpayoff if not self.problottery >= self.randomnumber_lottery: self.profitP = Constants.lowpayoff