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 = 'Part1' players_per_group = None num_rounds = 1 instructions_template = 'nuclear1/instructions.html' class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.participant.vars['paying_round'] = random.randint(1, 11) if (p.id_in_group % 2) == 0: p.participant.vars['type'] = 'B' else: p.participant.vars['type'] = 'A' class Group(BaseGroup): pass class Player(BasePlayer): mturk_id = models.CharField(label="MTurk ID:") female = models.IntegerField(choices=[(0, "Male"), (1, "Female"), (2, "Non-binary")], #widget=widgets.RadioSelect, label="Please indicate your gender.") age = models.IntegerField(min=15, max=100, label="How old are you?") education = models.IntegerField(choices=[(1, "Haven't graduated high school."), (2, "GED"), (3, "High school graduate"), (4, "Currently in college"), (5, "Bachelors"), (6, "Masters"), (7, "Professional degree (JD, MD, MBA)"), (8, "Doctorate")], #widget=widgets.RadioSelect, label="What is your highest educational degree? If you cannot find your degree in the following list, please indicate which degree from the list is closest to your actual degree.") employment = models.IntegerField(choices=[(1, "Employed full-time"), (2, "Employed part-time"), (3, "Independent, or business owner"), (4, "Out of work, or seeking work"), (5, "Student"), (6, "Out of labor force (e.g. retired or parent raising one or more children)"), ], #widget=widgets.RadioSelect, label="What is your current employment status?") income = models.IntegerField(choices=[(1, "$0 - $9,999"), (2, "$10,000 - $14,999"), (3, "$15,000 - $19,999"), (4, "$20,000 - $29,999"), (5, "$30,000 - $39,999"), (6, "$40,000 - $49,999"), (7, "$50,000 - $74,999"), (8, "$75,000 - $99,999"), (9, "$100,000 - $124,999"), (10, "$125,000 - $149,999"), (11, "$150,000 - $199,999"), (12, "$200,000+") ], #widget=widgets.RadioSelect, label="How high was your total household income, before taxes, last year (2019)?") #state = models.CharField(label="In which state do you live?") state = models.IntegerField(choices=[(1, "Alabama"), (2, "Alaska"), (3, "American Samoa"), (4, "Arizona"), (5, "Arkansas"), (6, "California"), (7, "Colorado"), (8, "Connecticut"), (9, "Delaware"), (10, "District Of Columbia"), (11, "Federated States Of Micronesia"), (12, "Florida"), (13, "Georgia"), (14, "Guam"), (15, "Hawaii"), (16, "Idaho"), (17, "Illinois"), (18, "Indiana"), (19, "Iowa"), (20, "Kansas"), (21, "Kentucky"), (22, "Louisiana"), (23, "Maine"), (24, "Marshall Islands"), (25, "Maryland"), (26, "Massachusetts"), (27, "Michigan"), (28, "Minnesota"), (29, "Mississippi"), (30, "Missouri"), (31, "Montana"), (32, "Nebraska"), (33, "Nevada"), (34, "New Hampshire"), (35, "New Jersey"), (36, "New Mexico"), (37, "New York"), (38, "North Carolina"), (39, "North Dakota"), (40, "Northern Mariana Islands"), (41, "Ohio"), (42, "Oklahoma"), (43, "Oregon"), (44, "Palau"), (45, "Pennsylvania"), (46, "Puerto Rico"), (47, "Rhode Island"), (48, "South Carolina"), (49, "South Dakota"), (50, "Tennessee"), (51, "Texas"), (52, "Utah"), (53, "Vermont"), (54, "Virgin Islands"), (55, "Virginia"), (56, "Washington"), (57, "West Virginia"), (58, "Wisconsin"), (59, "Wyoming")],#widget=widgets.RadioSelect, label="In which state do you live?") ethnicity = models.IntegerField(choices=[(1, "Hispanic or Latino"), (2, "American Indian or Alaskan Native"), (3, "Asian"), (4, "Native Hawaiian or Other Pacific Islander"), (5, "Black or African American"), (6, "White"),], #widget=widgets.RadioSelect, label="Which of the following best describes your race or ethnicity?") experience = models.IntegerField(label="How many hours per week do you spend online doing tasks for money?", min=0) attention = models.IntegerField(choices=[(1, "Option A: Probability 20% and $1.90"), (2, "Option B: Probability 30% and $1.80"), (3, "Option C: Probability 40% and $1.70"), (4, "Option D: Probability 50% and $1.60"), (5, "Option E: Probability 60% and $1.50"), (6, "Option F: Probability 70% and $1.40")], widget=widgets.RadioSelect, label="Please choose one option:") control1 = models.IntegerField(choices=[(1, "11 rounds with 11 rounds determining your payoff"), (2, "1 round with 1 round determining your payoff"), (3, "20 rounds with 1 round determining your payoff"), (4, "11 round with 1 round determining your payoff"), (5, "20 rounds with 20 rounds determining your payoff"), ], widget=widgets.RadioSelect, label="How many rounds are you going to play after the practice sessions " "and how many of these rounds are going to determine your payoff?") control2 = models.IntegerField(choices=[(1, "Either A or B. But my role will be fixed."), (2, "Either A or B. I will play both roles."), (3, "Either A or B or C. I will play all three roles."), (4, "Either A or B or C. But my role will be fixed."), (5, "Either A or B or C. But I will play only two of the three roles."), ], widget=widgets.RadioSelect, label="Which role can you have during today's experiment?") control3 = models.IntegerField(choices=[(1, "To negotiate how to split a pie of 300 tokens"), (2, "To decide how much of your 300 tokens the other play will receive"), (3, "To negotiate how to split a pie of 150 tokens"), (4, "To decide how much of your 150 tokens the other play will receive"), (5, "To negotiate how to split a pie of 100 tokens"), (6, "To decide how much of your 100 tokens the other play will receive")], widget=widgets.RadioSelect, label="What is your task?") control4 = models.IntegerField(choices=[(1, "The negotiation ends immediately and the division of the 150 tokens is implemented according to the accepted proposal"), (2, "The negotiation ends immediately and the division of the 100 tokens is implemented according to the accepted proposal"), (3, "The negotiation ends immediately and the division of the 300 tokens is implemented according to the accepted proposal"), (4, "The negotiation ends immediately and the other person receives the accepted amount from your 150 tokens"), (5, "The negotiation ends immediately and the other person receives the accepted amount from your 100 tokens"), (6, "The negotiation ends immediately and the other person receives the accepted amount from your 300 tokens")], widget=widgets.RadioSelect, label="What happens in case of an agreement?") control5 = models.IntegerField(choices=[(1, "Each person obtains a payoff of zero."), (2, "Each person obtains a random number between zero and 150 as their payoff."), (3, "Each person obtains their no-agreement payoff."), (4, "You can keep your 100 tokens and the other person obtains a payoff of zero."), (5, "You can keep your 150 tokens and the other person obtains a payoff of zero."), (6, "You can keep your 300 tokens and the other person obtains a payoff of zero.")], widget=widgets.RadioSelect, label="What happens in case there is no agreement?") control6 = models.IntegerField(choices=[(1, "C can reduce the payoff of A or B"), (2, "A can change the results."), (3, "B can change the results."), (4, "Nothing. The round finishes."), (5, "A and B can change the results together."), ], widget=widgets.RadioSelect, label="What is the last step in a round when no agreement has been reached?") currentA1 = models.IntegerField(initial=100, blank=True, null=True) historyA1 = models.CharField(initial="", blank=True, null=True) currentB1 = models.IntegerField(initial=100, blank=True, null=True) historyB1 = models.CharField(initial="", blank=True, null=True) nuclear1 = models.BooleanField() currentA2 = models.IntegerField(initial=100, blank=True, null=True) historyA2 = models.CharField(initial="", blank=True, null=True) currentB2 = models.IntegerField(initial=100, blank=True, null=True) historyB2 = models.CharField(initial="", blank=True, null=True) nuclear2 = models.BooleanField() final_offer2 = models.IntegerField(initial=0, blank=True, null=True) time_final2 = models.CharField(blank=True, null=True) failed2 = models.BooleanField(initial=False, blank=True, null=True) currentA3 = models.IntegerField(initial=100, blank=True, null=True) historyA3 = models.CharField(initial="", blank=True, null=True) currentB3 = models.IntegerField(initial=100, blank=True, null=True) historyB3 = models.CharField(initial="", blank=True, null=True) nuclear3 = models.BooleanField() final_offer3 = models.IntegerField(initial=0, blank=True, null=True) time_final3 = models.CharField(blank=True, null=True) failed3 = models.BooleanField(initial=False, blank=True, null=True) currentA4 = models.IntegerField(initial=100, blank=True, null=True) historyA4 = models.CharField(initial="", blank=True, null=True) currentB4 = models.IntegerField(initial=100, blank=True, null=True) historyB4 = models.CharField(initial="", blank=True, null=True) nuclear4 = models.BooleanField() final_offer4 = models.IntegerField(initial=0, blank=True, null=True) time_final4 = models.CharField(blank=True, null=True) failed4 = models.BooleanField(initial=False, blank=True, null=True) currentA5 = models.IntegerField(initial=100, blank=True, null=True) historyA5 = models.CharField(initial="", blank=True, null=True) currentB5 = models.IntegerField(initial=100, blank=True, null=True) historyB5 = models.CharField(initial="", blank=True, null=True) nuclear5 = models.BooleanField() final_offer5 = models.IntegerField(initial=0, blank=True, null=True) time_final5 = models.CharField(blank=True, null=True) failed5 = models.BooleanField(initial=False, blank=True, null=True) belief1 = models.IntegerField(min=0, max=100) belief2 = models.IntegerField(min=0, max=100) belief3 = models.IntegerField(min=0, max=100) belief4 = models.IntegerField(min=0, max=100) belief5 = models.IntegerField(min=0, max=100) belief6 = models.IntegerField(min=0, max=100) belief7 = models.IntegerField(min=0, max=100) belief8 = models.IntegerField(min=0, max=100) belief9 = models.IntegerField(min=0, max=100) belief10 = models.IntegerField(min=0, max=100) belief11 = models.IntegerField(min=0, max=100) self_prediction1 = models.IntegerField(min=0, max=100) self_prediction2 = models.IntegerField(min=0, max=100) self_prediction3 = models.IntegerField(min=0, max=100) self_prediction4 = models.IntegerField(min=0, max=100) self_prediction5 = models.IntegerField(min=0, max=100) self_prediction6 = models.IntegerField(min=0, max=100) self_prediction7 = models.IntegerField(min=0, max=100) self_prediction8 = models.IntegerField(min=0, max=100) self_prediction9 = models.IntegerField(min=0, max=100) self_prediction10 = models.IntegerField(min=0, max=100) self_prediction11 = models.IntegerField(min=0, max=100) active = models.BooleanField(initial=True) arrival = models.CharField() def role(self): if self.participant.vars['type'] == 'A': return 'A' else: return 'B'