from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import numpy as np def vars_for_all_templates(self): draw = [] neighbor_draw = [] neighbor_guess = [] neighbor_age = [] neighbor_edu = [] neighbor_gender = [] neighbor_probcourse = [] for i in range(len(self.participant.vars['draw'])): if self.participant.vars['draw'][i]==1: draw.append('global/main_W.png') else: draw.append('global/main_B.png') if self.participant.vars['neighbor_draw'+ str(i+1)]==1: neighbor_draw.append('global/main_W.png') else: neighbor_draw.append('global/main_B.png') neighbor_guess.append(self.participant.vars['neighbor_guess'+ str(i+1)]) if self.participant.vars['treatment'] == 'D_I_w' or self.participant.vars['treatment'] == 'I_D_w': neighbor_age.append(self.participant.vars['neighbor_age'+str(i+1)]) neighbor_edu.append(self.participant.vars['neighbor_edu'+str(i+1)]) if (self.participant.vars['neighbor_gender'+str(i+1)]==1): neighbor_gender.append('Male') elif(self.participant.vars['neighbor_gender'+str(i+1)]==2): neighbor_gender.append('Female') else: neighbor_gender.append('Unknown') if(self.participant.vars['neighbor_probcourse'+str(i+1)]): neighbor_probcourse.append('YES') else: neighbor_probcourse.append('NO') return { 'treatment': self.participant.vars['treatment'], 'Guesses': self.participant.vars['Guesses'], 'Guesses_confidence': self.participant.vars['Guesses_confidence'], 'Guesses_About_Neighbor': self.participant.vars['Guesses_About_Neighbor'], 'Guesses_confidence_About_Neighbor': self.participant.vars['Guesses_condifence_About_Neighbor'], 'neighbor_guess': neighbor_guess, 'neighbor_age': neighbor_age, 'neighbor_probcourse': neighbor_probcourse, 'neighbor_gender': neighbor_gender, 'neighbor_edu': neighbor_edu, 'participation_fee' : c(Constants.participation_fee), 'lottery_a_lo': c(Constants.lottery_a_lo), 'lottery_a_hi': c(Constants.lottery_a_hi), 'lottery_b_lo': c(Constants.lottery_b_lo), 'lottery_b_hi': c(Constants.lottery_b_hi), 'flag': self.participant.vars['flag'], 'competition_award': c(Constants.competition_award), 'draw_path_1': draw[1-1].format(self.round_number), 'struct_path_1': 'global/'+str(self.participant.vars['seq'][1-1])+'.png'.format(self.round_number), 'draw_path_2': draw[2-1].format(self.round_number), 'struct_path_2': 'global/'+str(self.participant.vars['seq'][2-1])+'.png'.format(self.round_number), 'draw_path_3': draw[3-1].format(self.round_number), 'struct_path_3': 'global/'+str(self.participant.vars['seq'][3-1])+'.png'.format(self.round_number), 'draw_path_4': draw[4-1].format(self.round_number), 'struct_path_4': 'global/'+str(self.participant.vars['seq'][4-1])+'.png'.format(self.round_number), 'draw_path_5': draw[5-1].format(self.round_number), 'struct_path_5': 'global/'+str(self.participant.vars['seq'][5-1])+'.png'.format(self.round_number), 'draw_path_6': draw[6-1].format(self.round_number), 'struct_path_6': 'global/'+str(self.participant.vars['seq'][6-1])+'.png'.format(self.round_number), 'draw_path_7': draw[7-1].format(self.round_number), 'struct_path_7': 'global/'+str(self.participant.vars['seq'][7-1])+'.png'.format(self.round_number), 'draw_path_8': draw[8-1].format(self.round_number), 'struct_path_8': 'global/'+str(self.participant.vars['seq'][8-1])+'.png'.format(self.round_number), 'draw_path_9': draw[9-1].format(self.round_number), 'struct_path_9': 'global/'+str(self.participant.vars['seq'][9-1])+'.png'.format(self.round_number), 'draw_path_10': draw[10-1].format(self.round_number), 'struct_path_10': 'global/'+str(self.participant.vars['seq'][10-1])+'.png'.format(self.round_number), 'draw_path_11': draw[11-1].format(self.round_number), 'struct_path_11': 'global/'+str(self.participant.vars['seq'][11-1])+'.png'.format(self.round_number), 'draw_path_12': draw[12-1].format(self.round_number), 'struct_path_12': 'global/'+str(self.participant.vars['seq'][12-1])+'.png'.format(self.round_number), 'draw_path_13': draw[13-1].format(self.round_number), 'struct_path_13': 'global/'+str(self.participant.vars['seq'][13-1])+'.png'.format(self.round_number), 'draw_path_14': draw[14-1].format(self.round_number), 'struct_path_14': 'global/'+str(self.participant.vars['seq'][14-1])+'.png'.format(self.round_number), 'draw_path_15': draw[15-1].format(self.round_number), 'struct_path_15': 'global/'+str(self.participant.vars['seq'][15-1])+'.png'.format(self.round_number), 'draw_path_16': draw[16-1].format(self.round_number), 'struct_path_16': 'global/'+str(self.participant.vars['seq'][16-1])+'.png'.format(self.round_number), 'draw_path_17': draw[17-1].format(self.round_number), 'struct_path_17': 'global/'+str(self.participant.vars['seq'][17-1])+'.png'.format(self.round_number), 'draw_path_18': draw[18-1].format(self.round_number), 'struct_path_18': 'global/'+str(self.participant.vars['seq'][18-1])+'.png'.format(self.round_number), 'draw_path_19': draw[19-1].format(self.round_number), 'struct_path_19': 'global/'+str(self.participant.vars['seq'][19-1])+'.png'.format(self.round_number), 'draw_path_20': draw[20-1].format(self.round_number), 'struct_path_20': 'global/'+str(self.participant.vars['seq'][20-1])+'.png'.format(self.round_number), 'draw_path_21': draw[21-1].format(self.round_number), 'struct_path_21': 'global/'+str(self.participant.vars['seq'][21-1])+'.png'.format(self.round_number), 'neighbor_draw_path_1': neighbor_draw[1-1].format(self.round_number), 'neighbor_struct_path_1': 'global/'+str(self.participant.vars['neighbor_seq'+ str(1)])+'.png'.format(self.round_number), 'neighbor_draw_path_2': neighbor_draw[2-1].format(self.round_number), 'neighbor_struct_path_2': 'global/'+str(self.participant.vars['neighbor_seq'+ str(2)])+'.png'.format(self.round_number), 'neighbor_draw_path_3': neighbor_draw[3-1].format(self.round_number), 'neighbor_struct_path_3': 'global/'+str(self.participant.vars['neighbor_seq'+ str(3)])+'.png'.format(self.round_number), 'neighbor_draw_path_4': neighbor_draw[4-1].format(self.round_number), 'neighbor_struct_path_4': 'global/'+str(self.participant.vars['neighbor_seq'+ str(4)])+'.png'.format(self.round_number), 'neighbor_draw_path_5': neighbor_draw[5-1].format(self.round_number), 'neighbor_struct_path_5': 'global/'+str(self.participant.vars['neighbor_seq'+ str(5)])+'.png'.format(self.round_number), 'neighbor_draw_path_6': neighbor_draw[6-1].format(self.round_number), 'neighbor_struct_path_6': 'global/'+str(self.participant.vars['neighbor_seq'+ str(6)])+'.png'.format(self.round_number), 'neighbor_draw_path_7': neighbor_draw[7-1].format(self.round_number), 'neighbor_struct_path_7': 'global/'+str(self.participant.vars['neighbor_seq'+ str(7)])+'.png'.format(self.round_number), 'neighbor_draw_path_8': neighbor_draw[8-1].format(self.round_number), 'neighbor_struct_path_8': 'global/'+str(self.participant.vars['neighbor_seq'+ str(8)])+'.png'.format(self.round_number), 'neighbor_draw_path_9': neighbor_draw[9-1].format(self.round_number), 'neighbor_struct_path_9': 'global/'+str(self.participant.vars['neighbor_seq'+ str(9)])+'.png'.format(self.round_number), 'neighbor_draw_path_10': neighbor_draw[10-1].format(self.round_number), 'neighbor_struct_path_10': 'global/'+str(self.participant.vars['neighbor_seq'+ str(10)])+'.png'.format(self.round_number), 'neighbor_draw_path_11': neighbor_draw[11-1].format(self.round_number), 'neighbor_struct_path_11': 'global/'+str(self.participant.vars['neighbor_seq'+ str(11)])+'.png'.format(self.round_number), 'neighbor_draw_path_12': neighbor_draw[12-1].format(self.round_number), 'neighbor_struct_path_12': 'global/'+str(self.participant.vars['neighbor_seq'+ str(12)])+'.png'.format(self.round_number), 'neighbor_draw_path_13': neighbor_draw[13-1].format(self.round_number), 'neighbor_struct_path_13': 'global/'+str(self.participant.vars['neighbor_seq'+ str(13)])+'.png'.format(self.round_number), 'neighbor_draw_path_14': neighbor_draw[14-1].format(self.round_number), 'neighbor_struct_path_14': 'global/'+str(self.participant.vars['neighbor_seq'+ str(14)])+'.png'.format(self.round_number), 'neighbor_draw_path_15': neighbor_draw[15-1].format(self.round_number), 'neighbor_struct_path_15': 'global/'+str(self.participant.vars['neighbor_seq'+ str(15)])+'.png'.format(self.round_number), 'neighbor_draw_path_16': neighbor_draw[16-1].format(self.round_number), 'neighbor_struct_path_16': 'global/'+str(self.participant.vars['neighbor_seq'+ str(16)])+'.png'.format(self.round_number), 'neighbor_draw_path_17': neighbor_draw[17-1].format(self.round_number), 'neighbor_struct_path_17': 'global/'+str(self.participant.vars['neighbor_seq'+ str(17)])+'.png'.format(self.round_number), 'neighbor_draw_path_18': neighbor_draw[18-1].format(self.round_number), 'neighbor_struct_path_18': 'global/'+str(self.participant.vars['neighbor_seq'+ str(18)])+'.png'.format(self.round_number), 'neighbor_draw_path_19': neighbor_draw[19-1].format(self.round_number), 'neighbor_struct_path_19': 'global/'+str(self.participant.vars['neighbor_seq'+ str(19)])+'.png'.format(self.round_number), 'neighbor_draw_path_20': neighbor_draw[20-1].format(self.round_number), 'neighbor_struct_path_20': 'global/'+str(self.participant.vars['neighbor_seq'+ str(20)])+'.png'.format(self.round_number), 'neighbor_draw_path_21': neighbor_draw[21-1].format(self.round_number), 'neighbor_struct_path_21': 'global/'+str(self.participant.vars['neighbor_seq'+ str(21)])+'.png'.format(self.round_number), } class Instructions(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): return {'n': Constants.num_rounds, 'image_draw': 'global/main_W.png'.format(self.round_number), 'image_structs': 'global/Instruction.png'.format(self.round_number), 'image_box': 'global/basic.png'.format(self.round_number), 'pic2': 'global/Pic222.png'.format(self.round_number), 'pic1': 'global/Picture1.png'.format(self.round_number)} class Instructions1(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): return {'n': Constants.num_rounds, 'image_draw': 'global/main_W.png'.format(self.round_number), 'image_structs': 'global/Instruction.png'.format(self.round_number), 'image_box': 'global/basic.png'.format(self.round_number), 'pic2': 'global/Pic222.png'.format(self.round_number), 'pic1': 'global/Picture1.png'.format(self.round_number)} class Instructions2(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): return {'n': Constants.num_rounds, 'image_draw': 'global/main_W.png'.format(self.round_number), 'image_structs': 'global/Instruction.png'.format(self.round_number), 'image_box': 'global/basic.png'.format(self.round_number), 'pic2': 'global/Pic222.png'.format(self.round_number), 'pic1': 'global/Picture1.png'.format(self.round_number)} class Instructions3(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): return {'n': Constants.num_rounds, 'image_draw': 'global/main_W.png'.format(self.round_number), 'image_structs': 'global/Instruction.png'.format(self.round_number), 'image_box': 'global/basic.png'.format(self.round_number), 'pic2': 'global/Pic222.png'.format(self.round_number), 'pic1': 'global/Picture1.png'.format(self.round_number), 'finale': 'global/Pic33.png'.format(self.round_number),} class MyPage(Page): form_model = 'player' form_fields = ['Guess_About_Neighbor_1','Guess_About_Neighbor_2','Guess_About_Neighbor_3','Guess_About_Neighbor_4','Guess_About_Neighbor_5', 'Guess_About_Neighbor_6','Guess_About_Neighbor_7','Guess_About_Neighbor_8','Guess_About_Neighbor_9','Guess_About_Neighbor_10', 'Guess_About_Neighbor_11','Guess_About_Neighbor_12','Guess_About_Neighbor_13','Guess_About_Neighbor_14','Guess_About_Neighbor_15', 'Guess_About_Neighbor_16','Guess_About_Neighbor_17','Guess_About_Neighbor_18','Guess_About_Neighbor_19','Guess_About_Neighbor_20', 'Guess_About_Neighbor_21', 'Confidence_for_neighbor_1','Confidence_for_neighbor_2','Confidence_for_neighbor_3','Confidence_for_neighbor_4', 'Confidence_for_neighbor_5','Confidence_for_neighbor_6','Confidence_for_neighbor_7','Confidence_for_neighbor_8', 'Confidence_for_neighbor_9','Confidence_for_neighbor_10','Confidence_for_neighbor_11','Confidence_for_neighbor_12', 'Confidence_for_neighbor_13','Confidence_for_neighbor_14','Confidence_for_neighbor_15','Confidence_for_neighbor_16', 'Confidence_for_neighbor_17','Confidence_for_neighbor_18','Confidence_for_neighbor_19','Confidence_for_neighbor_20', 'Confidence_for_neighbor_21'] def vars_for_template(self): info_structure = {1: [5 / 10, 5 / 10], 2: [6 / 10, 5 / 10], 3: [7 / 10, 5 / 10], 4: [8 / 10, 5 / 10], 5: [9 / 10, 5 / 10], 6: [10 / 10, 5 / 10], 7: [6 / 10, 6 / 10], 8: [7 / 10, 6 / 10], 9: [8 / 10, 6 / 10], 10: [9 / 10, 6 / 10], 11: [10 / 10, 6 / 10], 12: [7 / 10, 7 / 10], 13: [8 / 10, 7 / 10], 14: [9 / 10, 7 / 10], 15: [10 / 10, 7 / 10], 16: [8 / 10, 8 / 10], 17: [9 / 10, 8 / 10], 18: [10 / 10, 8 / 10], 19: [9 / 10, 9 / 10], 20: [10 / 10, 9 / 10], 21: [10 / 10, 10 / 10]} draw = self.participant.vars['draw'][self.round_number-1] structure = info_structure[self.participant.vars['seq'][self.round_number-1]] if draw == 1: return {'choice':[int(structure[0]*10), int(structure[1]*10)], 'color':'WHITE', 'image_path': 'global/main_W.png'.format(self.round_number), 'image_path2': 'global/'+str(self.participant.vars['seq'][self.round_number-1])+'.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number)} else: return {'choice': [int(structure[0]*10), int(structure[1]*10)], 'color': 'BLACK', 'image_path': 'global/main_B.png'.format(self.round_number), 'image_path2': 'global/'+str(self.participant.vars['seq'][self.round_number-1])+'.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number)} def before_next_page(self): pass class MyPage2(Page): form_model = 'player' form_fields = ['Guess1','Guess2','Guess3','Guess4','Guess5','Guess6','Guess7','Guess8','Guess9','Guess10', 'Guess11','Guess12','Guess13','Guess14','Guess15','Guess16','Guess17','Guess18','Guess19','Guess20','Guess21', 'Confidence1','Confidence2','Confidence3','Confidence4','Confidence5','Confidence6','Confidence7','Confidence8', 'Confidence9','Confidence10','Confidence11','Confidence12','Confidence13','Confidence14','Confidence15','Confidence16', 'Confidence17','Confidence18','Confidence19','Confidence20','Confidence21'] def vars_for_template(self): info_structure = {1: [5 / 10, 5 / 10], 2: [6 / 10, 5 / 10], 3: [7 / 10, 5 / 10], 4: [8 / 10, 5 / 10], 5: [9 / 10, 5 / 10], 6: [10 / 10, 5 / 10], 7: [6 / 10, 6 / 10], 8: [7 / 10, 6 / 10], 9: [8 / 10, 6 / 10], 10: [9 / 10, 6 / 10], 11: [10 / 10, 6 / 10], 12: [7 / 10, 7 / 10], 13: [8 / 10, 7 / 10], 14: [9 / 10, 7 / 10], 15: [10 / 10, 7 / 10], 16: [8 / 10, 8 / 10], 17: [9 / 10, 8 / 10], 18: [10 / 10, 8 / 10], 19: [9 / 10, 9 / 10], 20: [10 / 10, 9 / 10], 21: [10 / 10, 10 / 10]} draw = self.participant.vars['draw'][self.round_number-1] structure = info_structure[self.participant.vars['seq'][self.round_number-1]] if self.participant.vars['treatment'] == 'D_I_w' or self.participant.vars['treatment'] == 'I_D_w': return {'choice':[int(structure[0]*10), int(structure[1]*10)], 'color':'WHITE', 'image_path': 'global/main_W.png'.format(self.round_number), 'image_path2': 'global/'+str(self.participant.vars['seq'][self.round_number-1])+'.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number)} else: return {'choice': [int(structure[0]*10), int(structure[1]*10)], 'color': 'BLACK', 'image_path': 'global/main_B.png'.format(self.round_number), 'image_path2': 'global/'+str(self.participant.vars['seq'][self.round_number-1])+'.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number)} def before_next_page(self): self.participant.vars['Guesses_competition'] = dict() self.participant.vars['Guesses_confidence_competition'] = dict() self.participant.vars['Guesses_competition'][1-1] = self.player.get_Guess1_display() self.participant.vars['Guesses_confidence_competition'][1-1] = self.player.Confidence1 self.participant.vars['Guesses_competition'][2-1] = self.player.get_Guess2_display() self.participant.vars['Guesses_confidence_competition'][2-1] = self.player.Confidence2 self.participant.vars['Guesses_competition'][3-1] = self.player.get_Guess3_display() self.participant.vars['Guesses_confidence_competition'][3-1] = self.player.Confidence3 self.participant.vars['Guesses_competition'][4-1] = self.player.get_Guess4_display() self.participant.vars['Guesses_confidence_competition'][4-1] = self.player.Confidence4 self.participant.vars['Guesses_competition'][5-1] = self.player.get_Guess5_display() self.participant.vars['Guesses_confidence_competition'][5-1] = self.player.Confidence5 self.participant.vars['Guesses_competition'][6-1] = self.player.get_Guess6_display() self.participant.vars['Guesses_confidence_competition'][6-1] = self.player.Confidence6 self.participant.vars['Guesses_competition'][7-1] = self.player.get_Guess7_display() self.participant.vars['Guesses_confidence_competition'][7-1] = self.player.Confidence7 self.participant.vars['Guesses_competition'][8-1] = self.player.get_Guess8_display() self.participant.vars['Guesses_confidence_competition'][8-1] = self.player.Confidence8 self.participant.vars['Guesses_competition'][9-1] = self.player.get_Guess9_display() self.participant.vars['Guesses_confidence_competition'][9-1] = self.player.Confidence9 self.participant.vars['Guesses_competition'][10-1] = self.player.get_Guess10_display() self.participant.vars['Guesses_confidence_competition'][10-1] = self.player.Confidence10 self.participant.vars['Guesses_competition'][11-1] = self.player.get_Guess11_display() self.participant.vars['Guesses_confidence_competition'][11-1] = self.player.Confidence11 self.participant.vars['Guesses_competition'][12-1] = self.player.get_Guess12_display() self.participant.vars['Guesses_confidence_competition'][12-1] = self.player.Confidence12 self.participant.vars['Guesses_competition'][13-1] = self.player.get_Guess13_display() self.participant.vars['Guesses_confidence_competition'][13-1] = self.player.Confidence13 self.participant.vars['Guesses_competition'][14-1] = self.player.get_Guess14_display() self.participant.vars['Guesses_confidence_competition'][14-1] = self.player.Confidence14 self.participant.vars['Guesses_competition'][15-1] = self.player.get_Guess15_display() self.participant.vars['Guesses_confidence_competition'][15-1] = self.player.Confidence15 self.participant.vars['Guesses_competition'][16-1] = self.player.get_Guess16_display() self.participant.vars['Guesses_confidence_competition'][16-1] = self.player.Confidence16 self.participant.vars['Guesses_competition'][17-1] = self.player.get_Guess17_display() self.participant.vars['Guesses_confidence_competition'][17-1] = self.player.Confidence17 self.participant.vars['Guesses_competition'][18-1] = self.player.get_Guess18_display() self.participant.vars['Guesses_confidence_competition'][18-1] = self.player.Confidence18 self.participant.vars['Guesses_competition'][19-1] = self.player.get_Guess19_display() self.participant.vars['Guesses_confidence_competition'][19-1] = self.player.Confidence19 self.participant.vars['Guesses_competition'][20-1] = self.player.get_Guess20_display() self.participant.vars['Guesses_confidence_competition'][20-1] = self.player.Confidence20 self.participant.vars['Guesses_competition'][21-1] = self.player.get_Guess21_display() self.participant.vars['Guesses_confidence_competition'][21-1] = self.player.Confidence21 self.participant.vars['Guesses_About_Neighbor_competition'] = dict() self.participant.vars['Guesses_About_Neighbor_confidence_competition'] = dict() self.participant.vars['Guesses_About_Neighbor_competition'][1-1] = self.player.get_Guess_About_Neighbor_1_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][1-1] = self.player.Confidence_for_neighbor_1 self.participant.vars['Guesses_About_Neighbor_competition'][2-1] = self.player.get_Guess_About_Neighbor_2_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][2-1] = self.player.Confidence_for_neighbor_2 self.participant.vars['Guesses_About_Neighbor_competition'][3-1] = self.player.get_Guess_About_Neighbor_3_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][3-1] = self.player.Confidence_for_neighbor_3 self.participant.vars['Guesses_About_Neighbor_competition'][4-1] = self.player.get_Guess_About_Neighbor_4_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][4-1] = self.player.Confidence_for_neighbor_4 self.participant.vars['Guesses_About_Neighbor_competition'][5-1] = self.player.get_Guess_About_Neighbor_5_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][5-1] = self.player.Confidence_for_neighbor_5 self.participant.vars['Guesses_About_Neighbor_competition'][6-1] = self.player.get_Guess_About_Neighbor_6_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][6-1] = self.player.Confidence_for_neighbor_6 self.participant.vars['Guesses_About_Neighbor_competition'][7-1] = self.player.get_Guess_About_Neighbor_7_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][7-1] = self.player.Confidence_for_neighbor_7 self.participant.vars['Guesses_About_Neighbor_competition'][8-1] = self.player.get_Guess_About_Neighbor_8_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][8-1] = self.player.Confidence_for_neighbor_8 self.participant.vars['Guesses_About_Neighbor_competition'][9-1] = self.player.get_Guess_About_Neighbor_9_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][9-1] = self.player.Confidence_for_neighbor_9 self.participant.vars['Guesses_About_Neighbor_competition'][10-1] = self.player.get_Guess_About_Neighbor_10_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][10-1] = self.player.Confidence_for_neighbor_10 self.participant.vars['Guesses_About_Neighbor_competition'][11-1] = self.player.get_Guess_About_Neighbor_11_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][11-1] = self.player.Confidence_for_neighbor_11 self.participant.vars['Guesses_About_Neighbor_competition'][12-1] = self.player.get_Guess_About_Neighbor_12_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][12-1] = self.player.Confidence_for_neighbor_12 self.participant.vars['Guesses_About_Neighbor_competition'][13-1] = self.player.get_Guess_About_Neighbor_13_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][13-1] = self.player.Confidence_for_neighbor_13 self.participant.vars['Guesses_About_Neighbor_competition'][14-1] = self.player.get_Guess_About_Neighbor_14_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][14-1] = self.player.Confidence_for_neighbor_14 self.participant.vars['Guesses_About_Neighbor_competition'][15-1] = self.player.get_Guess_About_Neighbor_15_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][15-1] = self.player.Confidence_for_neighbor_15 self.participant.vars['Guesses_About_Neighbor_competition'][16-1] = self.player.get_Guess_About_Neighbor_16_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][16-1] = self.player.Confidence_for_neighbor_16 self.participant.vars['Guesses_About_Neighbor_competition'][17-1] = self.player.get_Guess_About_Neighbor_17_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][17-1] = self.player.Confidence_for_neighbor_17 self.participant.vars['Guesses_About_Neighbor_competition'][18-1] = self.player.get_Guess_About_Neighbor_18_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][18-1] = self.player.Confidence_for_neighbor_18 self.participant.vars['Guesses_About_Neighbor_competition'][19-1] = self.player.get_Guess_About_Neighbor_19_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][19-1] = self.player.Confidence_for_neighbor_19 self.participant.vars['Guesses_About_Neighbor_competition'][20-1] = self.player.get_Guess_About_Neighbor_20_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][20-1] = self.player.Confidence_for_neighbor_20 self.participant.vars['Guesses_About_Neighbor_competition'][21-1] = self.player.get_Guess_About_Neighbor_21_display() self.participant.vars['Guesses_About_Neighbor_confidence_competition'][21-1] = self.player.Confidence_for_neighbor_21 # ============================================================================= # if self.participant.vars['flag'] == 1: # if self.round_number == Constants.num_rounds: # # set payoff # ============================================================================= self.player.set_payoffs() # ******************************************************************************************************************** # # *** PAGE DECISION *** # # ******************************************************************************************************************** # class Decision(Page): form_model = 'player' form_fields = ['Switching_point'] # def get_form_fields(self): # # # unzip list of form_fields from list # form_fields = [list(t) for t in zip(*self.participant.vars['mpl_choices'])][1] # # return form_fields # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): info_structure = {1: [5 / 10, 5 / 10], 2: [6 / 10, 5 / 10], 3: [7 / 10, 5 / 10], 4: [8 / 10, 5 / 10], 5: [9 / 10, 5 / 10], 6: [10 / 10, 5 / 10], 7: [6 / 10, 6 / 10], 8: [7 / 10, 6 / 10], 9: [8 / 10, 6 / 10], 10: [9 / 10, 6 / 10], 11: [10 / 10, 6 / 10], 12: [7 / 10, 7 / 10], 13: [8 / 10, 7 / 10], 14: [9 / 10, 7 / 10], 15: [10 / 10, 7 / 10], 16: [8 / 10, 8 / 10], 17: [9 / 10, 8 / 10], 18: [10 / 10, 8 / 10], 19: [9 / 10, 9 / 10], 20: [10 / 10, 9 / 10], 21: [10 / 10, 10 / 10]} draw = self.participant.vars['draw'][self.round_number - 1] structure = info_structure[self.participant.vars['seq'][self.round_number - 1]] if draw == 1: return {'choice': [int(structure[0]*10), int(structure[1]*10)], 'color': 'WHITE', 'image_path': 'global/main_W.png'.format(self.round_number), 'image_path2': 'global/' + str(self.participant.vars['seq'][self.round_number - 1]) + '.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number), 'Guess': self.participant.vars['Guesses'][self.round_number-1]} else: return {'choice': [int(structure[0]*10), int(structure[1]*10)], 'color': 'BLACK', 'image_path': 'global/main_B.png'.format(self.round_number), 'image_path2': 'global/' + str(self.participant.vars['seq'][self.round_number - 1]) + '.png'.format(self.round_number), 'image_basic': 'global/basic.png'.format(self.round_number), 'Guess': self.participant.vars['Guesses'][self.round_number-1]} def before_next_page(self): if self.round_number == 1: self.participant.vars['switching_rows'] = dict() self.participant.vars['switching_rows'][self.round_number - 1] = self.player.Switching_point # set player's payoff # ---------------------------------------------------------------------------------------------------------------- # def before_next_page(self): # # # unzip indices and form fields from list # round_number = self.subsession.round_number # form_fields = [list(t) for t in zip(*self.participant.vars['mpl_choices'])][1] # indices = [list(t) for t in zip(*self.participant.vars['mpl_choices'])][0] # index = indices[round_number - 1] # # # if not Constants.one_choice_per_page: # # # replace choices in # for j, choice in zip(indices, form_fields): # choice_i = getattr(self.player, choice) # self.participant.vars['mpl_choices_made'][j - 1] = choice_i # # # set payoff # self.player.set_payoffs() # # determine consistency # self.player.set_consistency() # # set switching row # self.player.set_switching_row() # # self.player.participant_vars_dump = str(self.participant.vars) # ******************************************************************************************************************** # # *** PAGE RESULTS *** # # ******************************************************************************************************************** # # class Results(Page): # # # skip results until last page # # ---------------------------------------------------------------------------------------------------------------- # def is_displayed(self): # if Constants.one_choice_per_page: # return self.subsession.round_number == Constants.num_rounds # else: # return False # # # variables for template # # ---------------------------------------------------------------------------------------------------------------- # def vars_for_template(self): # # # unzip into list of lists # choices = [list(t) for t in zip(*self.participant.vars['mpl_choices'])] # indices = choices[0] # # # get index, round, and choice to pay # index_to_pay = self.player.participant.vars['mpl_index_to_pay'] # round_to_pay = indices.index(index_to_pay) + 1 # choice_to_pay = self.participant.vars['mpl_choices'][round_to_pay - 1] # # if Constants.one_choice_per_page: # return { # 'choice_to_pay': [choice_to_pay], # 'option_to_pay': self.player.in_round(round_to_pay).option_to_pay, # 'payoff': self.player.in_round(round_to_pay).payoff, # } # else: # return { # 'choice_to_pay': [choice_to_pay], # 'option_to_pay': self.player.option_to_pay, # 'payoff': self.player.payoff # } class EndWaitPage(WaitPage): def is_displayed(self): return self.round_number == Constants.num_rounds def after_all_players_arrive(self): pass class Survey(Page): form_model = 'player' form_fields = ['Age', 'Major', 'Education', 'Prob_course', 'Gender', 'Comment_ball', 'Comment_neighbor', 'Feedback'] def is_displayed(self): return True def before_next_page(self): self.participant.vars['Age'] = self.player.Age self.participant.vars['Major'] = self.player.Major self.participant.vars['Education'] = self.player.Education self.participant.vars['Prob_course'] = self.player.Prob_course self.participant.vars['Gender'] = self.player.Gender self.participant.vars['Comment_ball'] = self.player.Comment_ball self.participant.vars['Comment_neighbor'] = self.player.Comment_neighbor self.participant.vars['Feedback'] = self.player.Feedback self.player.participant_vars_dump = str(self.participant.vars) class Results(Page): # ============================================================================= # def is_displayed(self): # if self.participant.vars['flag']==1: # return self.subsession.round_number == Constants.num_rounds # else: # return False # ============================================================================= def is_displayed(self): return True def vars_for_template(self): return {'payoff': self.participant.vars['payoff'], 'rounds_selected': self.participant.vars['pay_off_randrounds'], 'guess_or_post': self.participant.vars['pay_off_guess_or_post'], 'payment': sum(self.participant.vars['payoff'])+Constants.participation_fee, 'competition_score': self.participant.vars['competition_score']} page_sequence = [ Instructions, Instructions1, Instructions2, #Instructions3, MyPage, MyPage2, Survey, # Decision, # EndWaitPage, Results, ] # if Constants.instructions: # page_sequence.insert(0, Instructions) # # if Constants.results: # page_sequence.append(Results)