from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'ElFarol' players_per_group = 10 num_rounds = 30 endowment = 10 multiplier = 2 bar_full = 6 StandardChoices_1=[ [1, '0ポイント'], [2, '10ポイント'], [3, '20ポイント'], [4, '5ポイント'] ] Survey1Choices = StandardChoices_1 StandardChoices_2=[ [1, '0ポイント'], [2, '10ポイント'], [3, '20ポイント'], [4, '15ポイント'] ] Survey2Choices = StandardChoices_2 class Subsession(BaseSubsession): pass class Group(BaseGroup): total_customers = models.CurrencyField() def set_payoffs(self): self.total_customers = sum([p.decision for p in self.get_players()]) for p in self.get_players(): if self.total_customers > C.BAR_FULL: if p.decision == True: p.payoff = 0 else: p.payoff = C.ENDOWMENT #print("bar is full") else: if p.decision == True: p.payoff = C.ENDOWMENT * C.MULTIPLIER print("winner") else: p.payoff = C.ENDOWMENT print("loser") #print("bar looks great") p.curr_cumu_payoffs = sum([pp.payoff for pp in p.in_all_rounds()]) def total_payoff(self): for p in self.get_players(): p.total_payoffs = sum([pp.payoff for pp in p.in_all_rounds()]) p.total_money = (p.total_payoffs * 2) + 1000 class Player(BasePlayer): total_payoffs = models.CurrencyField() curr_cumu_payoffs = models.CurrencyField() total_money = models.CurrencyField() decision = models.BooleanField( choices=[ [True, 'Join'], [False, 'Not join'], ], widget=widgets.RadioSelect ) consent_btn = models.BooleanField() #Survey1 (Emotional Scale) item1A = models.IntegerField( label='正しいと思う選択肢をお選びください', choices=C.SURVEY1CHOICES, widget=widgets.RadioSelect ) item2A = models.IntegerField( label='正しいと思う選択肢をお選びください', choices=C.SURVEY2CHOICES, widget=widgets.RadioSelect ) get_name = models.StringField( label='ここにお名前をお書きください' )