from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random import math author = 'Huanren Zhang' doc = """ Games used to estimate parameters of the Fehr-Schmidt model of inequality aversion """ class Constants(BaseConstants): name_in_url = 'sp' players_per_group = 2 num_rounds = 1 pie = c(40) class Subsession(BaseSubsession): pass class Group(BaseGroup): def interact(self): p1, p2 = self.get_players() ## set the values for participants, used in the payment info p1.participant.vars['UG_MAO'] = p2.UG_MAO p2.participant.vars['UG_MAO'] = p2.UG_MAO p1.participant.vars['UG_offer'] = p1.UG_offer p2.participant.vars['UG_offer'] = p1.UG_offer if p1.UG_offer < p2.UG_MAO: p1.payoff = 0 p2.payoff = 0 else: p1.payoff = p1.UG_kept p2.payoff = p1.UG_offer class Player(BasePlayer): UG_offer = models.PositiveIntegerField(min=0, max=Constants.pie) UG_kept = models.PositiveIntegerField(min=0, max=Constants.pie) UG_MAO= models.PositiveIntegerField(min=0, max=Constants.pie)