from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import numpy as np author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'results' players_per_group = 3 num_rounds = 1 winner_payoff = 4 loser_payoff = 1 # coin flip page for P3 coinflip_result = ['Most Points','Random Lottery'] coinflip_text = ['whoever earned the most points', 'a random lottery'] #for guessing reward_t = c(0.5) #reward for guessing correct number of correct reward_m = c(0.5) #reward for guess correct average multiplier reward_p = c(1) #reward for guessing correct number of points reward_text = ['Sorry, you did not guess right.', 'You guessed right!'] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Guessing answer_t = models.IntegerField(label="") #participant's guess at total correct answer_p = models.IntegerField(label="") #participant's guess at total points answer_m = models.FloatField(label="") #participant's guess at average multiplier total_t = models.IntegerField() #actual total correct total_p = models.IntegerField() #actual total points avg_m = models.FloatField() #actual average multiplier correct_t = models.IntegerField() # whether p's guess at total correct is correct correct_p = models.IntegerField() # whether p's guess at total points is correct correct_m = models.IntegerField() # whether p's guess at avg multiplier is correct def determine_correct(self): self.correct_t = [self.answer_t == self.total_t].count(True) self.correct_p = [self.answer_p == self.total_p].count(True) self.correct_m = [np.round(self.answer_m,1) == self.avg_m].count(True)