from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) from random import randint author = 'jNM²' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'BenchmarkGame' players_per_group = 2 num_rounds = 7 Cfix = 75 class Subsession(BaseSubsession): pass class Group(BaseGroup): newPrice = models.CurrencyField() sent_amount = models.IntegerField( min=0, max=9999999, doc="""Demand forecast sent by seller""" ) sent_back_amount = models.IntegerField( min=0, max=9999999, doc="""Amount will be produced""" ) rdmCurve = models.IntegerField() rdmRound = models.IntegerField() def random(self): randChoice = randint(0, 2) self.rdmRound = randint(1, Constants.num_rounds) if self.session.config['certainty'] == False: if randChoice == 1: self.rdmCurve = 1 if randChoice == 2: self.rdmCurve = 0 else: self.rdmCurve = -1 else: self.rdmCurve = 0 # save random choice in data 0 in certainty case, 1 in +1 shift, -1 for -1 shift class Player(BasePlayer): def role(self): return {1: 'Sales', 2: 'Operation'}[self.id_in_group]