from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) from random import shuffle import random author = 'ML' doc = """ Outro """ class Constants(BaseConstants): name_in_url = 'thankyou' players_per_group = None num_rounds = 1 pairs1_1 = [[7196, 5486], [1497, 5486], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212]] pairs2_1 = [[7196, 6911], [7196, 6911], [7196, 6911], [7196, 6911], [7196, 6911], [7196, 6911], [7196, 6911], [7196, 6911], [2922, 6911], [2922, 1212]] pairs3_1 = [[7196, 6199], [7196, 6199], [7196, 6199], [7196, 6199], [2209, 6199], [2209, 6199], [2209, 1212], [2209, 1212], [2209, 1212], [2209, 1212]] pairs4_1 = [[7196, 5486], [7196, 5486], [7196, 5486], [2922, 5486], [2922, 5486], [2922, 5486], [2922, 5486], [2922, 1212], [2922, 1212], [2922, 1212]] pairs5_1 = [[2708, 7196], [2708, 7196], [2708, 7196], [2708, 7196], [2708, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212]] pairs6_1 = [[4204, 7196], [4204, 7196], [4204, 7196], [4204, 7196], [4204, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 1212]] pairs7_1 = [[7196, 3516], [7196, 3516], [7196, 3516], [1610, 3516], [1610, 3516], [1610, 3516], [1610, 3516], [1610, 3516], [1610, 3516], [1610, 1212]] pairs8_1 = [[1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 7196], [1610, 1212]] pairs_1 = [pairs1_1, pairs2_1, pairs3_1, pairs4_1, pairs5_1, pairs6_1, pairs7_1, pairs8_1] pairs1_2 = [[7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [1212, 4204], [1212, 4204], [1212, 4204], [1212, 4204]] pairs2_2 = [[7196, 4204], [7196, 4204], [7196, 4204], [1212, 4204], [1212, 4204], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs3_2 = [[7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [1212, 4204], [1212, 4204], [1212, 4204], [1212, 1212]] pairs4_2 = [[7196, 4204], [7196, 4204], [1212, 4204], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs5_2 = [[7196, 2708], [7196, 2708], [7196, 2708], [7196, 2708], [1212, 2708], [1212, 4204], [1212, 4204], [1212, 4204], [1212, 4204], [1212, 4204]] pairs6_2 = [[7196, 4204], [7196, 4204], [7196, 4204], [7196, 4204], [1212, 4204], [1212, 2708], [1212, 2708], [1212, 2708], [1212, 2708], [1212, 2708]] pairs7_2 = [[7196, 5700], [7196, 5700], [7196, 5700], [7196, 5700], [7196, 5700], [1212, 5700], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs8_2 = [[7196, 5700], [7196, 5700], [7196, 5700], [7196, 5700], [7196, 5700], [1212, 5700], [5700, 5700], [5700, 5700], [5700, 5700], [5700, 5700]] pairs_2 = [pairs1_2, pairs2_2, pairs3_2, pairs4_2, pairs5_2, pairs6_2, pairs7_2, pairs8_2] pairs1_3 = [[7196, 5486], [1497, 5486], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212], [1497, 1212]] pairs2_3 = [[6911, 7196], [6911, 7196], [6911, 7196], [6911, 7196], [6911, 7196], [6911, 7196], [6911, 7196], [6911, 7196], [6911, 2922], [1212, 2922]] pairs3_3 = [[6443, 7196], [6443, 7196], [6443, 7196], [6443, 7196], [6443, 7196], [6443, 3598], [6443, 3598], [6443, 3598], [1212, 3598], [1212, 3598]] pairs4_3 = [[1212, 1212], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196]] pairs5_3 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [5700, 1212], [1212, 1212], [1212, 1212]] pairs6_3 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [5700, 1212], [5700, 5700], [5700, 5700]] pairs7_3 = [[7196, 7196], [7196, 7196], [6199, 6199], [6199, 6199], [3207, 3207], [3207, 3207], [2209, 3207], [2209, 1212], [1212, 1212], [1212, 1212]] pairs8_3 = [[1212, 7196], [1212, 7196], [7196, 6199], [7196, 6199], [6199, 3207], [6199, 3207], [3207, 3207], [3207, 1212], [2209, 1212], [2209, 1212]] pairs_3 = [pairs1_3, pairs2_3, pairs3_3, pairs4_3, pairs5_3, pairs6_3, pairs7_3, pairs8_3] pairs1_4 = [[7196, 7196], [7196, 7196], [6199, 6199], [6199, 6199], [3207, 3207], [3207, 3207], [2209, 3207], [2209, 1212], [1212, 1212], [1212, 1212]] pairs2_4 = [[1212, 7196], [1212, 7196], [7196, 6199], [7196, 6199], [6199, 3207], [6199, 3207], [3207, 3207], [3207, 1212], [2209, 1212], [2209, 1212]] pairs3_4 = [[5201, 7196], [5201, 7196], [5201, 7196], [5201, 7196], [5201, 7196], [5201, 7196], [5201, 1212], [5201, 1212], [5201, 1212], [1212, 1212]] pairs4_4 = [[5201, 7196], [5201, 7196], [5201, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs5_4 = [[1212, 7196], [1212, 7196], [1212, 7196], [1212, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212]] pairs6_4 = [[4204, 7196], [4204, 7196], [4204, 7196], [4204, 1212], [4204, 1212], [4204, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs7_4 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [5700, 1212], [1212, 1212], [1212, 1212]] pairs8_4 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [5700, 1212], [5700, 5700], [5700, 5700]] pairs_4 = [pairs1_4, pairs2_4, pairs3_4, pairs4_4, pairs5_4, pairs6_4, pairs7_4, pairs8_4] pairs1_5 = [[7196, 7196], [2708, 7196], [2708, 7196], [2708, 7196], [2708, 7196], [2708, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs2_5 = [[7196, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 7196], [1212, 7196], [1212, 7196], [1212, 7196], [1212, 7196]] pairs3_5 = [[4204, 7196], [4204, 7196], [4204, 7196], [4204, 7196], [4204, 7196], [4204, 7196], [4204, 1212], [4204, 1212], [4204, 1212], [1212, 1212]] pairs4_5 = [[4204, 7196], [4204, 7196], [4204, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs5_5 = [[2708, 7196], [2708, 7196], [2708, 7196], [2708, 7196], [2708, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212], [4204, 1212]] pairs6_5 = [[4204, 7196], [4204, 7196], [4204, 7196], [4204, 7196], [4204, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 1212], [2708, 1212]] pairs7_5 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [1212, 1212], [1212, 1212], [1212, 1212], [1212, 1212]] pairs8_5 = [[5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 7196], [5700, 1212], [5700, 5700], [5700, 5700], [5700, 5700], [5700, 5700]] pairs_5 = [pairs1_5, pairs2_5, pairs3_5, pairs4_5, pairs5_5, pairs6_5, pairs7_5, pairs8_5] all_pairs = [pairs_1, pairs_2, pairs_3, pairs_4, pairs_5] #randomly drawn pairs rdp_1 = [pairs_1[7], pairs_1[5], pairs_1[6], pairs_1[3], pairs_1[0], pairs_1[3], pairs_1[5], pairs_1[3]] rdp_2 = [pairs_2[4], pairs_2[5], pairs_2[4], pairs_2[1], pairs_2[4], pairs_2[7], pairs_2[3], pairs_2[7]] rdp_3 = [pairs_3[1], pairs_3[7], pairs_3[7], pairs_3[3], pairs_3[2], pairs_3[2], pairs_3[7], pairs_3[1]] rdp_4 = [pairs_4[4], pairs_4[4], pairs_4[4], pairs_4[3], pairs_4[2], pairs_4[1], pairs_4[1], pairs_4[4]] rdp_5 = [pairs_5[5], pairs_5[6], pairs_5[1], pairs_5[6], pairs_5[7], pairs_5[7], pairs_5[5], pairs_5[2]] rdp = [rdp_1, rdp_2, rdp_3, rdp_4, rdp_5] stages_1 = [3,3,3,3,1,3,3,3] stages_2 = [3,2,3,3,1,3,3,1] stages_3 = [2,3,3,3,3,3,2,3] stages_4 = [3,2,3,3,3,3,3,3] stages_5 = [3,1,3,1,3,3,3,3] chosen_1 = [1,1,2,1,1,2,2,2] chosen_2 = [2,2,1,2,1,2,2,1] chosen_3 = [2,1,2,1,2,1,2,2] chosen_4 = [1,2,1,1,1,2,1,2] chosen_5 = [2,1,2,1,1,2,2,1] class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): order = [] for x in range(10): order.append(x) shuffle(order) p.ord0_1 = order[0] p.ord1_1 = order[1] p.ord2_1 = order[2] p.ord3_1 = order[3] p.ord4_1 = order[4] p.ord5_1 = order[5] p.ord6_1 = order[6] p.ord7_1 = order[7] p.ord8_1 = order[8] p.ord9_1 = order[9] p.abord1 = random.randint(0, 1) if p.id_in_subsession < 81: temp = p.id_in_subsession p.axiom = 0 p.decision = (temp-1) // 10 p.position = (temp-1) % 10 p.stage = Constants.stages_1[p.decision] p.chosen = Constants.chosen_1[p.decision] if p.id_in_subsession > 80 and p.id_in_subsession < 161: temp = p.id_in_subsession - 80 p.axiom = 1 p.decision = (temp-1) // 10 p.position = (temp-1) % 10 p.stage = Constants.stages_2[p.decision] p.chosen = Constants.chosen_2[p.decision] if p.id_in_subsession > 160 and p.id_in_subsession < 241: temp = p.id_in_subsession - 160 p.axiom = 2 p.decision = (temp-1) // 10 p.position = (temp-1) % 10 p.stage = Constants.stages_3[p.decision] p.chosen = Constants.chosen_3[p.decision] if p.id_in_subsession > 240 and p.id_in_subsession < 321: temp = p.id_in_subsession - 240 p.axiom = 3 p.decision = (temp-1) // 10 p.position = (temp-1) % 10 p.stage = Constants.stages_4[p.decision] p.chosen = Constants.chosen_4[p.decision] if p.id_in_subsession > 320: temp = p.id_in_subsession - 320 p.axiom = 4 p.decision = (temp-1) // 10 p.position = (temp-1) % 10 p.stage = Constants.stages_5[p.decision] p.chosen = Constants.chosen_5[p.decision] class Group(BaseGroup): pass class Player(BasePlayer): axiom = models.IntegerField() decision = models.IntegerField() position = models.IntegerField() stage = models.IntegerField() chosen = models.IntegerField() ord1_1 = models.IntegerField() ord2_1 = models.IntegerField() ord3_1 = models.IntegerField() ord4_1 = models.IntegerField() ord5_1 = models.IntegerField() ord6_1 = models.IntegerField() ord7_1 = models.IntegerField() ord8_1 = models.IntegerField() ord9_1 = models.IntegerField() ord0_1 = models.IntegerField() abord1 = models.IntegerField() bonus = models.FloatField() preference = models.IntegerField( label="Which program would you prefer?", choices=[ [0, 'I prefer program A.'], [1, 'I prefer program B.'], ], widget=widgets.RadioSelect ) def set_payoffs(self) -> object: self.participant.vars['bonus'] = self.bonus self.payoff = self.bonus