from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) 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 = 'cournot2' players_per_group = 4 num_rounds = 10 instructions_template = 'cournot2/instructions.html' # Total production capacity of all players total_capacity = 121 max_units_per_player = 60 class Subsession(BaseSubsession): def creating_session(self): self.group_randomly() 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 = Constants.total_capacity - self.total_units - 1 for p in players: p.payoff = self.unit_price * p.units class Player(BasePlayer): units = models.IntegerField( min=0, max=Constants.max_units_per_player, doc="""Quantity of units to produce""", label="How many units will you produce (from 0 to 60)?" ) def other_player(self): return self.get_others_in_group()[0] test_1 = models.BooleanField( label="解答", choices=[ [False, "〇"], [True, "×"], [False, "わからない"], ] ) test_2 = models.BooleanField( label="解答", choices=[ [True, "〇"], [False, "×"], [False, "わからない"], ] ) test_3 = models.BooleanField( label="解答", choices=[ [False, "〇"], [True, "×"], [False, "わからない"], ] ) test_4 = models.BooleanField( label="解答", choices=[ [True, "〇"], [False, "×"], [False, "わからない"] ] ) test_5 = models.BooleanField( label="解答", choices=[ [False, "46"], [False, "50"], [False, "53"], [True, "64"] ] ) test_6 = models.BooleanField( label="解答", choices=[ [False, "755"], [True, "1080"], [False, "1143"], [False, "1190"] ] ) test_7 = models.BooleanField( label="解答", choices=[ [False, "755"], [True, "885"], [False, "900"], [False, "940"] ] )