from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'prisoners' players_per_group = 2 num_rounds = 1 payoff_both_cooperate = -1 payoff_both_defect = -3 payoff_cooperate_defect_high = 0 payoff_cooperate_defect_low = -4 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): defect = models.BooleanField( label="Please choose if you want to cooperate or defect", choices=[ [True,"Defect"], [False, "Cooperate"], ] ) # PAGES class MyPage(Page): form_model = "player" form_fields = ["defect"] class ResultsWaitPage(WaitPage): @staticmethod def after_all_players_arrive(group: Group): player_lists = group.get_players() player_1 = player_lists[0] player_2 = player_lists[1] if player_1.defect: if player_2.defect: player_1.payoff = Constants.payoff_both_defect player_2.payoff = Constants.payoff_both_defect else: player_1.payoff = Constants.payoff_cooperate_defect_high player_2.payoff = Constants.payoff_cooperate_defect_low else: if player_2.defect: player_1.payoff = Constants.payoff_cooperate_defect_high player_2.payoff = Constants.payoff_cooperate_defect_low else: player_1.payoff = Constants.payoff_both_cooperate plaeyr_2.payoff = Constants.payoff_both_cooperate class Results(Page): pass page_sequence = [MyPage, ResultsWaitPage, Results]