from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random doc = """ One player decides how to divide a certain amount between himself and the other player. See: Kahneman, Daniel, Jack L. Knetsch, and Richard H. Thaler. "Fairness and the assumptions of economics." Journal of business (1986): S285-S300. """ class Constants(BaseConstants): name_in_url = 'dictator_normal' players_per_group = None num_rounds = 1 instructions_template = 'dictator_normal/Instructions.html' # Initial amount allocated to the dictator endowment = c(10) class Subsession(BaseSubsession): def creating_session(self): #decides which game is implemented in the end for p in self.get_players(): p.chosen_game = random.sample(['DG', 'DG_exit'], k = 1)[0] class Group(BaseGroup): pass class Player(BasePlayer): P_ID = models.StringField(label="Please check whether your participant ID is entered correctly.") # control variables m_check_1 = models.BooleanField( label='Individual B will be informed about the game and about how much I decided to allocate to him/her.', widget=widgets.CheckboxInput, blank=True) offer = models.IntegerField(blank=True) kept = models.IntegerField() kept_history = models.StringField(blank=True, initial="") second_order_belief = models.IntegerField(label="I think that individual B expects ", min=0, max=10) def set_payoffs(self): self.payoff = c(self.kept) self.participant.vars['dictator_payoff'] = c(self.kept) #set recipients payoff self.participant.vars['dictator_recipient_payoff'] = c(10) - c(self.kept) ################################################################ ########## Varia ########## ################################################################ UserAgent = models.StringField() device = models.StringField() chosen_game = models.StringField()