from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import logging logger = logging.getLogger(__name__) from os import environ author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'ball' players_per_group = None num_rounds = 8 # Set 8 here as this is the max, and we can exit early if we want less rounds treatments = ['a','b','c','d'] higher_payoff_AP = 4 lower_payoff_AP = 3 example_position = 2 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def update_paradox_index(self) -> int: last_index = self.participant.vars['paradox_index'] last_index += 1 # Here we wrap back to the start at the end of the number of possible paradox's if last_index == self.get_paradox_size(): last_index = 0 self.participant.vars['paradox_index'] = last_index def get_paradox_size(self): return 4 if (self.participant.vars['treatment'] in ['a','b']) else 8 chose_orange = models.BooleanField( choices=[ [False, 'I choose blue'], [True, 'I choose orange'] ], ) blue_balls = models.IntegerField() size = models.IntegerField() treatment_name = models.StringField() red_balls = models.IntegerField() position = models.CharField() nr_next_players = models.IntegerField() timeout = models.IntegerField( choices=[0, 1] ) my_starting_position = models.IntegerField() my_position = models.IntegerField()