from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Ford Combs' doc = """ A decision-making task based on the work by De Martino et al. cited below. (De Martino, B., Kumaran, D., Seymour, B. & Dolan, R. J. Frames, biases and rational decision-making in the human brain. Science (80-. ). (2006). doi:10.1126/science.1128356) """ class Constants(BaseConstants): name_in_url = 'frame_task' players_per_group = None num_rounds = 1 instructions_template = 'frame_task/Instructions.html' class Subsession(BaseSubsession): def creating_session(self): print("creating session") endowment = models.IntegerField() endowment = random.randint(5,15) print(endowment) sure_percentage = models.IntegerField() sure_percentage = random.randint(1,endowment-1) print(sure_percentage) gamble_chance = models.IntegerField() gamble_chance = random.randint(20,80) random_number = models.IntegerField() random_numer = random.randint(0,101) self.session.vars['endowment'] = endowment self.session.vars['sure_amount'] = sure_percentage self.session.vars['gamble_chance'] = gamble_chance self.session.vars['random_number'] = random_number pass class Group(BaseGroup): pass class Player(BasePlayer): payoff = models.CurrencyField() # keep_percentage = IntegerField(random.randint(25,76)) #randonly set keep percentage gambled = models.BooleanField( choices=[ [False, 'Keep'], [True, 'Gamble'], ] ) pass