from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) 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 = 'stage1' players_per_group = None num_rounds = 1 instructions_template = 'stage1/Instructions.html' # """Amount allocated to each player""" endowment = c(100) multiplier = 1.6 check1=['0','100','160','240'] check2=['0','100','160','220'] check3=['0','40','100','160'] class Subsession(BaseSubsession): def creating_session(self): players = self.get_players() self.group_randomly() class Group(BaseGroup): total_contribution = models.CurrencyField() individual_share = models.CurrencyField() class Player(BasePlayer): s1q1attempt = models.IntegerField(initial=0) s1q3attempt = models.IntegerField(initial=0) s1q4attempt = models.IntegerField(initial=0) s1q5attempt = models.IntegerField(initial=0) display1 = models.CurrencyField() display2 = models.CurrencyField() display3 = models.CurrencyField() display4 = models.CurrencyField() payoff2 = models.CurrencyField() contribution = models.CurrencyField( min=0, max=Constants.endowment, doc="""The amount contributed by the player""", ) subjectid = models.CharField(initial='') check1 = models.CharField(choices=Constants.check1) check2 = models.CharField(choices=Constants.check2) check3 = models.CharField(choices=Constants.check3) def member_id(self): # player 1 is the leader, so member 1 is actually player 2 return (self.id_in_group) def other_player1(self): return self.get_others_in_group()[0] def other_player2(self): return self.get_others_in_group()[1] def other_player3(self): return self.get_others_in_group()[2] password_video1 = models.CharField(initial='') newcheck = models.CharField(choices=['Multiplied by 1.6', 'Remains unchanged', 'Gone and never gets returned to me' ], widget=widgets.RadioSelect) newcheck2 = models.CharField(choices=['Group Members who contribute to the Group Project (or contribute many points) increase the payout of others in the group', 'Group Members who do not contribute to the Group Project (or contribute very few points) increase the payout of others in the group', 'Contribution by Group Members will not affect the payouts of anyone in the Group' ], widget=widgets.RadioSelect)