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 = 'price_list' players_per_group = None num_rounds = 1 A_1_pay = c(300) A_2_pay = c(350) B_pay = c(160) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): first_choice = models.BooleanField( choices=[[True, 'A'], [False, 'B']], label="I choose...", ) second_choice = models.BooleanField( choices=[[True, 'A'], [False, 'B']], label="I choose...", widget=widgets.RadioSelect ) final_choice = models.IntegerField() lottery = models.BooleanField() def set_payoff(self): self.final_choice = random.choice([1, 2]) self.lottery = random.choice([True, False]) if self.final_choice == 1: if self.first_choice and self.lottery: self.payoff = Constants.A_1_pay if self.first_choice and not self.lottery: self.payoff = c(0) if not self.first_choice: self.payoff = Constants.B_pay else: if self.second_choice and self.lottery: self.payoff = Constants.A_2_pay if self.second_choice and not self.lottery: self.payoff = c(0) if not self.second_choice: self.payoff = Constants.B_pay