from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) # from otree_tools.models.fields import OtherModelField import random import itertools author = 'Celine Zhang' doc = """ This is a one-period public goods game with 32 players and 4 per group. """ class Constants(BaseConstants): name_in_url = 'game3nondom' players_per_group = None num_rounds = 1 instructions_template = 'dictator/instructions.html' endowment = c(100) pool_multiplier = c(2.0) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision1 = models.CurrencyField( min=0, max=Constants.endowment, ) decision2 = models.CurrencyField( min=0, max=Constants.endowment, ) decision3 = models.CurrencyField( min=0, max=Constants.endowment, ) control1 = models.CurrencyField( min=0, max=Constants.endowment, ) control2 = models.CurrencyField( min=0, max=Constants.endowment, ) control3 = models.CurrencyField( min=0, max=Constants.endowment, ) newcheck = models.CharField(choices=['In each round reward up to 60 points to any Group Member.', 'In each round remove up to 60 points from any Group Member.', 'In each round increase the size of the Group Project by 60 points.' ], widget=widgets.RadioSelect) newcheck2 = models.CharField(choices=['Person 1', 'Person 2', 'Person 3' ], widget=widgets.RadioSelect) newcheck3 = models.CharField(choices=['Red', 'Purple', 'Yellow', 'Green', 'None of the above' ], widget=widgets.RadioSelect) newcheck4 = models.CharField(choices=['Player 1 earns extra $$$, while Player 2 loses $$$.', 'Player 2 earns extra $$$, while Player 1 loses $$$.', 'Both Player 1 and Player 2 lose $$$.', 'Both Player 1 and Player 2 earn extra $$$', 'None of the above' ], widget=widgets.RadioSelect) s1q1attempt = models.IntegerField(initial=0) s1q2attempt = models.IntegerField(initial=0) s1q3attempt = models.IntegerField(initial=0) subjectid = models.CharField(initial='') payoff2 = models.CurrencyField() p1_payoff2 = models.CurrencyField() p2_payoff2 = models.CurrencyField() p3_payoff2 = models.CurrencyField() contribution = models.CurrencyField( min=0, max=Constants.endowment, doc="""The amount contributed by the player""", ) total_contribution = models.CurrencyField() individual_share = models.CurrencyField() def set_payoffs(self): self.total_contribution = self.contribution + 90 self.individual_share = self.total_contribution * Constants.pool_multiplier / 4 self.payoff2 = Constants.endowment - self.contribution + self.individual_share self.p1_payoff2 = sum([+56, +self.individual_share, ]) self.p2_payoff2 = sum([+93, +self.individual_share, ]) self.p3_payoff2 = sum([+61, +self.individual_share, ]) self.payoff = Constants.endowment - self.contribution + self.individual_share