from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from math import ceil import random import pandas as pd import itertools import numpy as np from sklearn.utils import shuffle doc = """ This is my rendition of the trust game, hopefully it works """ # This is the function I use to determine if offer was accepted or not def response(p): return True if random.random() < p else False class Constants(BaseConstants): name_in_url = 'my_11_20' players_per_group = None instructions_template = 'my_11_20/Instructions.html' endowment = c(21) payoff_if_rejected = c(0) offer_increment = c(1) offer_choices = currency_range(11, endowment, offer_increment) # num_rounds = len(offer_choices) * 2 num_rounds = 5 offer_choices_count = len(offer_choices) keep_give_amounts = [] for offer in offer_choices: keep_give_amounts.append((offer, endowment - offer)) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): amount_returned = models.IntegerField(widget=widgets.RadioSelect()) current_offer = models.IntegerField() test_question_1 = models.IntegerField( choices=(0, 19, 20, 39, 40), widget=widgets.RadioSelectHorizontal() ) test_question_2 = models.IntegerField( choices=(0, 19, 20, 39, 40), widget=widgets.RadioSelectHorizontal() ) test_question_3 = models.IntegerField( choices=(0, 19, 20, 39, 40), widget=widgets.RadioSelectHorizontal() ) test_question_4 = models.IntegerField( choices=(0, 19, 20, 39, 40), widget=widgets.RadioSelectHorizontal() ) def amount_returned_choices(self): # choices = [0, self.group.current_offer] choices = [ii for ii in range(11, 21)] return choices