from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'initialize' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 SAMPLED_INDS = (36, 1511, 1231, 166, 176, 1434, 221, 1433, 917, 806, 58, 1089, 1036, 790, 1568, 773, 1166, 608, 67, 703, 1465, 1276, 124, 966, 489, 49, 361, 1319, 1449, 837, 1158, 607, 1130, 50, 822, 893, 1447, 357, 1392, 1571, 1561, 1187, 1516, 1461, 868, 375, 807, 691, 188, 508, 217, 1532, 1079, 1519, 1191, 1261, 855, 5, 1470, 834, 1302, 437, 55, 976, 693, 1221, 33, 524, 560, 315, 1035, 158, 1373, 162, 193, 877, 990, 455, 599, 367, 1112, 824, 901, 96, 830, 1555, 948, 495, 318, 47, 241, 875, 1229, 327, 28, 593, 201, 1454, 1512, 231, 450, 255, 428, 219, 812, 97, 844, 1253, 1136, 1263, 347, 1124, 594, 29, 1514, 999, 91, 1197, 1441, 359, 638, 1382, 441, 499, 251, 1365, 787, 456, 529, 1483, 963, 198, 729, 1173, 668, 1043, 63, 899, 144, 344, 959, 865, 1274, 1292, 660, 6, 239, 439, 1045, 470, 401, 1162, 1499, 1358, 658, 182, 1151, 1309, 457, 937, 1303, 427, 1125, 1069, 260, 983, 1088, 891, 111, 1437, 518, 115, 908, 167, 126, 585, 1335, 964, 1438, 895, 592, 1131, 1189, 1466, 474, 257, 1310, 883, 120, 697, 526, 847, 1265, 338, 1266, 1167, 774, 1339, 941, 666) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def get_triplets(group: Group): import csv import os players=group.get_players() for p in players: rawdata=[] all_files=os.listdir('csv_experiments') for file in all_files: with open('csv_experiments/'+file, newline='') as f: reader=csv.reader(f) subdata=[] for row in reader: subdata.append(row) rawdata.append(subdata) triplets=[] for datum in rawdata: header=datum[0] for i in range(1, len(datum)): for j in range(len(datum[i])): triplet=[] if header[j][-6:]=='Truth1' and datum[i][j] != '' and datum[i][j+1] != '' and datum[i][j+2] != '': triplet.append(datum[i][j]) triplet.append(datum[i][j+1]) triplet.append(datum[i][j+2]) triplets.append(triplet) triplet=[] labels=[[0,0,1]]*len(triplets) p.my_field=triplets[0][0] if 'triplets' not in p.participant.vars: p.participant.vars['triplets']=triplets if 'labels' not in p.participant.vars: p.participant.vars['labels']=labels Group.get_triplets = get_triplets class Player(BasePlayer): pass class SingularInitialization(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): participant = player.participant import pickle from random import shuffle #with open('small_chunk.pkl','rb') as f: # triplets=pickle.load(f) #with open('judgement_chunk_1.pkl','rb') as f: # triplets=pickle.load(f) with open('dense_judgement.pkl','rb') as f: triplets=pickle.load(f) shuffle(triplets) labels=[[0,0,1]]*len(triplets) if 'triplets' not in player.participant.vars: player.participant.vars['triplets']=triplets if 'labels' not in player.participant.vars: player.participant.vars['labels']=labels player.participant.vars['points']=0 return dict(a='Loading!') page_sequence = [SingularInitialization]