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 from random import uniform import numpy as np import copy from sklearn.utils import shuffle doc = """ This is my rendition of the trust game, hopefully it works """ # to get the matrix images I go onto icar-project.com, my username is michael123456789, and my password is myownicarpassword class Constants(BaseConstants): name_in_url = 'my_IQ' players_per_group = None num_rounds = 11 instructions_template = 'my_IQ/Instructions.html' endowment = c(20) payoff_if_rejected = c(0) offer_increment = c(1) offer_choices = currency_range(0, endowment, offer_increment) matrix_answer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] offer_choices_count = len(offer_choices) all_images = ['fig12043.jpg', 'fig12044.jpg', 'fig12045.jpg', 'fig12046.jpg', 'fig12047.jpg', 'fig12048.jpg', 'fig12050.jpg', 'fig12053.jpg', 'fig12054.jpg', 'fig12055.jpg', 'fig12056.jpg'] keep_give_amounts = [] for offer in offer_choices: keep_give_amounts.append((offer, endowment - offer)) class Subsession(BaseSubsession): pass # slider_starter = np.random.choice(Constants.offer_choices) class Group(BaseGroup): pass class Player(BasePlayer): # amount_offered = models.CurrencyField(widget=widgets.RadioSelectHorizontal(), choices=Constants.offer_choices) mat_answer = models.StringField(widget=widgets.RadioSelectHorizontal(), choices = ['A', 'B', 'C', 'D', 'E', 'F']) age = models.IntegerField() gender = models.StringField(widget=widgets.RadioSelectHorizontal(), choices = ['male', 'female', 'other']) mat_image = models.CharField() def set_responder_identity(self): self.mat_image = 'my_IQ/' + Constants.all_images[self.round_number - 1] # self.mat_image = 'my_IQ/' + 'fig120' + str(42 + self.round_number) + '.jpg' #========================================================================================== attention_check_UBG_FirstHalf1 = models.StringField(blank=True) attention_check_UBG_FirstHalf2 = models.StringField(blank=True) # attention_check1 = models.StringField( # ) myownicarpassword age = models.IntegerField( choices=(range(16, 36)), widget=widgets.RadioSelect() ) gender = models.CharField( choices=('MALE', 'FEMALE'), widget=widgets.RadioSelect() ) test_question_1 = models.CharField( choices=('TRUE', 'FALSE'), widget=widgets.RadioSelect() ) test_question_2 = models.CharField( choices=('TRUE', 'FALSE'), widget=widgets.RadioSelect() ) test_question_3 = models.CharField( choices=('TRUE', 'FALSE'), widget=widgets.RadioSelect() ) test_question_4 = models.CharField( choices=('TRUE', 'FALSE'), widget=widgets.RadioSelect() ) test_question_5 = models.CharField( choices=('Randomly chosen responders', 'Groups of responders who received different starting endowments', 'Groups of responders from different academic backgrounds', 'All of the above'), widget=widgets.RadioSelect() ) test_question_6 = models.CharField( choices=('Random computer generate lotteries', 'Computer responses programmed to mimic responders who received different starting endowments', 'Computer responses programmed to mimic responders from different academic backgrounds', 'All of the above'), widget=widgets.RadioSelect() )