from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Evaluation_Maze' players_per_group = None num_rounds = 7 import csv with open('Instruction_Maze/data_A.csv',encoding='utf-8') as fileA: List_playerA = list(csv.DictReader(fileA)) lines = len(List_playerA) import csv with open('Instruction_Maze/data_B.csv',encoding='utf-8') as fileB: List_playerB = list(csv.DictReader(fileB)) import random List_item = [] for i in range(num_rounds+100): r = random.randint(1,lines) if r not in List_item: List_item.append(r) List_Round_Text = ["This is the first of seven turns. ", "This is the second of seven turns. ", "This is the third of seven turns. ", "This is the fourth of seven turns. ", "This is the fifth of seven turns. ", "This is the sixth of seven turns. ", "This is the last turn for evaluating players in the maze task. "] Correct_Answer = [1, 0, 1, 0, 1, 1, 0] # 1(0) denotes that player A(B) is the correct answer in the corresponding turn class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): answer_maze = models.IntegerField(min=0, max=5) def set_payoff_maze(self): t = self.round_number A_Correct = Constants.Correct_Answer[t-1] x_A = self.answer_maze points = A_Correct*x_A + (1-A_Correct)*(5-x_A) self.payoff = points*2/35 temp_var = 'Maze_round' + str(t) self.participant.vars[temp_var] = points if t == Constants.num_rounds: self.participant.vars['points_Maze'] = 0 for x in range(Constants.num_rounds): temp_var = 'Maze_round' + str(x+1) self.participant.vars['points_Maze'] = self.participant.vars['points_Maze'] \ + self.participant.vars[temp_var]