from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Magnus Strobel' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'signal_belief_choice' players_per_group = None num_rounds = 1 endowment = 4 id_reported_donation_list = {'1': 4.4, '2': 0.0, '3': 4.4, '4': 0.0, '5': 0.0, '6': 4.4, '7': 0.0, '8': 4.4, '9': 4.4, '10': 0.0, '11': 4.4, '12': 0.0, '13': 0.0, '14': 4.4, '15': 0.0, '16': 4.4, '17': 0.0, '18': 4.4, '19': 4.4, '20': 0.0, '21': 4.4, '22': 0.0, '23': 4.4, '24': 0.0, '25': 4.4, '26': 0.0, '27': 4.4, '28': 0.0, '29': 0.0, '30': 4.4, '31': 4.4, '32': 0.0, '33': 4.4, '34': 0.0, '35': 0.0, '36': 4.4, '37': 0.0, '38': 4.4, '39': 4.4, '40': 0.0, '41': 0.0, '42': 4.4, '43': 0.0, '44': 4.4, '45': 4.4, '46': 0.0, '47': 4.4, '48': 0.0, '49': 0.0, '50': 4.4, '51': 4.4, '52': 0.0, '53': 0.0, '54': 4.4, '55': 4.4, '56': 0.0, '57': 4.4, '58': 0.22, '59': 0.22, '60': 4.4, '61': 0.22, '62': 4.4, '63': 4.4, '64': 0.22, '65': 4.4, '66': 0.44, '67': 4.4, '68': 0.44, '69': 0.88, '70': 4.4, '71': 0.88, '72': 4.4, '73': 0.88, '74': 4.4, '75': 1.1, '76': 4.4, '77': 4.4, '78': 1.1, '79': 4.4, '80': 1.1, '81': 1.1, '82': 4.4, '83': 4.4, '84': 1.1, '85': 4.4, '86': 1.1, '87': 4.4, '88': 1.1, '89': 1.1, '90': 4.4, '91': 4.4, '92': 1.1, '93': 1.1, '94': 4.4, '95': 4.4, '96': 1.32, '97': 1.32, '98': 4.4, '99': 4.4, '100': 1.54, '101': 1.54, '102': 4.4, '103': 1.54, '104': 4.4, '105': 1.54, '106': 4.4, '107': 4.4, '108': 1.54, '109': 4.4, '110': 1.76, '111': 1.98, '112': 4.4, '113': 4.4, '114': 1.98, '115': 1.98, '116': 4.4, '117': 4.4, '118': 1.98, '119': 1.98, '120': 4.4, '121': 1.98, '122': 4.4, '123': 4.4, '124': 1.98, '125': 4.4, '126': 1.98, '127': 1.98, '128': 4.4, '129': 4.4, '130': 2.2, '131': 2.2, '132': 4.4, '133': 2.2, '134': 4.4, '135': 4.4, '136': 2.2, '137': 2.2, '138': 4.4, '139': 4.4, '140': 2.2, '141': 4.4, '142': 2.2, '143': 2.2, '144': 4.4, '145': 2.2, '146': 4.18, '147': 2.2, '148': 4.18, '149': 2.2, '150': 4.18, '151': 2.2, '152': 4.18, '153': 2.2, '154': 3.96, '155': 3.96, '156': 2.2, '157': 3.96, '158': 2.2, '159': 3.96, '160': 2.2, '161': 2.2, '162': 3.74, '163': 3.74, '164': 2.2, '165': 2.2, '166': 3.74, '167': 2.2, '168': 3.52, '169': 2.2, '170': 3.3, '171': 2.2, '172': 3.3, '173': 3.3, '174': 2.2, '175': 3.3, '176': 2.2, '177': 3.3, '178': 2.2, '179': 3.3, '180': 2.2, '181': 3.3, '182': 2.2, '183': 2.2, '184': 3.3, '185': 2.2, '186': 3.3, '187': 3.3, '188': 2.2, '189': 2.2, '190': 3.3, '191': 2.2, '192': 3.3, '193': 3.3, '194': 2.2, '195': 2.2, '196': 3.3, '197': 2.2, '198': 3.3, '199': 3.3, '200': 2.42, '201': 3.3, '202': 2.42, '203': 3.3, '204': 2.42, '205': 3.08, '206': 2.42, '207': 2.42, '208': 3.08, '209': 3.08, '210': 2.64, '211': 2.64, '212': 2.64, '213': 2.64, '214': 2.64, '215': 2.64, '216': 2.64} class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: ### Make keys of dict to list ### counter = 1 for p in self.get_players(): ### Get random ids from list and then delete them ### id_A = str(counter) p.id_of_assigned_player_A = id_A p.reported_donation_of_assigned_player_A = str(Constants.id_reported_donation_list.get(id_A)) p.participant.vars["id_of_assigned_player_A"] = id_A counter += 1 id_B = str(counter) p.id_of_assigned_player_B = id_B p.reported_donation_of_assigned_player_B = str(Constants.id_reported_donation_list.get(id_B)) p.participant.vars["id_of_assigned_player_B"] = id_B counter += 1 class Group(BaseGroup): pass class Player(BasePlayer): id_of_assigned_player_A = models.StringField() id_of_assigned_player_B = models.StringField() reported_donation_of_assigned_player_A = models.StringField() reported_donation_of_assigned_player_B = models.StringField() guess_donation_participant_A_public = models.CurrencyField( # blank = True, min = 0, label = "", ) guess_donation_participant_A_private = models.CurrencyField( # blank = True, min = 0, label = "", ) guess_donation_participant_B_public = models.CurrencyField( # blank = True, min = 0, label = "", ) guess_donation_participant_B_private = models.CurrencyField( # blank = True, min = 0, label = "", ) teammate_choice = models.StringField( choices=["Participant A", "Participant B"], label="" ) button_show_me_team_project_clicked = models.StringField() button_remind_me_what_I_did_1_clicked = models.StringField() button_remind_me_what_I_did_2_clicked = models.StringField()