from otree.api import ( <<<<<<< HEAD models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) ======= models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 doc = """ In Cournot competition, firms simultaneously decide the units of products to manufacture. The unit selling price depends on the total units produced. In this implementation, there are 2 firms competing for 1 period. """ class Constants(BaseConstants): name_in_url = 'cournot' players_per_group = 2 num_rounds = 1 <<<<<<< HEAD instructions_template = 'cournot/instructions.html' ======= instructions_template = 'cournot/Instructions.html' >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 # Total production capacity of all players total_capacity = 60 max_units_per_player = int(total_capacity / players_per_group) <<<<<<< HEAD ======= >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 class Subsession(BaseSubsession): pass class Group(BaseGroup): unit_price = models.CurrencyField() <<<<<<< HEAD total_units = models.IntegerField(doc="""Total units produced by all players""") ======= total_units = models.IntegerField( doc="""Total units produced by all players""" ) >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 def set_payoffs(self): players = self.get_players() self.total_units = sum([p.units for p in players]) self.unit_price = Constants.total_capacity - self.total_units for p in players: p.payoff = self.unit_price * p.units class Player(BasePlayer): units = models.IntegerField( <<<<<<< HEAD min=0, max=Constants.max_units_per_player, doc="""Quantity of units to produce""", label="How many units will you produce (from 0 to 30)?" ======= min=0, max=Constants.max_units_per_player, doc="""Quantity of units to produce""" >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 ) def other_player(self): return self.get_others_in_group()[0] <<<<<<< HEAD ======= >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3