from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import datetime, json, time import math import numpy as np def choices(): choice00000 = (300, 15, 25, 60) return choice00000 # keep 15, 25, 60, no limit def budget(): budget00000 = (10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20) return budget00000 def question(): #question_choice = 34 question_choice = random.randint(1, 36) return question_choice def a15(): baper15 = (5, 4, 3, 5, 3, 3, 3, 6, 3, 4) b15 = random.choices(baper15) return b15[0] def a25(): baper25 = (7, 3, 6, 7, 8, 4, 7, 4, 3, 9) b25 = random.choices(baper25) return b25[0] def a60(): baper60 = (10, 10, 5, 10, 8, 8, 10, 9, 5, 10) b60 = random.choices(baper60) return b60[0] def a300(): baper300 = (9, 9, 10, 9, 10, 10, 9, 10, 10, 9) b300 = random.choices(baper300) return b300[0] def tie(): tiee = (10, 0) tieee = random.choices(tiee) return tieee[0] class instruction_choice(Page): form_model = 'player' form_fields = ['baseline'] def is_displayed(self): return self.round_number == 1 def vars_for_template(self): self.player.baseline = question() self.participant.vars['baseline'] = self.player.baseline self.player.baper15 = a15() self.participant.vars['baper15'] = self.player.baper15 self.player.baper25 = a25() self.participant.vars['baper25'] = self.player.baper25 self.player.baper60 = a60() self.participant.vars['baper60'] = self.player.baper60 self.player.baper300 = a300() self.participant.vars['baper300'] = self.player.baper300 self.player.tieeeee = tie() self.participant.vars['tieeeee'] = self.player.tieeeee return dict( baseline = self.participant.vars['baseline'], baper15 = self.participant.vars['baper15'], baper25=self.participant.vars['baper25'], baper60=self.participant.vars['baper60'], baper300=self.participant.vars['baper300'], tieeeee = self.participant.vars['tieeeee'] ) def js_vars(self): return { 'baseline': self.participant.vars['baseline'], 'baper15': self.participant.vars['baper15'], 'baper25': self.participant.vars['baper25'], 'baper60': self.participant.vars['baper60'], 'baper300': self.participant.vars['baper300'], 'tieeeee': self.participant.vars['tieeeee'] } class survey1_16(Page): form_model = 'player' form_fields = ['choice7'] def is_displayed(self): return self.round_number == 1 def before_next_page(self): if self.player.choice7 == str(300): self.participant.vars['choice7'] = choices()[0] self.player.choice6 = str(300) self.player.choice5 = str(300) self.player.choice4 = str(300) self.player.choice3 = str(300) self.player.choice2 = str(300) self.player.choice1 = str(300) if self.player.choice7 == str(15): self.participant.vars['choice7'] = choices()[1] self.player.choice8 = str(15) self.player.choice9 = str(15) self.player.choice10 = str(15) self.player.choice11 = str(15) class survey1_rest(Page): form_model = 'player' form_fields = ['choice1', 'choice2', 'choice3', 'choice4', 'choice5', 'choice6', 'choice8', 'choice9', 'choice10', 'choice11', 'multiple_switching1'] def is_displayed(self): return self.round_number == 1 def js_vars(self): return { 'choice7': self.participant.vars['choice7'], } def vars_for_template(self): return dict( choice7=self.participant.vars['choice7'] ) def before_next_page(self): self.participant.vars['choice1'] = self.player.choice1 self.participant.vars['choice2'] = self.player.choice2 self.participant.vars['choice3'] = self.player.choice3 self.participant.vars['choice4'] = self.player.choice4 self.participant.vars['choice5'] = self.player.choice5 self.participant.vars['choice6'] = self.player.choice6 self.participant.vars['choice8'] = self.player.choice8 self.participant.vars['choice9'] = self.player.choice9 self.participant.vars['choice10'] = self.player.choice10 self.participant.vars['choice11'] = self.player.choice11 if self.player.multiple_switching1 == 0: self.player.multiple_switching1_1 = 0 self.player.choice1_1 = self.player.choice1 self.player.choice2_1 = self.player.choice2 self.player.choice3_1 = self.player.choice3 self.player.choice4_1 = self.player.choice4 self.player.choice5_1 = self.player.choice5 self.player.choice6_1 = self.player.choice6 self.player.choice7_1 = self.player.choice7 self.player.choice8_1 = self.player.choice8 self.player.choice9_1 = self.player.choice9 self.player.choice10_1 = self.player.choice10 self.player.choice11_1 = self.player.choice11 class survey1_rest_multi(Page): form_model = 'player' form_fields = ['choice1_1', 'choice2_1', 'choice3_1', 'choice4_1', 'choice5_1', 'choice6_1', 'choice7_1', 'choice8_1', 'choice9_1', 'choice10_1', 'choice11_1', 'multiple_switching1_1'] def is_displayed(self): return self.player.multiple_switching1 == 1 def js_vars(self): return { 'choice1_1': self.participant.vars['choice1'], 'choice2_1': self.participant.vars['choice2'], 'choice3_1': self.participant.vars['choice3'], 'choice4_1': self.participant.vars['choice4'], 'choice5_1': self.participant.vars['choice5'], 'choice6_1': self.participant.vars['choice6'], 'choice7_1': self.participant.vars['choice7'], 'choice8_1': self.participant.vars['choice8'], 'choice9_1': self.participant.vars['choice9'], 'choice10_1': self.participant.vars['choice10'], 'choice11_1': self.participant.vars['choice11'], } def vars_for_template(self): return dict( choice1_1=self.participant.vars['choice1'], choice2_1=self.participant.vars['choice2'], choice3_1=self.participant.vars['choice3'], choice4_1=self.participant.vars['choice4'], choice5_1=self.participant.vars['choice5'], choice6_1=self.participant.vars['choice6'], choice7_1=self.participant.vars['choice7'], choice8_1=self.participant.vars['choice8'], choice9_1=self.participant.vars['choice9'], choice10_1=self.participant.vars['choice10'], choice11_1=self.participant.vars['choice11'], ) class survey2_15(Page): form_model = 'player' form_fields = ['choice17'] def is_displayed(self): return self.round_number == 1 def before_next_page(self): if self.player.choice17 == str(300): self.participant.vars['choice17'] = choices()[0] self.player.choice16 = str(300) self.player.choice15 = str(300) self.player.choice14 = str(300) self.player.choice13 = str(300) self.player.choice12 = str(300) if self.player.choice17 == str(25): self.participant.vars['choice17'] = choices()[2] self.player.choice18 = str(25) self.player.choice19 = str(25) self.player.choice20 = str(25) self.player.choice21 = str(25) self.player.choice22 = str(25) class survey2_rest(Page): form_model = 'player' form_fields = ['choice12', 'choice13', 'choice14', 'choice15', 'choice16', 'choice18', 'choice19', 'choice20', 'choice21', 'choice22', 'multiple_switching2'] def is_displayed(self): return self.round_number == 1 def js_vars(self): return { 'choice17': self.participant.vars['choice17'], } def vars_for_template(self): return dict( choice17=self.participant.vars['choice17'] ) def before_next_page(self): if self.player.multiple_switching2 == 0: self.player.multiple_switching2_1 = 0 self.participant.vars['choice12'] = self.player.choice12 self.participant.vars['choice13'] = self.player.choice13 self.participant.vars['choice14'] = self.player.choice14 self.participant.vars['choice15'] = self.player.choice15 self.participant.vars['choice16'] = self.player.choice16 self.participant.vars['choice18'] = self.player.choice18 self.participant.vars['choice19'] = self.player.choice19 self.participant.vars['choice20'] = self.player.choice20 self.participant.vars['choice21'] = self.player.choice21 self.participant.vars['choice22'] = self.player.choice22 if self.player.multiple_switching2 == 0: self.player.choice12_1 = self.player.choice12 self.player.choice13_1 = self.player.choice13 self.player.choice14_1 = self.player.choice14 self.player.choice15_1 = self.player.choice15 self.player.choice16_1 = self.player.choice16 self.player.choice17_1 = self.player.choice17 self.player.choice18_1 = self.player.choice18 self.player.choice19_1 = self.player.choice19 self.player.choice20_1 = self.player.choice20 self.player.choice21_1 = self.player.choice21 self.player.choice22_1 = self.player.choice22 class survey2_rest_multi(Page): form_model = 'player' form_fields = ['choice12_1', 'choice13_1', 'choice14_1', 'choice15_1', 'choice16_1', 'choice18_1', 'choice19_1', 'choice20_1', 'choice21_1', 'choice22_1', 'multiple_switching2_1', 'choice17_1',] def is_displayed(self): return self.player.multiple_switching2 == 1 def js_vars(self): return { 'choice12_1': self.participant.vars['choice12'], 'choice13_1': self.participant.vars['choice13'], 'choice14_1': self.participant.vars['choice14'], 'choice15_1': self.participant.vars['choice15'], 'choice16_1': self.participant.vars['choice16'], 'choice17_1': self.participant.vars['choice17'], 'choice18_1': self.participant.vars['choice18'], 'choice19_1': self.participant.vars['choice19'], 'choice20_1': self.participant.vars['choice20'], 'choice21_1': self.participant.vars['choice21'], 'choice22_1': self.participant.vars['choice22'], } def vars_for_template(self): return dict( choice12_1=self.participant.vars['choice12'], choice13_1=self.participant.vars['choice13'], choice14_1=self.participant.vars['choice14'], choice15_1=self.participant.vars['choice15'], choice16_1=self.participant.vars['choice16'], choice17_1=self.participant.vars['choice17'], choice18_1=self.participant.vars['choice18'], choice19_1=self.participant.vars['choice19'], choice20_1=self.participant.vars['choice20'], choice21_1=self.participant.vars['choice21'], choice22_1=self.participant.vars['choice22'], ) class survey3_14(Page): form_model = 'player' form_fields = ['choice27'] def is_displayed(self): return self.round_number == 1 def before_next_page(self): if self.player.choice27 == str(300): self.participant.vars['choice27'] = choices()[0] self.player.choice26 = str(300) self.player.choice25 = str(300) self.player.choice24 = str(300) self.player.choice23 = str(300) if self.player.choice27 == str(60): self.participant.vars['choice27'] = choices()[3] self.player.choice28 = str(60) self.player.choice29 = str(60) self.player.choice30 = str(60) self.player.choice31 = str(60) self.player.choice32 = str(60) self.player.choice33 = str(60) class survey3_rest(Page): form_model = 'player' form_fields = ['choice23', 'choice24', 'choice25', 'choice26', 'choice28', 'choice29', 'choice30', 'choice31', 'choice32', 'choice33', 'multiple_switching3'] def is_displayed(self): return self.round_number == 1 def js_vars(self): return { 'choice27': self.participant.vars['choice27'], } def vars_for_template(self): return dict( choice27=self.participant.vars['choice27'] ) def before_next_page(self): if self.player.multiple_switching3 == 0: self.player.multiple_switching3_1 = 0 self.participant.vars['choice23'] = self.player.choice23 self.participant.vars['choice24'] = self.player.choice24 self.participant.vars['choice25'] = self.player.choice25 self.participant.vars['choice26'] = self.player.choice26 self.participant.vars['choice28'] = self.player.choice28 self.participant.vars['choice29'] = self.player.choice29 self.participant.vars['choice30'] = self.player.choice30 self.participant.vars['choice31'] = self.player.choice31 self.participant.vars['choice32'] = self.player.choice32 self.participant.vars['choice33'] = self.player.choice33 if self.player.multiple_switching3 == 0: self.player.choice23_1 = self.player.choice23 self.player.choice24_1 = self.player.choice24 self.player.choice25_1 = self.player.choice25 self.player.choice26_1 = self.player.choice26 self.player.choice27_1 = self.player.choice27 self.player.choice28_1 = self.player.choice28 self.player.choice29_1 = self.player.choice29 self.player.choice30_1 = self.player.choice30 self.player.choice31_1 = self.player.choice31 self.player.choice32_1 = self.player.choice32 self.player.choice33_1 = self.player.choice33 class survey3_rest_multi(Page): form_model = 'player' form_fields = ['choice23_1', 'choice24_1', 'choice25_1', 'choice26_1', 'choice27_1', 'choice28_1', 'choice29_1', 'choice30_1', 'choice31_1', 'choice32_1', 'choice33_1', 'multiple_switching3_1'] def is_displayed(self): return self.player.multiple_switching3 == 1 def js_vars(self): return { 'choice23_1': self.participant.vars['choice23'], 'choice24_1': self.participant.vars['choice24'], 'choice25_1': self.participant.vars['choice25'], 'choice26_1': self.participant.vars['choice26'], 'choice27_1': self.participant.vars['choice27'], 'choice28_1': self.participant.vars['choice28'], 'choice29_1': self.participant.vars['choice29'], 'choice30_1': self.participant.vars['choice30'], 'choice31_1': self.participant.vars['choice31'], 'choice32_1': self.participant.vars['choice32'], 'choice33_1': self.participant.vars['choice33'], } def vars_for_template(self): return dict( choice23_1=self.participant.vars['choice23'], choice24_1=self.participant.vars['choice24'], choice25_1=self.participant.vars['choice25'], choice26_1=self.participant.vars['choice26'], choice27_1=self.participant.vars['choice27'], choice28_1=self.participant.vars['choice28'], choice29_1=self.participant.vars['choice29'], choice30_1=self.participant.vars['choice30'], choice31_1=self.participant.vars['choice31'], choice32_1=self.participant.vars['choice32'], choice33_1=self.participant.vars['choice33'], ) class survey4_explanation(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class survey4_1525(Page): form_model = 'player' form_fields = ['choice34'] def is_displayed(self): return self.round_number == 1 class survey4_6015(Page): form_model = 'player' form_fields = ['choice35'] def is_displayed(self): return self.round_number == 1 class survey4_6025(Page): form_model = 'player' form_fields = ['choice36'] def is_displayed(self): return self.round_number == 1 class questionchosen(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return dict( question_chosen=self.participant.vars['baseline'], choose1=self.player.get_choice1_1_display(), choose2=self.player.get_choice2_1_display(), choose3=self.player.get_choice3_1_display(), choose4=self.player.get_choice4_1_display(), choose5=self.player.get_choice5_1_display(), choose6=self.player.get_choice6_1_display(), choose7=self.player.get_choice7_1_display(), choose8=self.player.get_choice8_1_display(), choose9=self.player.get_choice9_1_display(), choose10=self.player.get_choice10_1_display(), choose11=self.player.get_choice11_1_display(), choose12=self.player.get_choice12_1_display(), choose13=self.player.get_choice13_1_display(), choose14=self.player.get_choice14_1_display(), choose15=self.player.get_choice15_1_display(), choose16=self.player.get_choice16_1_display(), choose17=self.player.get_choice17_1_display(), choose18=self.player.get_choice18_1_display(), choose19=self.player.get_choice19_1_display(), choose20=self.player.get_choice20_1_display(), choose21=self.player.get_choice21_1_display(), choose22=self.player.get_choice22_1_display(), choose23=self.player.get_choice23_1_display(), choose24=self.player.get_choice24_1_display(), choose25=self.player.get_choice25_1_display(), choose26=self.player.get_choice26_1_display(), choose27=self.player.get_choice27_1_display(), choose28=self.player.get_choice28_1_display(), choose29=self.player.get_choice29_1_display(), choose30=self.player.get_choice30_1_display(), choose31=self.player.get_choice31_1_display(), choose32=self.player.get_choice32_1_display(), choose33=self.player.get_choice33_1_display(), choose34=self.player.get_choice34_display(), choose35=self.player.get_choice35_display(), choose36=self.player.get_choice36_display(), ) def js_vars(self): return { 'question_chosen': self.participant.vars['baseline'], } def before_next_page(self): if self.participant.vars['baseline'] == 1: if self.player.get_choice1_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice1_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[0] if self.participant.vars['baseline'] == 2: if self.player.get_choice2_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice2_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[1]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[1] if self.participant.vars['baseline'] == 3: if self.player.get_choice3_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice3_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[2]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[2] if self.participant.vars['baseline'] == 4: if self.player.get_choice4_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice4_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[3]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[3] if self.participant.vars['baseline'] == 5: if self.player.get_choice5_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice5_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[4]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[4] if self.participant.vars['baseline'] == 6: if self.player.get_choice6_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice6_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[5]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[5] if self.participant.vars['baseline'] == 7: if self.player.get_choice7_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice7_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[6]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[6] if self.participant.vars['baseline'] == 8: if self.player.get_choice8_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice8_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[7]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[7] if self.participant.vars['baseline'] == 9: if self.player.get_choice9_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice9_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[8]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[8] if self.participant.vars['baseline'] == 10: if self.player.get_choice10_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice10_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[9]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[9] if self.participant.vars['baseline'] == 11: if self.player.get_choice11_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice11_1_display() == str( choices()[1]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[10]): self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[10] if self.participant.vars['baseline'] == 12: if self.player.get_choice12_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice12_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[0] if self.participant.vars['baseline'] == 13: if self.player.get_choice13_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice13_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[1]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[1] if self.participant.vars['baseline'] == 14: if self.player.get_choice14_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice14_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[2]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[2] if self.participant.vars['baseline'] == 15: if self.player.get_choice15_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice15_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[3]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[3] if self.participant.vars['baseline'] == 16: if self.player.get_choice16_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice16_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[4]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[4] if self.participant.vars['baseline'] == 17: if self.player.get_choice17_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice17_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[5]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[5] if self.participant.vars['baseline'] == 18: if self.player.get_choice18_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice18_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[6]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[6] if self.participant.vars['baseline'] == 19: if self.player.get_choice19_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice19_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[7]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[7] if self.participant.vars['baseline'] == 20: if self.player.get_choice20_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice20_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[8]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[8] if self.participant.vars['baseline'] == 21: if self.player.get_choice21_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice21_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[9]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[9] if self.participant.vars['baseline'] == 22: if self.player.get_choice22_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice22_1_display() == str( choices()[2]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[10]): self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[10] if self.participant.vars['baseline'] == 23: if self.player.get_choice23_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice23_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[0]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[0] if self.participant.vars['baseline'] == 24: if self.player.get_choice24_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice24_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[1]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[1] if self.participant.vars['baseline'] == 25: if self.player.get_choice25_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice25_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[2]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[2] if self.participant.vars['baseline'] == 26: if self.player.get_choice26_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice26_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[3]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[3] if self.participant.vars['baseline'] == 27: if self.player.get_choice27_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice27_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[4]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[4] if self.participant.vars['baseline'] == 28: if self.player.get_choice28_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice28_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[5]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[5] if self.participant.vars['baseline'] == 29: if self.player.get_choice29_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice29_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[6]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[6] if self.participant.vars['baseline'] == 30: if self.player.get_choice30_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice30_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[7]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[7] if self.participant.vars['baseline'] == 31: if self.player.get_choice31_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice31_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[8]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[8] if self.participant.vars['baseline'] == 32: if self.player.get_choice32_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice32_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[9]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[9] if self.participant.vars['baseline'] == 33: if self.player.get_choice33_1_display() == 'No time limit per game with a starting budget of \N{euro sign}' + str( budget()[0]): self.participant.vars['time_limit'] = choices()[0] self.participant.vars['budget'] = budget()[0] if self.player.get_choice33_1_display() == str( choices()[3]) + ' seconds per game with a starting budget of \N{euro sign}' + str(budget()[10]): self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[10] if self.participant.vars['baseline'] == 34: if self.player.get_choice34_display() == 'Compete with a time limit of ' + str(choices()[1]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[1]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[0] if self.player.get_choice34_display() == 'Compete with a time limit of ' + str(choices()[2]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[2]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[0] if self.participant.vars['baseline'] == 35: if self.player.get_choice35_display() == 'Compete with a time limit of ' + str(choices()[3]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[3]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[0] if self.player.get_choice35_display() == 'Compete with a time limit of ' + str(choices()[1]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[1]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[1] self.participant.vars['budget'] = budget()[0] if self.participant.vars['baseline'] == 36: if self.player.get_choice36_display() == 'Compete with a time limit of ' + str(choices()[3]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[3]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[3] self.participant.vars['budget'] = budget()[0] if self.player.get_choice36_display() == 'Compete with a time limit of ' + str(choices()[2]) + ' seconds per game against the past performance of someone who also had a time limit of ' + str(choices()[2]) + ' seconds per game': self.participant.vars['time_limit'] = choices()[2] self.participant.vars['budget'] = budget()[0] # Set of games: a = [[78, 46, 13, 67, 65, 25, 34, 15, 47, 62], [68, 15, 42, 29, 27, 41, 19, 23, 36, 33], [76, 51, 48, 11, 47, 15, 65, 39, 35, 63], [91, 75, 69, 44, 64, 16, 35, 62, 33, 49], [68, 16, 17, 49, 14, 22, 41, 57, 19, 21], [91, 69, 25, 17, 55, 26, 13, 75, 22, 72], [55, 21, 17, 33, 26, 9, 41, 27, 34, 23], [93, 65, 58, 32, 79, 77, 31, 71, 76, 17], [84, 41, 72, 46, 26, 48, 35, 32, 49, 28], [85, 23, 54, 72, 42, 62, 49, 58, 38, 69]] class Instructions(Page): form_model = 'player' form_fields = ['my_page_timeout_seconds', 'starting_budget'] timeout_seconds = 5 def vars_for_template(self): if self.round_number == 1: self.player.my_page_timeout_seconds = self.participant.vars['time_limit'] self.player.starting_budget = self.participant.vars['budget'] for i in range(1, 10): if self.round_number % 10 == i: self.participant.vars['game_number'] = i if self.round_number % 10 == 0: self.participant.vars['game_number'] = 10 return dict( timeout_options=self.participant.vars['time_limit'], game_number=self.participant.vars['game_number'], ) def before_next_page(self): self.participant.vars['sssss'] = time.time() def js_vars(self): return { 'timeout_options': self.participant.vars['time_limit'], } class Game1(Page): form_model = 'player' form_fields = ['correct'] def get_timeout_seconds(self): return self.player.my_page_timeout_seconds def vars_for_template(self): if self.round_number == 1: self.participant.vars['set1'] = a self.player.my_page_timeout_seconds = self.participant.vars['time_limit'] self.player.starting_budget = self.participant.vars['budget'] return dict( question_chosen=self.participant.vars['baseline'], game_number=self.participant.vars['game_number'], n=[self.participant.vars['set1'][0][h] for h in range(0, 10)], payoff1=self.participant.vars['budget'], my_page_timeout_seconds=self.participant.vars['time_limit'], ) for i in range(2, 11): if self.round_number == i: self.player.my_page_timeout_seconds = self.participant.vars['time_limit'] self.player.starting_budget = self.participant.vars['budget'] return dict( question_chosen=self.participant.vars['baseline'], game_number=self.participant.vars['game_number'], n=[self.participant.vars['set1'][i - 1][h] for h in range(0, 10)], payoff1=self.player.in_round(i - 1).payoff1, my_page_timeout_seconds=self.participant.vars['time_limit'], ) def before_next_page(self): self.player.time_spent = math.floor(time.time() - self.participant.vars['sssss']) #if self.timeout_happened: # self.player.time_spent = self.player.my_page_timeout_seconds if self.round_number == 1: self.player.payoff1 = self.participant.vars['budget'] else: self.player.payoff1 = self.player.in_round(self.round_number - 1).payoff1 if self.player.correct == 1: self.player.payoff1 = self.player.payoff1 else: self.player.payoff1 = self.player.payoff1 - 1 self.participant.vars['payoff1'] = self.player.payoff1 self.participant.vars['time_spent'] = self.player.time_spent self.participant.vars['number_correct'] = self.participant.vars['game_number'] - (10 - self.player.payoff1) def js_vars(self): for i in range(1, 11): if self.round_number == i: return { 'n': [self.participant.vars['set1'][i - 1][h] for h in range(0, 10)], 'timeout_options': self.participant.vars['time_limit'], 'question_chosen': self.participant.vars['baseline'], } class results(Page): form_model = 'player' form_fields = ['payoff1', 'time_spent'] timeout_seconds = 5 def vars_for_template(self): self.participant.vars['results'] = self.player.correct self.participant.vars['payoff1'] = self.player.payoff1 self.participant.vars['time_spent'] = self.player.time_spent self.participant.vars['number_correct'] = self.participant.vars['game_number'] - (10 - self.player.payoff1) if self.participant.vars['baseline'] < 34: self.participant.vars['payoff_round5'] = self.player.payoff1 if self.participant.vars['baseline'] > 33: if self.participant.vars['time_limit'] == 15: if self.participant.vars['number_correct'] > self.participant.vars['baper15']: self.participant.vars['payoff_round5'] = 10 if self.participant.vars['number_correct'] < self.participant.vars['baper15']: self.participant.vars['payoff_round5'] = 0 if self.participant.vars['number_correct'] == self.participant.vars['baper15']: self.participant.vars['payoff_round5'] = self.participant.vars['tieeeee'] if self.participant.vars['time_limit'] == 25: if self.participant.vars['number_correct'] > self.participant.vars['baper25']: self.participant.vars['payoff_round5'] = 10 if self.participant.vars['number_correct'] < self.participant.vars['baper25']: self.participant.vars['payoff_round5'] = 0 if self.participant.vars['number_correct'] == self.participant.vars['baper25']: self.participant.vars['payoff_round5'] = self.participant.vars['tieeeee'] if self.participant.vars['time_limit'] == 60: if self.participant.vars['number_correct'] > self.participant.vars['baper60']: self.participant.vars['payoff_round5'] = 10 if self.participant.vars['number_correct'] < self.participant.vars['baper60']: self.participant.vars['payoff_round5'] = 0 if self.participant.vars['number_correct'] == self.participant.vars['baper60']: self.participant.vars['payoff_round5'] = self.participant.vars['tieeeee'] if self.participant.vars['time_limit'] == 300: if self.participant.vars['number_correct'] > self.participant.vars['baper300']: self.participant.vars['payoff_round5'] = 10 if self.participant.vars['number_correct'] < self.participant.vars['baper300']: self.participant.vars['payoff_round5'] = 0 if self.participant.vars['number_correct'] == self.participant.vars['baper300']: self.participant.vars['payoff_round5'] = self.participant.vars['tieeeee'] for i in range(1, 11): if self.round_number == i: return dict( my_page_timeout_seconds=self.participant.vars['time_limit'], game_number=self.participant.vars['game_number'], result=self.participant.vars['results'], payoff1=self.participant.vars['payoff1'], time_spent=self.participant.vars['time_spent'], number_correct=self.participant.vars['number_correct'], question_chosen=self.participant.vars['baseline'], ) def js_vars(self): return { 'payoff1': self.participant.vars['payoff1'], 'time_spent': self.participant.vars['time_spent'], 'number_correct': self.participant.vars['number_correct'], 'question_chosen': self.participant.vars['baseline'], } class finish_game(Page): form_model = 'player' def is_displayed(self): return self.round_number == 10 def vars_for_template(self): return dict( number_correct = self.participant.vars['number_correct'], my_page_timeout_seconds=self.participant.vars['time_limit'], payoff_competition = self.participant.vars['payoff_round5'], baper300 = self.participant.vars['baper300'], baper15=self.participant.vars['baper15'], baper25=self.participant.vars['baper25'], baper60=self.participant.vars['baper60'], question_chosen = self.participant.vars['baseline'], ) def js_vars(self): return { 'number_correct': self.participant.vars['number_correct'], 'my_page_timeout_seconds': self.participant.vars['time_limit'], 'payoff_competition': self.participant.vars['payoff_round5'], 'baper15': self.participant.vars['baper15'], 'baper25': self.participant.vars['baper25'], 'baper60': self.participant.vars['baper60'], 'baper300': self.participant.vars['baper300'], 'question_chosen': self.participant.vars['baseline'], } page_sequence = [instruction_choice, survey2_15, survey2_rest, survey2_rest_multi, survey1_16, survey1_rest, survey1_rest_multi, survey3_14, survey3_rest, survey3_rest_multi, survey4_explanation, survey4_1525, survey4_6015, survey4_6025, questionchosen, Instructions, Game1, results, finish_game]