from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Mike Zhiren Wu' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'my_information_cascades_reward' players_per_group = 6 num_rounds = 1 endowment = c(15) bonus = c(20) bonus_extra = c(10) instructions_template = 'my_information_cascades_reward/Instructions.html' instructions_page = 'my_information_cascades_reward/Instructionspage.html' urn_A = ['red', 'red', 'blue'] urn_B = ['red', 'blue', 'blue'] urns = ['A', 'B'] class Subsession(BaseSubsession): def creating_session(self): self.group_randomly() for group in self.get_groups(): group.storyline = random.choice(Constants.urns) for p in self.get_players(): if group.storyline == 'A': p.current_ball = random.choice(Constants.urn_A) else: p.current_ball = random.choice(Constants.urn_B) class Group(BaseGroup): storyline = models.CharField() # the correct answer choice_of_urn_first = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) choice_of_urn_second = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) choice_of_urn_third = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) choice_of_urn_fourth = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) choice_of_urn_fifth = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) choice_of_urn_sixth = models.CharField( # the guess by the player choices=['A', 'B'], widget=widgets.RadioSelectHorizontal() ) class Player(BasePlayer): current_ball = models.CharField() # the color of the ball a player will draw origin = models.StringField() gender = models.StringField( choices=['男', '女'], widget=widgets.RadioSelectHorizontal() ) age = models.IntegerField()