from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random 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 = 'ultimatum_game' players_per_group = 2 num_rounds = 5 instructions_template = 'ultimatum_game/Instructions.html' # Initial amount allocated to the dictator endowment = c(100) payoff_if_rejected = c(0) points_name = 'TJS' class Subsession(BaseSubsession): pass class Group(BaseGroup): sent = models.CurrencyField( doc="""Amount proposer decided to send to responder""", min=0, max=Constants.endowment, ) decision = models.StringField(initial=None, choices=['Accept', 'Reject'] ) average_accept = models.IntegerField(initial=150) average_overall = models.IntegerField(initial=150) def find_avarage(self): games = self.in_previous_rounds() previous = [] print("previous games") for i in games: previous.append(i.sent) return previous class Player(BasePlayer): answer1 = models.IntegerField(label="What will be the payoff of each participant (considering participation fee)?") answer2 = models.IntegerField(label="What will be the payoff of proposer (considering participation fee?)") answer3 = models.IntegerField(label="What will be the payoff of responder (considering participation fee?)") pass age = models.IntegerField(label="What is your year of birth:") gender = models.StringField(choices=['Female', 'Male', 'Other'], label='What is your gender?') nationality = models.StringField( label='What is your nationality?') education = models.StringField(choices=['I have a part-time job', 'I have a full time job', 'I have a stipend or scholarship', 'I depend on my family members', 'I am usually broke'], label='How do you make a living?') comment = models.StringField( label='Do you have any other comments?')