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 = 'ee1740721_1' players_per_group = 4 num_rounds = 1 fair=c(5) unfair_high=c(9) unfair_low=c(1) class Subsession(BaseSubsession): pass class Group(BaseGroup): def set_payoffs(self): players = self.get_players() if self.get_player_by_id(1).delegation_choice: if self.get_player_by_id(2).distribution_choice: for p in players: p.payoff += Constants.fair else: self.get_player_by_id(1).payoff += Constants.unfair_high self.get_player_by_id(2).payoff += Constants.unfair_high self.get_player_by_id(3).payoff += Constants.unfair_low self.get_player_by_id(4).payoff += Constants.unfair_low else: if self.get_player_by_id(1).distribution_choice: for p in players: p.payoff += Constants.fair else: self.get_player_by_id(1).payoff += Constants.unfair_high self.get_player_by_id(2).payoff += Constants.unfair_high self.get_player_by_id(3).payoff += Constants.unfair_low self.get_player_by_id(4).payoff += Constants.unfair_low class Player(BasePlayer): delegation_choice=models.BooleanField(label="Do you want to delegate the choice?", choices=[[True, "Yes"], [False, "No"]], widget=widgets.RadioSelect) distribution_choice=models.BooleanField(label="How do you want to distribute the resources?", choices=[[True, "Fairly"], [False, "Unfairly"]], widget=widgets.RadioSelect)