from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) doc = '' class Constants(BaseConstants): name_in_url = 'Practice_round' players_per_group = 4 num_rounds = 5 yield_benefit = 1.05 acre_endowment = 100 per_acre_profit = c(100) cc_cost_per_acre = c(25) yield_benefit_pct = 5 USE_THOUSAND_SEPARATOR = True REAL_WORLD_CURRENCY_DECIMAL_PLACES = False my_constant = 0.001 instructions_template = 'Practice_round/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): total_acres = models.IntegerField() def method811404(self): group = self players = group.get_players() acres_planted = [p.acres_planted_individual for p in players] group.total_acres = sum(acres_planted) for p in players: p.cc_cost_total = p.acres_planted_individual * Constants.cc_cost_per_acre p.profit_cc_acres_no_bonus = ( Constants.per_acre_profit ) - Constants.cc_cost_per_acre p.payoff_no_bonus = ( ( (Constants.acre_endowment - p.acres_planted_individual) * Constants.per_acre_profit ) + (p.acres_planted_individual * Constants.per_acre_profit) - p.cc_cost_total ) p.payoff = p.payoff_no_bonus p.payoff_round_1 = (p.payoff) * (Constants.my_constant) class Player(BasePlayer): acres_planted_individual = models.IntegerField( label='How many acres would you like to plant with cover crops in this year?', max=Constants.acre_endowment, min=0, ) payoff_no_bonus = models.CurrencyField() cc_cost_total = models.CurrencyField() profit_cc_acres_no_bonus = models.CurrencyField() payoff_round_1 = models.CurrencyField()