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 = 'my_cournot_nash' players_per_group = 2 num_rounds = 1 instructions_template='my_cournot_nash/instructions.html' total_capacity=200 max_units_per_player=100 class Subsession(BaseSubsession): pass class Group(BaseGroup): unit_price=models.CurrencyField() total_units=models.IntegerField(doc="""Total units produced by all players""") def set_payoffs(self): players = self.get_players() self.total_units = sum([p.units for p in players]) self.unit_price = max(Constants.max_units_per_player - self.total_units,0) for p in players: p.payoff = (self.unit_price-1)* p.units class Player(BasePlayer): units=models.IntegerField( min=0.1, max=Constants.max_units_per_player, doc="""Quantity of units to produce""", label="How many units will you produce (from 0.1 to 100)" ) def other_player(self): return self.get_others_in_group()[0]