from otree.api import * c = cu doc = '\nThis is a one-shot "Prisoner\'s Dilemma". The players are asked separately\nwhether they want to choose option A or B. Before they make their decision, they read a text about charity. Their choices directly determine their payoffs.\n' class C(BaseConstants): NAME_IN_URL = 'Prisoner_Text1' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 PAYOFF_A = cu(1) PAYOFF_B = cu(0.7) PAYOFF_C = cu(0.3) PAYOFF_D = cu(0) INSTRUCTIONS_TEMPLATE = 'Prisoner_Text1/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def set_payoffs(group: Group): for p in group.get_players(): set_payoff(p) class Player(BasePlayer): cooperate = models.BooleanField(choices=[[True, 'Cooperate'], [False, 'Defect']], doc='This player s decision', widget=widgets.RadioSelect) age = models.IntegerField(label='What is your age?') gender = models.StringField(choices=[['female', 'female'], ['male', 'male'], ['diverse', 'diverse']], label='What is your gender?') country = models.StringField(label='What is your country of residence?') religion = models.StringField(choices=[['Yes', 'Yes'], ['No', 'No']], label='Do you describe yourself as religious?') higher_instance = models.StringField(choices=[['Yes', 'Yes'], ['No', 'No']], label='Have you ever had an experience which convinced you of the extistence of God/Gods/comparable higher instances?') education = models.StringField(choices=[['Early childhood education (e.g. nursery)', 'Early childhood education (e.g. nursery)'], ['Primary education (e.g. elementary school)', 'Primary education (e.g. elementary school)'], ['School-leaving qualifications (e.g. high school, college, A-levels...)', 'School-leaving qualifications (e.g. high school, college, A-levels...)'], ['Bachelor or Master level education', 'Bachelor or Master level education'], ['Higher academic education', 'Higher academic education']], label='What is your level of education?') text = models.IntegerField(label='text') comprehension1 = models.StringField(choices=[['You pick A', 'You pick A'], ['You pick B', 'You pick B']], label='Which earns you more money:') comprehension2 = models.StringField(choices=[['You pick A', 'You pick A'], ['You pick B', 'You pick B']], label='Which earns the other person more money:') comprehension3 = models.StringField(choices=[['Other person picks A', 'Other person picks A'], ['Other person picks B', 'Other person picks B']], label='Which earns you more money:') comprehension4 = models.StringField(choices=[['Other person picks A', 'Other person picks A'], ['Other person picks B', 'Other person picks B']], label='Which earns the other person more money:') comprehension5 = models.CurrencyField(label='If you pick B and the other picks A, what bonus will you receive?') def other_player(player: Player): group = player.group return player.get_others_in_group()[0] def set_payoff(player: Player): payoff_matrix = { (False, True): C.PAYOFF_A, (True, True): C.PAYOFF_B, (False, False): C.PAYOFF_C, (True, False): C.PAYOFF_D, } other = other_player(player) player.payoff = payoff_matrix[(player.cooperate, other.cooperate)] class Introduction(Page): form_model = 'player' class Texts(Page): form_model = 'player' class Decision(Page): form_model = 'player' form_fields = ['cooperate'] class Comprehension(Page): form_model = 'player' form_fields = ['comprehension1', 'comprehension2', 'comprehension3', 'comprehension4', 'comprehension5'] class Demographic_questions(Page): form_model = 'player' form_fields = ['age', 'gender', 'country', 'religion', 'higher_instance', 'education'] page_sequence = [Introduction, Texts, Decision, Comprehension, Demographic_questions]