from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Bot, Currency as c, currency_range ) author = 'Hanna Freudenreich' doc = """ An implementation of the intergroup prisoners' dilemma maximizing difference game (IPD-MD) (Halevy et al. 2008) for oTree. """ class Constants(BaseConstants): name_in_url = 'my_IPDMD' players_per_group = 6 num_rounds = 1 endowment = c(10) show_up = c(15) multiplier = 0.5 class Subsession(BaseSubsession): pass class Group(BaseGroup): def role(self): if self.id_in_group <= 3: return 'subgroup1' else: return 'subgroup2' #subgroup1_within = models.CurrencyField(initial=0) #subgroup1_between = models.CurrencyField(initial=0) #subgroup2_within = models.CurrencyField(initial=0) #subgroup2_between = models.CurrencyField(initial=0) #def set_payoffs(self): # for player in self.get_players(): # if player.role() == 'subgroup1': # self.subgroup1_within += player.contribution_within # self.subgroup1_between += player.contribution_between # elif player.role() == 'subgroup2': # self.subgroup2_within += player.contribution_within # self.subgroup2_between += player.contribution_between #for player in self.get_players(): # if player.role() == 'subgroup1': # player.payoff = Constants.endowment - player.contribution_within - player.contribution_between + Constants.multiplier * (self.subgroup1_within + self.subgroup1_between - self.subgroup2_between) # elif player.role() == 'subgroup2': # player.payoff = Constants.endowment - player.contribution_within - player.contribution_between + Constants.multiplier * (self.subgroup2_within + self.subgroup2_between - self.subgroup1_between) class Player(BasePlayer): #firstmover decision contribution_within = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between = models.CurrencyField(min=0, max=Constants.endowment, label="") keep = models.CurrencyField( min=0, max=Constants.endowment , label="") #second mover decision contribution_within_0 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_0 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_0 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_2 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_2 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_2 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_4 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_4 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_4 = models.CurrencyField( min=0, max=Constants.endowment , label="") contribution_within_6 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_6 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_6 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_8 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_8 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_8 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_10 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_10 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_10 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_12 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_12 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_12 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_14 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_14 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_14 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_16 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_16 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_16 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_18 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_18 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_18 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_20 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_20 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_20 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_22 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_22 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_22 = models.CurrencyField( min=0, max=Constants.endowment , label="") contribution_within_24 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_24 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_24 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_26 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_26 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_26 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) contribution_within_28 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_28 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_28 = models.CurrencyField( min=0, max=Constants.endowment , label="") contribution_within_30 = models.CurrencyField(min=0, max=Constants.endowment, label="") contribution_between_30 = models.CurrencyField(min=0, max=Constants.endowment, label="") keep_30 = models.CurrencyField( min=0, max=Constants.endowment, label="" ) ex_sum_a = models.CurrencyField(min=0, max=50, label="") ex_sum_b = models.CurrencyField(min=0, max=50, label="") ex_back_a = models.CurrencyField(min=0, max=50, label="") ex_back_b = models.CurrencyField(min=0, max=50, label="") ex_back_a1 = models.CurrencyField(min=0, max=50, label="") ex_back_b1 = models.CurrencyField(min=0, max=50, label="") ex_sum = models.CurrencyField(min=0, max=50, label="") ex_sum_a1 = models.CurrencyField(min=0, max=50, label="") ex_sum_b1 = models.CurrencyField(min=0, max=50, label="") ex_minus = models.CurrencyField(min=0, max=50, label="Wie viel wird jedem Mitglied Ihrer Gruppe abgezogen?") ex_final = models.CurrencyField( min=0, max=50, label="" ) ex_minus1 = models.CurrencyField( min=0, max=50, label= "Wie viel wird jedem Mitglied der anderen Gruppe abgezogen?") #def role(self): # if self.id_in_group <= 3: # return 'subgroup1' # else: # return 'subgroup2' exp_own_a = models.CurrencyField(min=0, max=Constants.endowment, label='') #label="Was denken Sie: wieviel hat jedes Mitglied Ihrer Gruppe im Durchschnitt in Topf A eingezahlt?") exp_own_b = models.CurrencyField(min=0, max=Constants.endowment, label='') #label="Was denken Sie: wieviel hat jedes Mitglied Ihrer Gruppe im Durchschnitt in Topf B eingezahlt?") exp_other_a = models.CurrencyField( min=0, max=Constants.endowment, label='')#label="Was denken Sie: wieviel hat jedes Mitglied der anderen Gruppe im Durchschnitt in Topf A eingezahlt?" ) exp_other_b = models.CurrencyField( min=0, max=Constants.endowment, label='')#label="Was denken Sie: wieviel hat jedes Mitglied der anderen Gruppe im Durchschnitt in Topf B eingezahlt?" )