from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Eugene' doc = """ Collective Risk Goods Games #1 """ import random class Constants(BaseConstants): name_in_url = 'colrisk1' players_per_group = 4 num_rounds = 10 p_ruin = 0.5 group_target = c(30) endowment_rich = c(20) endowment_poor = c(10) class Subsession(BaseSubsession): pass class Group(BaseGroup): def vars_for_admin_report(self): payoffs = sorted([p.payoff for p in self.get_players()]) return dict(payoffs=payoffs) total_contribution = models.CurrencyField() class Player(BasePlayer): contribution = models.CurrencyField(widget=widgets.RadioSelectHorizontal, choices=[0, 0.75, 1.50], label="How much would you like to transfer to the group account on this round?" )