from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) doc = '' class Constants(BaseConstants): name_in_url = 'public_goods_emc' players_per_group = None num_rounds = 1 endowment = c(50) multplier = 2 class Subsession(BaseSubsession): my_field = models.CurrencyField() class Group(BaseGroup): pass class Player(BasePlayer): contribution = models.CurrencyField(label='What is your contribution towards the project?', max=Constants.endowment, min=0) payoff_player1 = models.CurrencyField(initial=0) payoff_player2 = models.CurrencyField(initial=0) payoff_player3 = models.CurrencyField(initial=0) payoff_player4 = models.CurrencyField(initial=0) def set_payoffs(self): self.payoff_player1 =(50 - self.contribution) + (((45 + self.contribution)*2)/4) self.payoff_player2 =(50 - 10) + (((45 + self.contribution)*2)/4) self.payoff_player3 =(50 - 15) + (((45 + self.contribution)*2)/4) self.payoff_player4 =(50 - 20) + (((45 + self.contribution)*2)/4)