from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as cu, ) import random class Constants(BaseConstants): name_in_url = 'bonus_app' # <- your app folder name players_per_group = None num_rounds = 1 N_GROUPS = 5 N_INFO = 60 TOTAL_SLOTS = N_GROUPS * N_INFO PAYOFF_BY_INFOSET = { 1: cu(0.10), 2: cu(0.20), 3: cu(0.30), 4: cu(0.40), 5: cu(0.50), 6: cu(0.60), 7: cu(0.70), 8: cu(0.80), 9: cu(0.90), 10: cu(1.00), 11: cu(1.10), 12: cu(1.20), 13: cu(1.30), 14: cu(1.40), 15: cu(1.50), 16: cu(1.60), 17: cu(1.70), 18: cu(1.80), 19: cu(1.90), 20: cu(2.00), 21: cu(2.10), 22: cu(2.20), 23: cu(2.30), 24: cu(2.40), 25: cu(2.50), 26: cu(2.60), 27: cu(2.70), 28: cu(2.80), 29: cu(2.90), 30: cu(3.00), 31: cu(3.10), 32: cu(3.20), 33: cu(3.30), 34: cu(3.40), 35: cu(3.50), 36: cu(3.60), 37: cu(3.70), 38: cu(3.80), 39: cu(3.90), 40: cu(4.00), 41: cu(4.10), 42: cu(4.20), 43: cu(4.30), 44: cu(4.40), 45: cu(4.50), 46: cu(4.60), 47: cu(4.70), 48: cu(4.80), 49: cu(4.90), 50: cu(5.00), 51: cu(5.10), 52: cu(5.20), 53: cu(5.30), 54: cu(5.40), 55: cu(5.50), 56: cu(5.60), 57: cu(5.70), 58: cu(5.80), 59: cu(5.90), 60: cu(6.00), } class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): tg = p.participant.vars.get('tg') info_id = p.participant.vars.get('info_set') if tg is None or info_id is None: raise RuntimeError( "Missing tg/info_set in participant.vars. Assign them in the first app." ) p.tg = tg p.info_set = info_id class Group(BaseGroup): pass class Player(BasePlayer): tg = models.IntegerField() info_set = models.IntegerField() choices = models.IntegerField( choices=[ [1, 'Option 1'], [2, 'Option 2'], ], widget=widgets.RadioSelect, blank = True )