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 = 'instruct_n' players_per_group = None num_rounds = 1 instructions_template = 'BaNu_n_intro/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): 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(initial=False) 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(initial=False) 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(initial=False) 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(initial=False) 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(initial=False) 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() returning = models.BooleanField( choices=[(True, "Yes, I will participate."), (False, "No, I will not participate.")], widget=widgets.RadioSelect, label = "Will you participate in the experiment tomorrow?" ) def role(self): if self.participant.vars['type'] == 'A': return 'A' else: return 'B'