from otree.api import * doc = """ Rule following task, Akdeniz & Mathew, 2022, Normative versus prosocial underpinnings of human decision making. """ class Constants(BaseConstants): name_in_url = 'part3bucket' players_per_group = None num_rounds = 1 num_balls = 50 points_a = 5 points_b = 10 task = 2 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): balls_A = models.IntegerField() balls_B = models.IntegerField() balls_I = models.IntegerField(min=0, max=0) ex1 = models.CurrencyField( doc="""Answer to first example""", min=0, max=Constants.num_balls*Constants.points_b, label="", ) ex2 = models.CurrencyField( doc="""Answer to second example""", min=0, max=Constants.num_balls*Constants.points_b, label="", ) payment_bucket = models.CurrencyField() bucket_choice = models.IntegerField() def set_payoffs_bucket(self): print('in set_payoffs for bucket') participant = self.participant participant.payment_bucket = self.balls_A * Constants.points_a + self.balls_B * Constants.points_b print('bucket payment is', participant.payment_bucket) participant.bucket_choice = self.balls_A print('bucket choice', participant.bucket_choice)