from otree.api import * from otree.api import BasePlayer import random import math def multiply(value, arg): return value * arg def make_fieldlevel(): return models.IntegerField( choices=[ [1, 'Use my current choices.'], [2, '20% chance to learn correct choices and can reselect, 75% to use current choices, 5% you earn nothing.'], [3, '50% chance to learn correct choices and can reselect, 30% to use current choices, 20% you earn nothing.'], ]) def make_fieldlottery(x): return models.StringField(label='Box A - ' +str(x*25)+'% chance to contain money') def make_fieldchoice(x): return models.StringField(label='Box A - it drew ' +str(x)+'/4 ('+str(x*25)+'%) red balls') class Constants(BaseConstants): name_in_url = 'JMPJoint' players_per_group = None tasks = ['ComparativeChoice','BeliefElicitation'] num_rounds = len(tasks) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): for i in range(0, 5): exec(f"p10comp{i} = models.IntegerField(blank=True)") for i in range(0, 5): exec(f"p25comp{i} = models.IntegerField(blank=True)") for i in range(0, 5): exec(f"p4lott{i} = models.IntegerField(blank=True)") for i in range(0, 5): exec(f"p10lott{i} = models.IntegerField(blank=True)") for i in range(0, 5): exec(f"p25lott{i} = models.IntegerField(blank=True)") for i in range(0,5): locals()['p10complevel'+str(i)] = make_fieldlevel() for i in range(0,5): locals()['p25complevel'+str(i)] = make_fieldlevel() for i in range(0,5): locals()['p4lottlevel'+str(i)] = make_fieldlevel() for i in range(0,5): locals()['p10lottlevel'+str(i)] = make_fieldlevel() for i in range(0,5): locals()['p25lottlevel'+str(i)] = make_fieldlevel() del i rand_q_sequence = models.StringField() test = models.IntegerField() levelexp = models.IntegerField( choices=[ [1, 'Use my current choices.'], [2, '20% chance to learn correct choices and can reselect, 75% to use current choices, 5% you earn nothing.'], [3, '50% chance to learn correct choices and can reselect, 30% to use current choices, 20% you earn nothing.'], ], widget=widgets.RadioSelect, verbose_name="Please choose an option", ) choice1exp=models.IntegerField() choice2exp=models.IntegerField() treatment=models.StringField() payment20draw = models.IntegerField() correctiondraw=models.IntegerField() boxBnumber=models.IntegerField() newchoice = models.IntegerField(min=0, max=25, label="Please enter a number between 0 and 25" ) playerearning = models.IntegerField() playerfinalpayment = models.IntegerField() choicelevel = models.IntegerField() switchingpoint = models.IntegerField() thoughtprocess = models.StringField() winrate = models.IntegerField() prolificID = models.StringField() earning = models.IntegerField() # PAGES # FUNCTIONS def creating_session(subsession: Subsession): if subsession.round_number == 1: for p in subsession.get_players(): round_numbers = list(range(1, Constants.num_rounds + 1)) random.shuffle(round_numbers) task_rounds = dict(zip(Constants.tasks, round_numbers)) p.participant.task_roundscomp = task_rounds treatment = ['sym', 'asy', 'amb'] p.treatment = random.choice(treatment) p.participant.treatment = p.treatment p.treatment = p.participant.treatment del treatment if subsession.round_number == 2: for p in subsession.get_players(): p.payment20draw = random.choice(list(range(101))) p.boxBnumber = random.choice(list(range(26))) p.correctiondraw = random.choice(list(range(101))) p.treatment = p.participant.treatment # PAGES class Consent(Page): form_model = "player" def is_displayed(self): return self.round_number == 1 class Introduction(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class ExampleMPL(Page): form_model = 'player' form_fields = ['choice1exp'] @staticmethod def vars_for_template(player): return dict(right_side_amounts=range(0, 11, 1)) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.choice1exp = player.choice1exp def is_displayed(self): return self.round_number == 1 class ExampleElicit(Page): form_model = 'player' form_fields = ['levelexp'] def is_displayed(self): return self.round_number == 1 class ExampleLearning(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class comp10p0(Page): form_model = 'player' form_fields = ['p10comp0', 'p10complevel0'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10comp0 = player.p10comp0 participant.p10complevel0= player.p10complevel0 class comp10p1(Page): form_model = 'player' form_fields = ['p10comp1', 'p10complevel1'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10comp1 = player.p10comp1 participant.p10complevel1= player.p10complevel1 class comp10p2(Page): form_model = 'player' form_fields = ['p10comp2', 'p10complevel2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10comp2 = player.p10comp2 participant.p10complevel2= player.p10complevel2 class comp10p3(Page): form_model = 'player' form_fields = ['p10comp3', 'p10complevel3'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10comp3 = player.p10comp3 participant.p10complevel3= player.p10complevel3 class comp10p4(Page): form_model = 'player' form_fields = ['p10comp4', 'p10complevel4'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10comp4 = player.p10comp4 participant.p10complevel4= player.p10complevel4 class comp25p0(Page): form_model = 'player' form_fields = ['p25comp0', 'p25complevel0'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25comp0 = player.p25comp0 participant.p25complevel0= player.p25complevel0 class comp25p1(Page): form_model = 'player' form_fields = ['p25comp1', 'p25complevel1'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25comp1 = player.p25comp1 participant.p25complevel1= player.p25complevel1 class comp25p2(Page): form_model = 'player' form_fields = ['p25comp2', 'p25complevel2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25comp2 = player.p25comp2 participant.p25complevel2= player.p25complevel2 class comp25p3(Page): form_model = 'player' form_fields = ['p25comp3', 'p25complevel3'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25comp3 = player.p25comp3 participant.p25complevel3= player.p25complevel3 class comp25p4(Page): form_model = 'player' form_fields = ['p25comp4', 'p25complevel4'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['ComparativeChoice'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25comp4 = player.p25comp4 participant.p25complevel4= player.p25complevel4 class lott4p0(Page): form_model = 'player' form_fields = ['p4lott0', 'p4lottlevel0'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,5)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 4 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p4lott0 = player.p4lott0 participant.p4lottlevel0= player.p4lottlevel0 class lott4p1(Page): form_model = 'player' form_fields = ['p4lott1', 'p4lottlevel1'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,5)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 4 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p4lott1 = player.p4lott1 participant.p4lottlevel1= player.p4lottlevel1 class lott4p2(Page): form_model = 'player' form_fields = ['p4lott2', 'p4lottlevel2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,5)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 4 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p4lott2 = player.p4lott2 participant.p4lottlevel2= player.p4lottlevel2 class lott4p3(Page): form_model = 'player' form_fields = ['p4lott3', 'p4lottlevel3'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,5)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 4 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p4lott3 = player.p4lott3 participant.p4lottlevel3= player.p4lottlevel3 class lott4p4(Page): form_model = 'player' form_fields = ['p4lott4', 'p4lottlevel4'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,5)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 4 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p4lott4 = player.p4lott4 participant.p4lottlevel4= player.p4lottlevel4 class lott10p0(Page): form_model = 'player' form_fields = ['p10lott0', 'p10lottlevel0'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10lott0 = player.p10lott0 participant.p10lottlevel0= player.p10lottlevel0 class lott10p1(Page): form_model = 'player' form_fields = ['p10lott1', 'p10lottlevel1'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10lott1 = player.p10lott1 participant.p10lottlevel1= player.p10lottlevel1 class lott10p2(Page): form_model = 'player' form_fields = ['p10lott2', 'p10lottlevel2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10lott2 = player.p10lott2 participant.p10lottlevel2= player.p10lottlevel2 class lott10p3(Page): form_model = 'player' form_fields = ['p10lott3', 'p10lottlevel3'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10lott3 = player.p10lott3 participant.p10lottlevel3= player.p10lottlevel3 class lott10p4(Page): form_model = 'player' form_fields = ['p10lott4', 'p10lottlevel4'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,11)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 10 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p10lott4 = player.p10lott4 participant.p10lottlevel4= player.p10lottlevel4 class lott25p0(Page): form_model = 'player' form_fields = ['p25lott0', 'p25lottlevel0'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0,26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25lott0 = player.p25lott0 participant.p25lottlevel0= player.p25lottlevel0 class lott25p1(Page): form_model = 'player' form_fields = ['p25lott1', 'p25lottlevel1'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25lott1 = player.p25lott1 participant.p25lottlevel1= player.p25lottlevel1 class lott25p2(Page): form_model = 'player' form_fields = ['p25lott2', 'p25lottlevel2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25lott2 = player.p25lott2 participant.p25lottlevel2= player.p25lottlevel2 class lott25p3(Page): form_model = 'player' form_fields = ['p25lott3', 'p25lottlevel3'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25lott3 = player.p25lott3 participant.p25lottlevel3= player.p25lottlevel3 class lott25p4(Page): form_model = 'player' form_fields = ['p25lott4', 'p25lottlevel4'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task_roundscomp['BeliefElicitation'] @staticmethod def vars_for_template(self): right_side_amounts = [i for i in range(0, 26)] right_side_amounts_percentages = [{"amount": a, "percentage": int(a / 25 * 100)} for a in right_side_amounts] return { 'right_side_amounts_percentages': right_side_amounts_percentages, } @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.p25lott4 = player.p25lott4 participant.p25lottlevel4= player.p25lottlevel4 class Prepayment(Page): form_model = "player" form_fields = ['thoughtprocess'] def is_displayed(self): return self.round_number == 2 def before_next_page(player, timeout_happened): participant = player.participant player.choicelevel = participant.p25complevel3 player.switchingpoint = participant.p25comp3 class ChosenChoiceSym(Page): form_model = "player" def is_displayed(player): return player.treatment == 'sym' and player.round_number==2 def get_form_fields(player): if player.choicelevel == 3: if player.correctiondraw > 50: return ['newchoice'] if player.choicelevel == 2: if player.correctiondraw > 75: return ['newchoice'] else: return [] def vars_for_template(self): numberfromA = list(range(5)) switchingfromB = [{"amount": a, "percentage": math.ceil(11+a)} for a in numberfromA] return { 'switchingfromB': switchingfromB, } def before_next_page(player, timeout_happened): if player.field_maybe_none('newchoice') is not None: participant = player.participant participant.newchoice = player.newchoice else: player.newchoice = 50 class ChosenChoiceAsy(Page): form_model = "player" def is_displayed(player): return player.treatment == 'asy' and player.round_number==2 def get_form_fields(player): if player.choicelevel == 3: if player.correctiondraw > 50: return ['newchoice'] if player.choicelevel == 2: if player.correctiondraw > 75: return ['newchoice'] else: return [] def vars_for_template(self): numberfromA = [0, 1, 2, 3, 4] switchingfromB = [ {"amount": a, "percentage": math.ceil((a * math.log(0.4 / 0.3) + (4 - a) * math.log(0.1 / 0.2) - 25 * math.log(0.1 / 0.2)) / ( math.log(0.4 / 0.3) - math.log(0.1 / 0.2)))} for a in numberfromA] return { 'switchingfromB': switchingfromB, 'numberfromA': numberfromA, } def before_next_page(player, timeout_happened): if player.field_maybe_none('newchoice') is not None: participant = player.participant participant.newchoice = player.newchoice else: player.newchoice = 50 class ChosenChoiceAmb(Page): form_model = "player" def is_displayed(player): return player.treatment == 'amb' and player.round_number==2 def get_form_fields(player): if player.choicelevel == 3: if player.correctiondraw > 50: return ['newchoice'] if player.choicelevel == 2: if player.correctiondraw > 75: return ['newchoice'] else: return [] def vars_for_template(self): numberfromA = [0, 1, 2, 3, 4] switchingfromB = [ {"amount": 0, "percentage": 10}, {"amount": 1, "percentage": 12}, {"amount": 2, "percentage": 14}, {"amount": 3, "percentage": 16}, {"amount": 4, "percentage": 18}, ] return { 'switchingfromB': switchingfromB, 'numberfromA': numberfromA, } def before_next_page(player, timeout_happened): if player.field_maybe_none('newchoice') is not None: participant = player.participant participant.newchoice = player.newchoice else: player.newchoice=50 class FinalOutcomeSym(Page): form_model = "player" form_fields=['prolificID'] def is_displayed(player): return player.treatment == 'sym' and player.round_number==2 def vars_for_template(player): for i in range(26): if player.newchoice < 30: if player.newchoice == i: if i < player.boxBnumber: player.winrate = 80 if i >= player.boxBnumber: player.winrate = math.ceil(100*0.8**i*0.2**(20-i)/(0.8**i*0.2**(20-i)+0.2**i*0.8**(20-i))) else: if player.switchingpoint == i: if i < player.boxBnumber: player.winrate = 80 if i >= player.boxBnumber: player.winrate = math.ceil(100*0.8**i*0.2**(20-i)/(0.8**i*0.2**(20-i)+0.2**i*0.8**(20-i))) if player.winrate < player.payment20draw: player.earning = 0 else: player.earning = 10 class FinalOutcomeAsy(Page): form_model = "player" form_fields = ['prolificID'] def is_displayed(player): return player.treatment == 'asy' and player.round_number==2 def vars_for_template(player): for i in range(26): if player.newchoice < 30: if player.newchoice == i: if i < player.boxBnumber: player.winrate = math.ceil(100*0.8**3*0.2**(1)/(0.8**3*0.2**(1)+0.6**3*0.4**(1))) if i >= player.boxBnumber: player.winrate = math.ceil(100*0.8**i*0.2**(25-i)/(0.8**i*0.2**(25-i)+0.6**i*0.4**(25-i))) else: if player.switchingpoint == i: if i < player.boxBnumber: player.winrate = math.ceil(100*0.8**3*0.2/(0.8**3*0.2+0.6**3*0.4)) if i >= player.boxBnumber: player.winrate = math.ceil(100*0.8**i*0.2**(20-i)/(0.8**i*0.2**(25-i)+0.6**i*0.4**(25-i))) if player.winrate < player.payment20draw: player.earning = 0 else: player.earning = 10 if player.field_maybe_none('newchoice') is None: player.newchoice = 100 class FinalOutcomeAmb(Page): form_model = "player" form_fields = ['prolificID'] def is_displayed(player): return player.treatment == 'amb' and player.round_number==2 def vars_for_template(player): for i in range(26): if player.newchoice < 30: if player.newchoice == i: if i < player.boxBnumber: player.winrate = 70 if i >= player.boxBnumber: if i<=10: player.winrate=math.ceil(100/16) if i>10 & i <15: player.winrate=50 if i>=15: player.winrate=math.ceil(150/16) else: if player.switchingpoint == i: if i < player.boxBnumber: player.winrate = 70 if i >= player.boxBnumber: if i <= 10: player.winrate = math.ceil(100 / 16) if i > 10 & i < 15: player.winrate = 50 if i >= 15: player.winrate = math.ceil(150 / 16) if player.winrate < player.payment20draw: player.earning = 0 else: player.earning = 10 if player.field_maybe_none('newchoice') is None: player.newchoice = 100 class Final(Page): def is_displayed(self): return self.round_number == 2 page_sequence = [Consent, Introduction, ExampleMPL,ExampleElicit,ExampleLearning, comp10p0,comp10p1,comp10p2,comp10p3,comp10p4, comp25p0,comp25p1,comp25p2,comp25p3,comp25p4, lott4p0,lott4p1,lott4p2,lott4p3,lott4p4, lott10p0, lott10p1, lott10p2, lott10p3, lott10p4, lott25p0, lott25p1, lott25p2, lott25p3, lott25p4,Prepayment,ChosenChoiceSym,ChosenChoiceAsy,ChosenChoiceAmb,FinalOutcomeSym,FinalOutcomeAsy,FinalOutcomeAmb,Final]