from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import numpy as np import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'my_wlg' players_per_group = 2 num_rounds = 4 paycombos = {'11', '12', '13', '14', '15', '16', '17', '22', '23', '24', '25', '26', '27', '33', '34', '35', '36', '37', '44', '45', '46', '47', '55', '56', '57', '66', '67', '77' } #payofflist = np.array([(c(0.15), c(0.13), c(0.10), c(0.07), c(0.05), c(0.03), c(0.00)), # (c(0.00), c(0.20), c(0.17), c(0.15), c(0.13), c(0.10), c(0.07)), # (c(0.00), c(0.00), c(0.25), c(0.23), c(0.20), c(0.17), c(0.15)), # (c(0.00), c(0.00), c(0.00), c(0.30), c(0.27), c(0.25), c(0.23)), # (c(0.00), c(0.00), c(0.00), c(0.00), c(0.35), c(0.33), c(0.30)), # (c(0.00), c(0.00), c(0.00), c(0.00), c(0.00), c(0.40), c(0.37)), # (c(0.00), c(0.00), c(0.00), c(0.00), c(0.00), c(0.00), c(0.45))]) payofflist = np.array([(0.15, 0.13, 0.10, 0.07, 0.05, 0.03, 0.00), (0.00, 0.20, 0.17, 0.15, 0.13, 0.10, 0.07), (0.00, 0.00, 0.25, 0.23, 0.20, 0.17, 0.15), (0.00, 0.00, 0.00, 0.30, 0.27, 0.25, 0.23), (0.00, 0.00, 0.00, 0.00, 0.35, 0.33, 0.30), (0.00, 0.00, 0.00, 0.00, 0.00, 0.40, 0.37), (0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.45)]) print(payofflist.ndim) class Subsession(BaseSubsession): def creating_session(self): self.group_randomly(fixed_id_in_group=True) print('in creating_session') if self.round_number == 1: paying_round = random.randint(1, Constants.num_rounds) self.session.vars['paying_round'] = paying_round print('set the paying round to', paying_round) class Group(BaseGroup): minnumber = models.IntegerField() min = models.IntegerField() class Player(BasePlayer): numchoice = models.IntegerField(min=1, max=7) charity_yn = models.StringField( choices=['donate $0.10 of my earnings to charity', 'not donate $0.10 of my earnings to charity'], widget=widgets.RadioSelect ) charitychoice = models.StringField() earn = models.DecimalField(max_digits=3, decimal_places=2)