Esempio n. 1
0
class Player(BasePlayer):

    starttime = models.FloatField()
    endtime = models.FloatField()
    demand = models.PositiveIntegerField()
    units = models.PositiveIntegerField(
        min=1, max=100,
        doc="""Quantity of units to order"""
    )

    qu1 = models.PositiveIntegerField(
        choices=[45, 100, 90], widget=widgets.RadioSelect(), blank=True)
    qu2 = models.PositiveIntegerField(
        choices=[100, 140, 200], widget=widgets.RadioSelect(), blank=True)
    qu3 = models.PositiveIntegerField(
        choices=[40, 60, 100], widget=widgets.RadioSelect(), blank=True)

    def other_player(self):
        return self.get_others_in_group()[0]

    def set_payoff(self):

        q = self.units
        d = self.demand

        if (q < d):
            self.payoff = Constants.price * q - Constants.cost * q
        else:
            self.payoff = Constants.price * d - Constants.cost * q
Esempio n. 2
0
class Player(BasePlayer):
    hit_bomb = models.PositiveIntegerField()
    group_adapt = models.PositiveIntegerField(
        choices=[[1, 'Yes'],
                 [0, 'No']
                 ],
        widget=widgets.RadioSelect()
    )

    adapt = models.PositiveIntegerField(
        choices=[[1, 'Yes'],
                 [0, 'No']
                 ],
        widget=widgets.RadioSelect()
    )

    risk = models.PositiveIntegerField()

    def set_payoff(self):
        if self.group_adapt:
            self.payoff = 400
        else:
            if self.adapt==1:
                self.payoff = 300
            else:
                if self.hit_bomb==1:
                    self.payoff = 50
                else:
                    self.payoff = Constants.stakes
Esempio n. 3
0
class Player(BasePlayer):

    blank = models.CharField(blank=True)

    add100_1 = models.PositiveIntegerField()
    add100_2 = models.PositiveIntegerField()

    even_int = models.PositiveIntegerField()

    dynamic_choices = models.CharField()

    blank_dynamic_choices = models.IntegerField(blank=True)

    choices_flat = models.CurrencyField(widget=widgets.RadioSelect(),
                                        choices=[c(1), c(2)])

    choices = models.IntegerField(widget=widgets.RadioSelect(),
                                  choices=[[1, 'A'], [2, 'B']])

    dynamic_radio = models.CharField(widget=widgets.RadioSelectHorizontal())

    min_max_dynamic = models.CurrencyField()
    min_max_blank = models.FloatField(blank=True, min=1, max=1)
    min_max_blank2 = models.FloatField(blank=True, min=1, max=1)

    equals_one = models.IntegerField(initial=1)
Esempio n. 4
0
class Player(BasePlayer):

    starttime = models.FloatField()
    endtime = models.FloatField()
    orderquantity = models.PositiveIntegerField(choices=[0, 1, 2, 3, 4, 5, 6],
                                                widget=widgets.RadioSelect())
    trueorderquantity = models.PositiveIntegerField()
    demand = models.PositiveIntegerField()
    nickname = models.CharField(blank=True)
    pecu = models.PositiveIntegerField(choices=[[1, '1 = Not at all'],
                                                [2, '2'], [3, '3'], [4, '4'],
                                                [5, '5'], [6, '6'], [7, '7'],
                                                [8, '8'],
                                                [9,
                                                 '9 = As much as possible']],
                                       widget=widgets.RadioSelect())
    nonpecu = models.PositiveIntegerField(
        choices=[[1, '1 = Not at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'],
                 [6, '6'], [7, '7'], [8, '8'], [9, '9 = As much as possible']],
        widget=widgets.RadioSelect())
    conflict = models.PositiveIntegerField(
        choices=[[1, '1 = Least conflicted'], [2, '2'], [3, '3'], [4, '4'],
                 [5, '5'], [6, '6'], [7, '7'], [8, '8'],
                 [9, '9 = Most conflicted']],
        widget=widgets.RadioSelect())
Esempio n. 5
0
class Player(BasePlayer):
    my_id = models.PositiveIntegerField()
    interaction_number = models.PositiveIntegerField()
    round_in_interaction = models.PositiveIntegerField()

    action = models.CharField(choices=['A', 'B'],
                              doc="""This player's action""",
                              widget=widgets.RadioSelect())

    signal = models.CharField(choices=['A', 'B'],
                              doc="""This player's signal received""",
                              widget=widgets.RadioSelect())

    message = models.CharField(choices=['a', 'b'],
                               doc="""This player's message""",
                               widget=widgets.RadioSelect())
    partner_id = models.PositiveIntegerField()
    other_action = models.CharField(choices=['A', 'B'])
    other_signal = models.CharField(choices=['a', 'b'])
    other_message = models.CharField(choices=['a', 'b'])

    cum_payoff = models.CurrencyField()

    def get_partner(self):
        return self.get_others_in_group()[0]
Esempio n. 6
0
class Player(BasePlayer):

    prolificcode = models.CharField()
    starttime = models.FloatField()
    endtime = models.FloatField()
    jsdectime_start = models.FloatField()
    jsdectime_end = models.FloatField()
    q = models.IntegerField()
    d = models.IntegerField()
    revenue = models.IntegerField()
    cost = models.IntegerField()
    fakeround_number = models.IntegerField()
    pecu = models.PositiveIntegerField(choices=[[1, '1 = Not at all'],
                                                [2, '2'], [3, '3'], [4, '4'],
                                                [5, '5'], [6, '6'], [7, '7'],
                                                [8, '8'],
                                                [9,
                                                 '9 = As much as possible']],
                                       widget=widgets.RadioSelect())
    nonpecu = models.PositiveIntegerField(
        choices=[[1, '1 = Not at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'],
                 [6, '6'], [7, '7'], [8, '8'], [9, '9 = As much as possible']],
        widget=widgets.RadioSelect())
    conflict = models.PositiveIntegerField(
        choices=[[1, '1 = Least conflicted'], [2, '2'], [3, '3'], [4, '4'],
                 [5, '5'], [6, '6'], [7, '7'], [8, '8'],
                 [9, '9 = Most conflicted']],
        widget=widgets.RadioSelect())
Esempio n. 7
0
class Player(BasePlayer):
    def role(self):
        if self.id_in_group == 1:
            return 'Politician'
        if self.id_in_group == 2:
            return 'Bureaucrat'
        if self.id_in_group == 3:
            return 'Citizen'
        else:
            return "Waiting"

    current_wp = models.IntegerField()
    outofthegame = models.BooleanField()
    startwp_timer_set = models.BooleanField(default=False)
    startwp_time = models.PositiveIntegerField()
    age = models.PositiveIntegerField()
    gender = models.PositiveIntegerField(choices=[
        [1, 'Female'],
        [2, 'Male'],
        [3, 'Other'],
    ],
                                         widget=widgets.RadioSelect())
    income = models.PositiveIntegerField(choices=[
        [1, '<£1,000/month'],
        [2, '£1,000 - £2,000/month'],
        [3, '£2,000 - £4,000/month'],
        [4, '£4,000 - £6,000/month'],
        [5, '>£6,000/month'],
    ],
                                         widget=widgets.RadioSelect())

    def elections(self):
        self.participant.vars['new_election'] = 0
Esempio n. 8
0
class Player(BasePlayer):
    age = models.PositiveIntegerField(
        min = 16,
        max = 120,
        verbose_name = "How old are you?",
        doc = "collect age data between 16 and 120",
    )

    field_of_study = models.CharField(
        blank = True, # some subjects might not study
        verbose_name = "What do you study?",
        doc = "collect field of study data, open field",
    )

    likes_experiment = models.CharField(
        choices = ["Yes, of course!", "No, suck it!", "Maybe..."],
        widget = widgets.RadioSelect(),
        verbose_name = "Doy you like the survey?",
        doc = "likes experiment - yes, no, or maybe",
    )

    female = models.PositiveIntegerField(
        choices = [[0, "Male"], [1, "Female"], [2, "Other"]],
        widget = widgets.RadioSelect(),
        verbose_name = "What is your gender?",
        doc = "gender of participant",
    )

    height = models.FloatField(
        initial = 1.0,
        min = 1.0,
        max = 2.5,
        widget = widgets.SliderInput(attrs={'step': '0.1'}),
        verbose_name = "What is your height in meters?",#
        doc = "height of participant in meters",
    )

    weight = models.FloatField(
        initial = 30,
        min = 30,
        max = 300,
        widget = widgets.SliderInput(attrs={'step': '0.1'}),
        verbose_name = "How heavy are you in Kg?",
        doc = "weight of participant in kg",
    )

    bmi = models.FloatField()

    bmi_eval = models.CharField()

    def calculate_bmi(self):
        self.bmi = round(self.weight / self.height ** 2, 2)

    def bmi_evaluation(self):
        if self.bmi < 18.5:
            self.bmi_eval = "You are underweight. Get help!"
        elif self.bmi > 25:
            self.bmi_eval =  "You are overweight, you fat f**k!"
        else:
            self.bmi_eval = "Your weight is normal, good job!"
Esempio n. 9
0
class Player(BasePlayer):
    treatment = models.PositiveIntegerField()
    senior_name = models.CharField()
    junior_name = models.CharField()
    senior_prob = models.FloatField()
    senior_dice_num = models.PositiveIntegerField()
    junior_dice_num = models.PositiveIntegerField()
    dice_num = models.PositiveIntegerField()
    dice_roll = models.PositiveIntegerField()
    dice_win = models.BooleanField()
    acc = models.FloatField()
    good_prior = models.FloatField()
    senior = models.BooleanField()
    good = models.BooleanField()
    signal = models.BooleanField()
    posterior = models.FloatField()
    lottery_odds = models.PositiveIntegerField()
    lottery_win = models.BooleanField()
    investment = models.BooleanField(
        choices=[
            [1, 'The investment'],
            [0, 'The lottery'],
        ],
        widget=widgets.RadioSelect()
    )
    dice_count = models.BooleanField()


    ## Understanding Questions
    failures = models.PositiveIntegerField()
    truefalse1 = models.BooleanField(choices=[[1, 'True'], [0, 'False']], widget=widgets.RadioSelect())
    truefalse2 = models.BooleanField(choices=[[1, 'True'], [0, 'False']], widget=widgets.RadioSelect())
    truefalse3 = models.BooleanField(choices=[[1, 'True'], [0, 'False']], widget=widgets.RadioSelect())
    truefalse4 = models.BooleanField(choices=[[1, 'True'], [0, 'False']], widget=widgets.RadioSelect())
    blank1 = models.PositiveIntegerField()
    blank2 = models.PositiveIntegerField()
    blank3 = models.PositiveIntegerField()

    ## Survey Questions
    age = models.PositiveIntegerField(verbose_name='What is your age?', choices=[(0, "< 23"), (1, "23 ~ 30"), (2, "31 ~ 40"), (3, "41~50"), (4, "51 ~ 60"), (5, "61 ~ 70"), (6, "> 70"), (7, "I prefer not to answer")], initial=None)
    gender = models.CharField(initial=None, choices=['Male', 'Female', 'Other', 'I prefer not to answer'], verbose_name='What is your gender?', widget=widgets.RadioSelect())
    howmuchmturk = models.PositiveIntegerField(verbose_name = "What percentage of your income comes from work on Amazon MTurk?", choices=((0, "0 ~ 10%"), (1, "11 ~ 20%"), (2, "21 ~ 30%"), (3, "31 ~ 40%"), (4, "41 ~ 50%"), (5, "51 ~ 60%"), (6, "61 ~ 70%"), (7, "71 ~ 80%"), (8, "81 ~ 90%"), (9, "91 ~ 100%"), (10, "I prefer not to answer")), initial=None)
    howmuchstudies = models.PositiveIntegerField(initial=None, verbose_name = 'Have you participated in psychological or economics studies before? If so how many?', choices=[(0,"No."), (1,"Yes, one before this study."), (2,"Yes, fewer than five other studies."), (3,"Yes, more than five other studies."), (4,"I prefer not to answer")])
    education = models.PositiveIntegerField(initial=None, verbose_name = "What is your highest level of education?", choices = [(0,"I have no high school diploma"), (1,"High school diploma"), (2,"Some college years"), (3,"Professional further education/ Apprenticeship/ Associate Degree"), (4,"Bachelor's degree"), (5,"Postgraduate degree"), (6,"I prefer not to answer")])
    major = models.CharField(initial=None, blank = True, verbose_name = "If you have some college education, what best describes your major?", choices = ["No College education", "Psychology/ Cognitive Sciences",  "Care Work/ Nursing", "Human Resources/ Communications", "Computer Science/ Engineering/", "Maths/ Phsycis/ Chemistry/ Earth Sciences", "Medicine/ Biology/ Life Sciences", "Economics/ Politics/ Sociology/ Social Sciences", "Langauges/ Literature", "History/ Philosophy/ ", "Art/ Design/ Architecture", "Other/ Not Listed", "I prefer not to answer"])
    commentsbox = models.TextField(initial=None, blank = True, verbose_name = "Do you have any further comments or suggestions?")
    income = models.PositiveIntegerField(verbose_name = 'What is your annual household income?', choices=[(0,"$0 - $10,000"), (1,"$10,001 - $20,000"), (2,"$20,001 - $30,000"), (3, "$30,001 - $45,000"), (4, "$45,001 - $70,000"), (5, "$70,001 - $100,000"), (6, "More than $100,000"), (7, "I prefer not to answer")])


    def calculate_bonus(self):
        if self.dice_count:
            self.participant.payoff = self.dice_win * Constants.high_bonus + (1 - self.dice_win) * Constants.low_bonus
        else:
            if self.investment:
                self.participant.payoff = self.good * Constants.high_bonus + (1 - self.good) * Constants.low_bonus
            else:
                self.participant.payoff = self.lottery_win * Constants.high_bonus + (1 - self.lottery_win) * Constants.low_bonus
Esempio n. 10
0
class Player(BasePlayer):
    gender = models.CharField(
        choices=['femenino', 'masculino'],
        doc="genero",
        widget=widgets.RadioSelect()
    )



    cutoff = models.CurrencyField(
        min=0, max=100 + 1,
        doc="min H payoff which player plays H",
        initial=0
    )

    decision = models.CharField(
        choices=['A', 'B'],
        doc="""Players play""",
        widget=widgets.RadioSelect()
    )

    private_payoff = models.CurrencyField(
        doc="H payoff",
        initial=0
    )

    dummy_decision = models.CharField(choices=['A', 'B'],
                                         doc="dum decision"
                                         )

    def other_player(self):
        return self.get_others_in_group()[0]

    def create_matrix(self):
        payoff_matrix = {
            'A':
                {
                    'A': self.private_payoff,
                    'B': self.private_payoff + c(self.session.config["mu_pay"])
                },
            'B':
                {
                    'A': c(self.session.config["d_payoff"]),
                    'B': c(self.session.config["bothd_payoff"])
                }
        }

        return payoff_matrix

    def set_payoff(self):
        self.payoff = c(self.create_matrix()[self.decision]['A']
                        * self.session.vars['weight_matrix'][self.decision]['A'] +
                        self.create_matrix()[self.decision]['B']
                        * self.session.vars['weight_matrix'][self.decision]['B'])
Esempio n. 11
0
class Player(BasePlayer):
    email = models.CharField(
        verbose_name=
        "Please enter you email address, so we may send you a code to access the payment you earned"
    )

    age = models.PositiveIntegerField(verbose_name='What is your age?',
                                      min=18,
                                      max=125)

    gender = models.CharField(choices=['Male', 'Female'],
                              verbose_name='What is your gender?',
                              widget=widgets.RadioSelect())

    education = models.CharField(
        choices=[
            'Less than a high school degree', 'High School Diploma',
            'Vocational Training', 'Attended College', 'Bachelor’s Degree',
            'Graduate Degree', 'Unknown'
        ],
        verbose_name=
        'What is the highest level of education you have completed?',
        widget=widgets.RadioSelect())

    geographic = models.CharField(
        verbose_name=
        'In which city and country did you grow up? If you lived in more than one place, list the one in which you spent the most time. (If the United States, please also indicate the state)'
    )

    previous_mturk = models.IntegerField(
        min=0,
        verbose_name=
        'Have you previously done any experiments on Mechanical Turk or other online sites? If you have not, please type 0 in the response box. If yes, please indicate how many experiments you have done in total.'
    )

    satisfaction = models.CharField(
        choices=[
            'Very pleased', 'Pleased', 'Neutral', 'Displeased',
            'Very displeased'
        ],
        verbose_name='How satisfied are you with the outcome of this game?',
        widget=widgets.RadioSelectHorizontal())

    reasoning_stay = models.CharField(
        verbose_name=
        'If/when you remained at the same planet(s), why did you stay at that/those planet(s)?'
    )

    reasoning_switch = models.CharField()

    reasoning_quit = models.CharField()
Esempio n. 12
0
class Player(BasePlayer):

    age = models.PositiveIntegerField(verbose_name="Edad", min=13, max=125)

    gender = models.CharField(choices=['Femenino', 'Masculino'],
                              verbose_name='Sexo',
                              widget=widgets.RadioSelect())

    field = models.CharField(choices=[
        'Economía', 'Psicología', "Derecho", "Ingeniería",
        "Gestión y Alta Dirección", "Arquitectura", "Sociología",
        "Ciencias políticas", "Antropología", "C. Comunicación", "Humanidades",
        "Otra"
    ],
                             verbose_name='¿Qué carrera estudias?',
                             widget=widgets.RadioSelect())

    tax1 = models.CharField(
        choices=['Sí', 'No'],
        verbose_name='¿Es justificable pagar menores impuestos al Estado?',
        widget=widgets.RadioSelect())

    tax2 = models.CharField(
        choices=['Sí', 'No'],
        verbose_name=
        '¿Pagarías menores impuestos al Estado, sabiendo que la probabilidad de ser atrapado es mínima?',
        widget=widgets.RadioSelect())

    corrup = models.CharField(
        choices=['Sí', 'No'],
        verbose_name='¿Crees que existe corrupción en el Estado?',
        widget=widgets.RadioSelect())

    malg = models.CharField(
        choices=['Sí', 'No'],
        verbose_name=
        '¿Crees que el Estado malgasta el dinero que recibe de los contribuyentes?',
        widget=widgets.RadioSelect())

    tasa1 = models.CharField(
        choices=['Sí', 'No'],
        verbose_name=
        '¿Es justificable que se aumente la tasa de impuestos si el Estado promete invertir el dinero en más obras para la población?',
        widget=widgets.RadioSelect())

    tasa2 = models.CharField(
        choices=['Sí', 'No'],
        verbose_name=
        'De acuerdo con la pregunta anterior, ¿Estarías dispuesto a contribuir con mayores impuestos a pesar de que las obras y políticas del Estado no te beneficien directamente?',
        widget=widgets.RadioSelect())

    avrisk = models.CharField(
        choices=['Sí', 'No'],
        verbose_name=
        '¿Apostarías S/.10 si existe un 50% de probabilidad de que ganes S/.5 más pero 50% de probabilidad de que pierdas S/. 5?',
        widget=widgets.RadioSelect())
Esempio n. 13
0
class Player(BasePlayer):

    othpayoff = models.IntegerField()
    starttime = models.FloatField()
    endtime = models.FloatField()
    demand = models.PositiveIntegerField()
    units = models.PositiveIntegerField(min=1,
                                        max=100,
                                        doc="""Quantity of units to order""")

    qu1 = models.PositiveIntegerField(choices=[66, 14, 41],
                                      widget=widgets.RadioSelect(),
                                      blank=True)
    qu2 = models.PositiveIntegerField(choices=[50, 82, 10],
                                      widget=widgets.RadioSelect(),
                                      blank=True)
    qu3 = models.PositiveIntegerField(choices=[300, 280, 100],
                                      widget=widgets.RadioSelect(),
                                      blank=True)

    def other_player(self):
        return self.get_others_in_group()[0]

    def set_payoff(self):

        q1 = self.units
        q2 = self.other_player().units
        d1 = self.demand
        d2 = self.other_player().demand

        if (q2 < d2):
            efdemand = d1 + int(round(0.8 * (d2 - q2)))
        else:
            efdemand = d1

        if (q1 > efdemand):
            self.payoff = Constants.price * efdemand - Constants.cost * q1
        else:
            self.payoff = Constants.price * q1 - Constants.cost * q1

        if (q1 < d1):
            efdemand2 = d2 + int(round(0.8 * (d1 - q1)))
        else:
            efdemand2 = d2

        if (q2 > efdemand2):
            self.othpayoff = Constants.price * efdemand2 - Constants.cost * q2
        else:
            self.othpayoff = Constants.price * q2 - Constants.cost * q2
Esempio n. 14
0
class Player(BasePlayer):
    decision = models.CharField(
        choices=['Cooperate', 'Defect'],
        doc="""This player's decision""",
        widget=widgets.RadioSelect()
    )

    def other_player(self):
        return self.get_others_in_group()[0]

    def set_payoff(self):

        payoff_matrix = {
            'Cooperate':
                {
                    'Cooperate': Constants.both_cooperate_payoff,
                    'Defect': Constants.betrayed_payoff
                },
            'Defect':
                {
                    'Cooperate': Constants.betray_payoff,
                    'Defect': Constants.both_defect_payoff
                }
        }

        self.payoff = (payoff_matrix[self.decision]
                       [self.other_player().decision])
Esempio n. 15
0
class Group(BaseGroup):
    company_chosen = models.BooleanField(
        doc="""Whether customer chooses company""",
        widget=widgets.RadioSelect(),
        choices=(
            (True, 'Choose'),
            (False, 'Decline'),
        )
    )

    company_choose_employee = models.FloatField(
        choices=Constants.company_choose_employee_choices,
        doc="""Company's different options of employee to offer customer""",
        verbose_name='Company Hiring Options',
        widget=widgets.RadioSelectHorizontal()
    )
    def set_payoffs(self):
        company = self.get_player_by_role('company')
        customer = self.get_player_by_role('customer')
        if not self.contract_accepted:
            company.payoff = Constants.company_rejected_pay
            customer.payoff = Constants.customer_choose_pay
        else:
            company.payoff = Constants.company_chosen_pay
            customer.payoff = Constants.customer_reject_pay
        customer.payoff += Constants.base_pay
        company.payoff += Constants.base_pay
Esempio n. 16
0
class Player(BasePlayer):
    decision = models.StringField(choices=['Cooperate', 'Defect'],
                                  doc="""현재 경기자의 결정""",
                                  widget=widgets.RadioSelect())

    def other_player(self):
        return self.get_others_in_group()[0]

    def set_payoff(self):
        points_matrix = {
            'Cooperate': {
                'Cooperate': Constants.both_cooperate_payoff,
                'Defect': Constants.betrayed_payoff
            },
            'Defect': {
                'Cooperate': Constants.betray_payoff,
                'Defect': Constants.both_defect_payoff
            }
        }

        self.payoff = (
            points_matrix[self.decision][self.other_player().decision])

    def get_coop(self):
        """이전 라운드까지의 협조 횟수를 돌려준다."""
        num_coop = 0
        for p in self.in_previous_rounds():
            if p.decision == "Cooperate":
                num_coop += 1
        return num_coop
Esempio n. 17
0
class Player(BasePlayer):
    gender = models.CharField(
        widget=widgets.RadioSelect(),
        choices=["Male", "Female", "Other"],
        verbose_name="With which gender do you most closely identify?")
    age = models.PositiveIntegerField(verbose_name="How old are you?")
    education = models.CharField(
        widget=widgets.RadioSelect(),
        choices=[
            "Less than high school",
            "High school graduate (includes equivalency)",
            "Some college, no degree", "Associate's degree",
            "Bachelor's degree", "Ph.D.", "Graduate or professional degree"
        ],
        verbose_name=
        "What is the highest degree or level of education you have completed?")
Esempio n. 18
0
class Player(BasePlayer):
    treatment = models.StringField()

    choice = models.StringField()

    # decision time collected by JavaScript method
    jsdectime_start = models.FloatField()
    jsdectime_end = models.FloatField()
    jsdectime = models.FloatField()
    # decision time collected by Python method
    pydectime = models.FloatField()

    pyresttime = models.FloatField()

    reward = models.FloatField()
    risk = models.FloatField()
    certainty = models.FloatField()
    display = models.IntegerField()

    # Whether the lottery is chosen in the trial: 1 = yes, 0 = no
    lottery = models.IntegerField()

    decmode = models.PositiveIntegerField(choices=[
        [7, 'Almost always (near 100% of the time)'],
        [6, 'Very often (about 80% of the time)'],
        [5, 'Moderately often (about 60% of the time)'],
        [4, 'About half of the time (50% of the time)'],
        [3, 'Moderately seldom (about 40% of the time)'],
        [2, 'Very seldom (about 20% of the time)'],
        [1, 'Almost never (near 0% of the time)'],
    ],
                                          widget=widgets.RadioSelect())

    payoff_ddm = models.LongStringField()
    pay_pound = models.FloatField()
Esempio n. 19
0
class Player(BasePlayer):
    def other_player(self):
        """Returns other player in group. Only valid for 2-player groups."""
        return self.get_others_in_group()[0]

    blank = models.CharField(blank=True)

    add100_1 = models.PositiveIntegerField()
    add100_2 = models.PositiveIntegerField()

    even_int = models.PositiveIntegerField()

    after_next_button_field = models.BooleanField()

    dynamic_choices = models.CharField()

    radio = models.CurrencyField(widget=widgets.RadioSelect(),
                                 choices=[c(1), c(2)])

    dynamic_radio = models.CharField(widget=widgets.RadioSelectHorizontal())

    dynamic_min_max = models.CurrencyField()

    in_before_session_starts = models.CurrencyField()

    def role(self):
        # you can make this depend of self.id_in_group
        return ''
Esempio n. 20
0
class Group(BaseGroup):

    accepted = models.StringField(choices=Constants.accept_choices,
                                  widget=widgets.RadioSelect())
    accepted_offer = models.CurrencyField()

    def set_payoff(self):

        for p in self.get_players():
            if self.accepted == 'A':
                if p.role == 'A':
                    self.accepted_offer = p.offer
                    p.payoff = Constants.endowment - self.accepted_offer
                elif p.role == 'B':
                    p.payoff = c(0)
                else:
                    p.payoff = self.accepted_offer
            elif self.accepted == 'B':
                if p.role == 'A':
                    p.payoff = c(0)
                elif p.role == 'B':
                    self.accepted_offer = p.offer
                    p.payoff = Constants.endowment - self.accepted_offer
                else:
                    p.payoff = self.accepted_offer
            else:
                p.payoff = c(0)

    pass
Esempio n. 21
0
class Player(BasePlayer):

    age = models.PositiveIntegerField(verbose_name='What is your age?',
                                      min=13,
                                      max=125)

    gender = models.CharField(choices=['Male', 'Female'],
                              verbose_name='What is your gender?',
                              widget=widgets.RadioSelect())

    crt_bat = models.PositiveIntegerField(verbose_name='''
        A bat and a ball cost 22 dollars in total.
        The bat costs 20 dollars more than the ball.
        How many dollars does the ball cost?''')

    crt_widget = models.PositiveIntegerField(verbose_name='''
        "If it takes 5 machines 5 minutes to make 5 widgets,
        how many minutes would it take 100 machines to make 100 widgets?"
        ''')

    crt_lake = models.PositiveIntegerField(verbose_name='''
        In a lake, there is a patch of lily pads.
        Every day, the patch doubles in size.
        If it takes 48 days for the patch to cover the entire lake,
        how many days would it take for the patch to cover half of the lake?
        ''')
Esempio n. 22
0
class Player(BasePlayer):

    ps_score_value = models.FloatField()
    ps_score = models.CharField(max_length=max(map(len, Constants.psscores)))

    computer = models.CharField(
        max_length=10, verbose_name="What computer are you sitting at?")

    people_best_intentions = models.IntegerField(
        choices=Constants.describe_me_level,
        verbose_name="I assume that people have only the best intentions:")
    will_to_return_a_favor = models.IntegerField(
        choices=Constants.describe_me_level,
        verbose_name="When someone does me a favor, I am willing to return it:"
    )
    give_to_without_expecting_anything_in_return = models.IntegerField(
        choices=Constants.describe_me_level,
        verbose_name=
        "I am willing to give to good causes without expecting anything in return:"
    )

    donate = models.IntegerField(min=0, max=Constants.donate_max)

    present = models.IntegerField(
        verbose_name="Which present do you give to the stranger?",
        widget=widgets.RadioSelect(),
        choices=list(sorted(Constants.presents.items())))
Esempio n. 23
0
class Group(BaseGroup):

    sent_amount = models.CurrencyField(widget=widgets.RadioSelect(),
                                       doc="""Amount sent by P1""",)
    sent_back_amount = models.CharField(widget=widgets.RadioSelect(),
                                        doc="""Offer Amount Accepted/Rejected by P2""",)

    def set_payoffs(self):
        p1 = self.get_player_by_id(1)
        p2 = self.get_player_by_id(2)
        if self.sent_back_amount == 'Accept':
            p1.payoff = Constants.endowment - self.sent_amount
            p2.payoff = self.sent_amount * Constants.multiplication_factor
        else:
            p1.payoff = 0
            p2.payoff = 0
Esempio n. 24
0
class Player(BasePlayer):
    decision = models.StringField(choices=['B', 'A'],
                                  doc="""Decisión del jugador actual""",
                                  widget=widgets.RadioSelect())

    dummy_decision = models.CharField(choices=['A', 'B'], doc="dum decision")

    def other_player(self):
        return self.get_others_in_group()[0]

    def set_payoff(self):
        points_matrix = {
            'B': {
                'B': Constants.both_cooperate_payoff,
                'A': Constants.betrayed_payoff
            },
            'A': {
                'B': Constants.betray_payoff,
                'A': Constants.both_defect_payoff
            }
        }

        self.payoff = (
            points_matrix[self.decision][self.other_player().decision])

    def get_coop(self):
        """Devuelve el número de colaboraciones hasta la ronda anterior."""
        num_coop = 0
        for p in self.in_previous_rounds():
            if p.decision == "B":
                num_coop += 1
        return num_coop
Esempio n. 25
0
class Group(BaseGroup):
    total_contribution = models.CurrencyField()

    individual_share = models.CurrencyField()
    max_contributor = None
    max_contribution = models.CurrencyField()
    numbers = models.IntegerField(widget=widgets.RadioSelect())

    def set_payoffs(self):
        self.total_contribution = sum(
            [p.contribution for p in self.get_players()])
        self.individual_share = self.total_contribution * Constants.efficiency_factor / Constants.players_per_group
        for p in self.get_players():
            p.payoff = (Constants.endowment -
                        p.contribution) + self.individual_share

    #def find_min_max(self):
        self.max_contributor = max(self.get_players(),
                                   key=lambda p: p.contribution)
        #print("max found is", max(self.get_players(), key=lambda p: p.contribution))
        #print(self.max_contributor.contribution,self.max_contributor.participant)
        self.max_contribution = self.max_contributor.contribution

    def group_fields(self):
        self.max_contributor = max(self.get_players(),
                                   key=lambda p: p.contribution)
        self.lowest_contributor = self.max_contributor.get_others_in_group()
        list3 = []
        for p in self.lowest_contributor:
            list3.append(p.id_in_group)
        print("group fields", list3)
        return list3
Esempio n. 26
0
class Group(BaseGroup):
    sale_price = models.CurrencyField()

    seller_id = models.PositiveIntegerField(
        choices=[(i, 'Buy from seller %i' % i) for i in
                 range(1, Constants.players_per_group)] + [
                    (0, 'Buy nothing')],
        widget=widgets.RadioSelect(),
        doc="""0 means no purchase made"""
    )  # seller index

    def set_payoff(self):
        for p in self.get_players():
            p.payoff = Constants.initial_endowment

        if self.seller_id != 0:
            seller = self.get_seller()
            self.sale_price = seller.seller_proposed_price

            buyer = self.get_player_by_role('buyer')
            buyer.payoff += seller.seller_proposed_quality + Constants.buyer_extra_value - seller.seller_proposed_price
            seller.payoff += seller.seller_proposed_price - seller.seller_proposed_quality

    def get_seller(self):
        for p in self.get_players():
            if 'seller' in p.role() and p.seller_id() == self.seller_id:
                return p
Esempio n. 27
0
class Player(BasePlayer):
    entite = models.CharField(initial=Constants.c_entites[0],
                              choices=Constants.c_entites,
                              widget=widgets.RadioSelect())
    average_note = models.FloatField(min=Constants.c_min_note,
                                     max=Constants.c_max_note,
                                     initial=0)

    def generate_proposition_stubs(self):
        # Create a fixed number of "proposition stubs"
        for i in range(Constants.c_nb_propositions_per_player):
            proposition = self.proposition_set.create(
            )  # create a new Proposition object as part of the player's decision set
            proposition.prop_player_ID_ingroup = self.id_in_group
            proposition.type = Constants.c_proposition_types[i]
            proposition.text = "Prop-" + proposition.type + "-" + str(
                self.id_in_group)
            proposition.save()  # important: save to DB!

    def generate_appreciation_stubs(self):
        # Get all propositions that don't belong to that player
        proposition_qs = Proposition.objects.exclude(player=self.pk)
        for prop in proposition_qs:
            appreciation = self.appreciation_set.create()
            appreciation.player = self
            appreciation.app_player_ID_ingroup = self.id_in_group
            appreciation.proposition = prop
            appreciation.note = 0
            appreciation.reaction = " "
            appreciation.related_version = 999
            appreciation.up_to_date = False
            appreciation.save()  # important: save to DB!
Esempio n. 28
0
class Player(BasePlayer):
    def set_payoff(self):
        """Calculate payoff, which is zero for the survey"""
        self.payoff = 0

    q_country = CountryField(
        verbose_name='What is your country of citizenship?')
    q_age = models.PositiveIntegerField(verbose_name='What is your age?',
                                        choices=range(13, 125),
                                        initial=None)
    q_gender = models.CharField(initial=None,
                                choices=['Male', 'Female'],
                                verbose_name='What is your gender?',
                                widget=widgets.RadioSelect())

    crt_bat = models.PositiveIntegerField(verbose_name='''
        A bat and a ball cost 22 dollars in total.
        The bat costs 20 dollars more than the ball.
        How many dollars does the ball cost?''')

    crt_widget = models.PositiveIntegerField(verbose_name='''
        "If it takes 5 machines 5 minutes to make 5 widgets,
        how many minutes would it take 100 machines to make 100 widgets?"
        ''')

    crt_lake = models.PositiveIntegerField(verbose_name='''
        In a lake, there is a patch of lily pads.
        Every day, the patch doubles in size.
        If it takes 48 days for the patch to cover the entire lake,
        how many days would it take for the patch to cover half of the lake?
        ''')
Esempio n. 29
0
class Group(BaseGroup):
    total_return = models.CurrencyField(
        doc="""Total return from agent's effort = [Return for single unit of
            agent's work effort] * [Agent's work effort]"""
    )

    agent_fixed_pay = models.CurrencyField(
        doc="""Amount offered as fixed pay to agent""",
        min=Constants.min_fixed_payment, max=Constants.max_fixed_payment,
        verbose_name='Fixed Payment (from {} to {})'.format(
            Constants.min_fixed_payment, Constants.max_fixed_payment)
    )

    agent_return_share = models.FloatField(
        choices=Constants.agent_return_share_choices,
        doc="""Agent's share of total return""",
        verbose_name='Return Share',
        widget=widgets.RadioSelectHorizontal()
    )

    agent_work_effort = models.PositiveIntegerField(
        choices=range(1, 10 + 1),
        doc="""Agent's work effort, [1, 10]""",
        widget=widgets.RadioSelectHorizontal(),
    )

    agent_work_cost = models.CurrencyField(
        doc="""Agent's cost of work effort"""
    )

    contract_accepted = models.BooleanField(
        doc="""Whether agent accepts proposal""",
        widget=widgets.RadioSelect(),
        choices=(
            (True, 'Accept'),
            (False, 'Reject'),
        )
    )

    def set_payoffs(self):
        principal = self.get_player_by_role('principal')
        agent = self.get_player_by_role('agent')

        if not self.contract_accepted:
            principal.payoff = Constants.reject_principal_pay
            agent.payoff = Constants.reject_agent_pay
        else:
            self.agent_work_cost = cost_from_effort(self.agent_work_effort)
            self.total_return = return_from_effort(self.agent_work_effort)

            money_to_agent = self.agent_return_share * \
                             self.total_return + self.agent_fixed_pay
            agent.payoff = money_to_agent - self.agent_work_cost
            principal.payoff = self.total_return - money_to_agent
        principal.payoff += Constants.base_pay
        agent.payoff += Constants.base_pay

    def return_share_as_percentage(self):
        return utils.float_as_percentage(self.agent_return_share)
Esempio n. 30
0
class Player(BasePlayer):
    decision = models.StringField(
        choices=["stay silent", "betray"],
        widget=widgets.RadioSelect(),
        verbose_name="Make a choice",
        doc="Participants make a choice about cooperation")

    years = models.PositiveIntegerField()