from otree.api import * c = cu doc = '\nThis is a repeated "Bribery game". A citizen and an officer are asked separately whether they want to offer a bribe, and if the bribe is offered, whether they accept it. The choices directly determine the\npayoffs, which depend on the probability of a third party enforcer being able to punish both the corrupt official and the citizen.\n' class C(BaseConstants): NAME_IN_URL = 'Bribery_Indifference' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 PAYOFF_E_BA_O = cu(-5) PAYOFF_E_BNA_O = cu(5) PAYOFF_E_NB_O = cu(4) PAYOFF_I_BA_O = cu(6) PAYOFF_I_BNA_O = cu(4) PAYOFF_I_NB_O = cu(4) PAYOFF_E_BA_C = cu(-10) PAYOFF_E_BNA_C = cu(-7) PAYOFF_E_NB_C = cu(4) PAYOFF_I_BA_C = cu(9) PAYOFF_I_BNA_C = cu(4) PAYOFF_I_NB_C = cu(4) PROBABILITY = 0.167 INSTRUCTIONS_TEMPLATE = 'Bribery_Indifference/instructions.html' class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): session = subsession.session subsession.group_randomly() class Group(BaseGroup): pass def set_payoffs(group: Group): for p in group.get_players(): set_payoff_citizen(p) set_payoff_officer(p) class Player(BasePlayer): bribe = models.BooleanField(choices=[[True, 'Bribe'], [False, 'Not Bribe']], doc='This player s decision', widget=widgets.RadioSelect) accept = models.BooleanField(choices=[[True, 'Accept Bribe'], [False, 'Not Accept Bribe']], widget=widgets.RadioSelect) control_corruption_punish = models.CurrencyField(label='What payoff does the officer obtain if the citizen offers a bribe, and he(she) accepts the bribe?') control_corruption_impunity = models.CurrencyField(label='How much does the officer obtain if the citizen offers a bribe, and he(she) accepts the bribe, and they are not discovered?') control_transparency = models.CurrencyField(label='How much does the officer earn if the citizen offers a bribe, and he(she) does not accept the bribe?') control_corruption_temptation = models.CurrencyField(label='How much does the citizen earn if he(she) offers a bribe, but the officer does not accept the bribe, and they are discovered?') def set_payoff_citizen(player: Player): payoff_citizen = { (False, True): C.PAYOFF_E_NB_C, (True, True): C.PAYOFF_E_BA_C, (False, False): C.PAYOFF_E_BNA_C, (True, False): C.PAYOFF_E_NB_C, } other=officer_player player.payoff = payoff_citizen[(player.accept, other.bribe)] def officer_player(player: Player): group = player.group return player.get_others_in_group()[0] def set_payoff_officer(player: Player): payoff_officer = { (False, True): C.PAYOFF_E_NB_O, (True, True): C.PAYOFF_E_BA_O, (False, False): C.PAYOFF_E_BNA_O, (True, False): C.PAYOFF_E_NB_O, } other=citizen_player player.payoff = payoff_officer[(player.bribe, other.accept)] def citizen_player(player: Player): group = player.group return player.get_others_in_group()[0] class Introduction(Page): form_model = 'player' form_fields = ['control_corruption_impunity', 'control_transparency', 'control_corruption_punish', 'control_corruption_temptation'] class Citizen_Bribe(Page): form_model = 'player' form_fields = ['bribe'] timeout_seconds = 100 @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 class Officer_Accept(Page): form_model = 'player' form_fields = ['accept'] timeout_seconds = 100 @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 2 class ResultsWaitPage(WaitPage): after_all_players_arrive = set_payoffs class Results(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): return dict( bribe_decision=player.field_display('bribe'), accept_decision=player.field_display('accept'), ) class IntroductionPopulist(Page): form_model = 'player' page_sequence = [Introduction, Citizen_Bribe, Officer_Accept, ResultsWaitPage, Results, IntroductionPopulist]