from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) 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' players_per_group = 2 num_rounds = 1 # instructions_template = 'dictator_mcf/instructions.html' # Initial amount allocated to the dictator endowment = c(50) class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.is_mcf = p.participant.vars['is_mcf'] p.with_mcf = p.participant.vars['with_mcf'] class Group(BaseGroup): def set_payoffs(self): p1 = self.get_player_by_id(1) p2 = self.get_player_by_id(2) p1.is_sender = True p1.participant.vars['sender_1'] = True p2.is_sender = False p2.participant.vars['sender_1'] = False p1.payoff = Constants.endowment - p1.sent p2.payoff = p1.sent p1.participant.vars['earning_1'] = p1.payoff p2.participant.vars['earning_1'] = p2.payoff class Player(BasePlayer): is_sender = models.BooleanField() is_mcf = models.BooleanField() with_mcf = models.BooleanField() sent = models.CurrencyField(min=0, max=Constants.endowment)