from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'minimum_effort' PLAYERS_PER_GROUP = 3 NUM_ROUNDS = 5 payoff_matrix = [[8.00], [4.00,14.40], [2.00,7.20,17.60], [1.00,3.60,8.80,19.20], [0.50,1.80,4.40,9.60,20.00], [0.25,0.90,2.20,4.80,10.00,20.40], [0.13,0.45,1.10,2.40,5.00,10.20,20.60] ] def creating_session(subsession): subsession.group_randomly() class Subsession(BaseSubsession): pass class Group(BaseGroup): lowest_num = models.IntegerField(initial=0, doc="""Lowest number selected in group""") def get_lowest(group): group.lowest_num = min(player.num_chosen for player in group.get_players()) class Player(BasePlayer): num_chosen = models.PositiveIntegerField(choices=[1,2,3,4,5,6,7], doc="""Number chosen by player""") student_ID = models.IntegerField(label="Please enter your student ID to proceed") def set_payoff(player): group = player.group player.payoff = C.payoff_matrix[(player.num_chosen - 1)][(group.lowest_num - 1)] # PAGES class ID_Entry(Page): form_model = 'player' form_fields = ['student_ID'] @staticmethod def is_displayed(subsession): return subsession.round_number == 1 class FirstPage(Page): form_model = 'player' form_fields = ['num_chosen'] class ResultsWaitPage(WaitPage): @staticmethod def after_all_players_arrive(group: Group): group.get_lowest() for player in group.get_players(): player.set_payoff() class Results(Page): pass class WaitForAll(WaitPage): wait_for_all_groups = True class Final(Page): @staticmethod def is_displayed(subsession): return subsession.round_number == 5 page_sequence = [ID_Entry, FirstPage, ResultsWaitPage, Results, WaitForAll ,Final]