from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, Page, WaitPage ) cu = c doc = '\nOne player decides how to divide a certain amount between himself and the other\nplayer.\n\nSee: Kahneman, Daniel, Jack L. Knetsch, and Richard H. Thaler. "Fairness\nand the assumptions of economics." Journal of business (1986):\nS285-S300.\n\n' class Constants(BaseConstants): name_in_url = 'dictator' players_per_group = 2 num_rounds = 1 endowment = c(100) instructions_template = 'dictator/instructions.html' class Subsession(BaseSubsession): pass def set_payoffs(group): p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) group.send_group=p1.send p1.payoff = Constants.endowment - group.send_group p2.payoff = group.send_group class Group(BaseGroup): send_group = models.CurrencyField(doc='Amount dictator decided to keep for himself', label='I will send', max=Constants.endowment, min=0) set_payoffs = set_payoffs class Player(BasePlayer): send = models.CurrencyField(label='I will send', max=Constants.endowment, min=0)