class Player(BasePlayer):

    subperiod_time = models.PositiveIntegerField(
        doc="""The length of the real effort task timer.""")

    period_number = models.PositiveIntegerField(doc='''period number''')

    subperiod_number = models.PositiveIntegerField(doc='''subperiod number''')

    rp = models.FloatField(doc='''customer reserve price''')

    mc = models.FloatField(doc='''firm mill cost''')

    transport_cost = models.FloatField(doc="""transport, or shopping cost""")

    loc = models.FloatField(doc="player's location")

    price = models.FloatField(doc="player's price in previous round/subperiod")

    next_subperiod_price = models.FloatField(
        doc="player's price in current round/subperiod")

    boundary_lo = models.FloatField(doc="player's low end of boundary")

    boundary_hi = models.FloatField(doc="player's high end of boundary")

    prev_round_payoff = models.FloatField(
        doc="player's payoffs this previous round/subperiod")

    prev_round_cumulative_payoff = models.FloatField(
        doc="player's payoffs cumulative the previous round/subperiod.")

    paid_period = models.IntegerField(
        doc='''1 if this is a paid period, 0 otherwise''')
Example #2
0
class Player(BasePlayer):
    def score_round(self):
        # update player payoffs
        if (self.solution == self.user_total):
            self.is_correct = True
            self.payoff_score = 1
        else:
            self.is_correct = False
            self.payoff_score = c(0)

    task_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer.""")

    int1 = models.PositiveIntegerField(doc="this round's first int")

    int2 = models.PositiveIntegerField(doc="this round's second int")

    solution = models.PositiveIntegerField(
        doc="this round's correct summation")

    user_total = models.PositiveIntegerField(
        min=1,
        max=9999,
        doc="user's summation",
        widget=widgets.TextInput(attrs={'autocomplete': 'off'}))

    is_correct = models.BooleanField(doc="did the user get the task correct?")

    payoff_score = models.FloatField(doc='''score in this task''')
Example #3
0
class Player(BasePlayer):

    identification1 = models.PositiveIntegerField(
        initial=None,
        choices=range(1, 8),
        verbose_name='Persons of your same ethnicity living in Xishuangbanna',
        widget=widgets.RadioSelectHorizontal())

    identification2 = models.PositiveIntegerField(
        initial=None,
        choices=range(1, 8),
        verbose_name=
        'Persons of your same ethnicity living outside Xishuangbanna',
        widget=widgets.RadioSelectHorizontal())

    identification3 = models.PositiveIntegerField(
        initial=None,
        choices=range(1, 8),
        verbose_name=
        'Persons with your same confession living in Xishuangbanna',
        widget=widgets.RadioSelectHorizontal())

    identification4 = models.PositiveIntegerField(
        initial=None,
        choices=range(1, 8),
        verbose_name=
        'Persons with your same confession living outside Xishuangbanna',
        widget=widgets.RadioSelectHorizontal())
Example #4
0
class Player(BasePlayer):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    group = models.ForeignKey(Group, null = True)
    # </built-in>

    contribution = models.CurrencyField(choices=[0,Constants.endowment],widget=widgets.RadioSelect())
    record = models.CurrencyField()
    punishment_p1 = models.CurrencyField(min=0, max=50)
    punishment_p2 = models.CurrencyField(min=0, max=50)
    punishment_p3 = models.CurrencyField(min=0, max=50)
    income = models.PositiveIntegerField(min=0, max=90)
    cost  = models.PositiveIntegerField(min=0, max=150)
    deduction = models.PositiveIntegerField(min=0, max=150)
    def other_player(self):
        """Returns other player in group. Only valid for 2-player groups."""
        return self.get_others_in_group()

    def set_payoff(self):
        self.income = Constants.endowment - self.contribution + group.individual_share
        self.cost = self.punishment_for_p1 + self.punishment_for_p2 + self.punishment_for_p3
        self.deduction = sum([q.punishment_p1 for q in self.other_player()])

    def role(self):
        if self.id_in_group == 1:
            return 'Player 1'
        if self.id_in_group == 2:
            return 'Player 2'
        if self.id_in_group == 3:
            return 'Player 3'
Example #5
0
class Player(BasePlayer):

    health = models.PositiveIntegerField(min=0, max=Constants.max_health)
    resources = models.PositiveIntegerField(min=0)

    use_toilet = models.BooleanField(widget=widgets.RadioSelectHorizontal())
    small_cleaning = models.BooleanField(widget=widgets.RadioSelectHorizontal())

    big_clean = models.BooleanField(widget=widgets.RadioSelectHorizontal())
Example #6
0
class Player(BasePlayer):
    user_text = models.CharField(
    	doc="user's transcribed text")
    is_correct = models.BooleanField(
    	doc="did the user get the task correct?")
    final_score = models.IntegerField(
    	doc="player's total score up to this round")


    quiz_01 = models.PositiveIntegerField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
      
    quiz_02 = models.PositiveIntegerField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')

    quiz_03 = models.PositiveIntegerField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
      
    quiz_04 = models.FloatField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
      
    quiz_05 = models.FloatField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
      
    quiz_06= models.FloatField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
      
    quiz_07 = models.FloatField(
        verbose_name='Your earnings:',
        min = 0,
        max = 999,
        initial=None,
        doc='quiz answer')
Example #7
0
class Player(BasePlayer):

    turk_id = models.CharField(
        verbose_name='Please enter your Mechanical Turk ID',
        widget=widgets.TextInput())

    clear = models.PositiveIntegerField(
        choices=[[1, 'Very clear'], [2, 'Somewhat clear'],
                 [3, 'Neither clear nor unclear'], [4, 'Somewhat unclear'],
                 [5, 'Very unclear']],
        verbose_name='How clear were the instructions to play the game?',
        widget=widgets.RadioSelectHorizontal())

    timing_instr = models.PositiveIntegerField(
        choices=[
            [1, 'Very long'],
            [2, 'Somewhat long'],
            [3, 'Just right'],
            [4, 'Somewhat short'],
            [5, 'Very short'],
        ],
        verbose_name=
        'How was the allocated timing to read the instructions? i.e. Did you have enough time to read the instructions before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    timing_dec = models.PositiveIntegerField(
        choices=[[1, 'Very fast'], [2, 'Somewhat fast'], [3, 'Just right'],
                 [4, 'Somewhat slow'], [5, 'Very slow']],
        verbose_name=
        'How was the allocated timing for the decision making page? (The page each round that asks for your decision) i.e. Did you have enough time to make an informed decision before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    timing_res = models.PositiveIntegerField(
        choices=[[1, 'Very fast'], [2, 'Somewhat fast'], [3, 'Just right'],
                 [4, 'Somewhat slow'], [5, 'Very slow']],
        verbose_name=
        'How was the allocated timing for the page displaying the results of the game? (The page that shows the outcome for each round) i.e. Did you have enough time to read the results of each round before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    diff = models.PositiveIntegerField(
        choices=[[1, 'Very easy'], [2, 'Somewhat easy'],
                 [3, 'Neither easy nor difficult'], [4, 'Somewhat difficult'],
                 [5, 'Very difficult']],
        verbose_name='How easy was it to understand the goal of the game?',
        widget=widgets.RadioSelectHorizontal())

    comment = models.CharField(
        verbose_name='Please write any comments or suggestions about the game',
        widget=widgets.Textarea())

    def role(self):
        if self.id_in_group == 1:
            return 'attacker'
        if self.id_in_group == 2:
            return 'defender'
        if self.id_in_group == 3:
            return 'user'
Example #8
0
class Player(BasePlayer):

   ##-------------------------------
   # treatment assigment variable
   TT = models.CharField() # treatment player variable

   ##-------------------------------
   # Form variables
   name = models.CharField()
   profession = models.CharField()
   age = models.PositiveIntegerField()
   playAs = models.CharField(
       choices=["General audience", "Fisherman", "Manager", "Scientist in the field of fisheries",
                "Scientist (other)", "Student in the field of fisheries", "Student (other)"])

   dynamicKnowledge =  models.CharField(
       choices=["Fully agree", "Agree", "Neither agree nor disagree ",
                "Disagree","Fully disagree"])
   groupCooperation = models.CharField(
       choices=["Fully agree", "Agree", "Neither agree nor disagree ",
                "Disagree","Fully disagree"])
   leverageCooperation = models.CharField(
       choices=["Profit table analysis", "Pledge analysis", "Biomass analysis",
                "Catch & others profit analysis"])
   suffConditionCooperation = models.CharField(
       choices=["Fully agree", "Agree", "Neither agree nor disagree ",
                "Disagree","Fully disagree"])
   biomassUncertainty = models.CharField(
       choices=["Fully agree", "Agree", "Neither agree nor disagree ",
                "Disagree", "Fully disagree"])

   blimUncertainty = models.CharField(
            choices=["Fully agree", "Agree", "Neither agree nor disagree ",
                "Disagree", "Fully disagree","Not in my treatment"])


   ##-------------------------------
   ## players variables
   profit = models.FloatField()

   ## player etimation other harvesting level
   other_choice = models.PositiveIntegerField(
       choices=Constants.other_choice_catch,initial=0)

   ## player harvest choice
   catch_choice = models.PositiveIntegerField(
            choices=Constants.choice_catch,initial=0)

   ## player proposal harvest choice
   catch_pledge = models.PositiveIntegerField(
       choices=Constants.choice_catch,initial=0)
Example #9
0
class Player(BasePlayer):
    output0 = models.PositiveIntegerField()
    output1 = models.PositiveIntegerField()
    output2 = models.PositiveIntegerField()
    output3 = models.PositiveIntegerField()
    output4 = models.PositiveIntegerField()
    output5 = models.PositiveIntegerField()
    output6 = models.PositiveIntegerField()
    output7 = models.PositiveIntegerField()
    output8 = models.PositiveIntegerField()
Example #10
0
class Player(BasePlayer):

    def score_round(self):
        # update player payoffs
        if (self.correct_text == self.user_text):
            self.is_correct = True
            self.payoff_score = 1
        else:
            self.is_correct = False
            self.payoff_score = 0


    task_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer."""
    )

    correct_text = models.CharField(
        doc="user's transcribed text")

    user_text = models.CharField(
        doc="user's transcribed text",
        widget=widgets.TextInput(attrs={'autocomplete':'off'}))

    is_correct = models.BooleanField(
        doc="did the user get the task correct?")

    ret_final_score = models.IntegerField(
        doc="player's total score up to this round")

    payoff_score = models.FloatField(
            doc = '''score in this task'''
        )
Example #11
0
class Group(BaseGroup):
    # variables that change for each group
    treatment_endowment = models.IntegerField()
    treatment_treatment = models.TextField()
    a_takes = models.DecimalField(min=0, max=100, max_digits=5, decimal_places=2)
    total_taken = models.CurrencyField()
    b_predicts = models.PositiveIntegerField(min=0, max=100)
    b_willing = models.DecimalField(min=0, max_digits=6, decimal_places=3)
    b_message = models.TextField()
    b_message_price = models.DecimalField(max_digits=5, decimal_places=2)
    price_method = models.TextField()
    price_display = models.TextField()
    b_eligible = models.BooleanField()
    target_income = models.DecimalField(max_digits=5, decimal_places=2)
    reader_index = models.IntegerField()

    def final_pay(self):
        p1 = self.get_player_by_id(1)
        p2 = self.get_player_by_id(2)
        p1.final_reward = self.treatment_endowment+ p1.task_reward + self.total_taken

        if self.price_method != 'WTA':
            if self.b_eligible:
                p2.final_reward = self.treatment_endowment+ p2.task_reward - self.total_taken - self.b_message_price
            else:
                p2.final_reward = self.treatment_endowment + p2.task_reward - self.total_taken
        else:  # WTA
            if self.b_eligible:
                p2.final_reward = self.treatment_endowment + p2.task_reward - self.total_taken
            else:  # gave up right to send message
                p2.final_reward = self.treatment_endowment + p2.task_reward - self.total_taken + self.b_message_price

    def reader_pay(self):
        for p in self.get_players():
            p.final_reward = self.treatment_endowment + p.task_reward
Example #12
0
class Player(BasePlayer):

    ret_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer.""")
    user_text = models.CharField(doc="user's transcribed text")
    is_correct = models.BooleanField(doc="did the user get the task correct?")
    ret_final_score = models.IntegerField(
        doc="player's total score up to this round")
    round_payoff = models.FloatField(
        doc=
        "total number of correct real effort tasks, completed before timer expired"
    )

    def set_final_score(self):
        correct_cnt = 0
        for p in self.in_all_rounds():
            if p.round_payoff != None:
                correct_cnt = correct_cnt + p.round_payoff
            else:
                correct_cnt = correct_cnt + 0

        if correct_cnt == None:
            self.ret_final_score = 20
        elif (correct_cnt < 10):
            self.ret_final_score = 2 + (2 * correct_cnt)
        else:
            self.ret_final_score = 20
Example #13
0
class Player(BasePlayer):

   ##-------------------------------
   # treatment assigment variable
   TT = models.CharField() # treatment player variable

   # test Form variables
   growthTest    = models.PositiveIntegerField(min=0, max=3)
   profitTest    = models.PositiveIntegerField(min=0, max=150)
   profitIndTest = models.FloatField()
   biomassTest   = models.PositiveIntegerField()

   ##-------------------------------
   # 1st Form variables
   name = models.CharField()
   profession = models.CharField()
   age = models.PositiveIntegerField()
   playAs = models.CharField(
       choices=["Pêcheur", "Gestionnaire dans le domaine de l'halieutique",
                "Scientifique dans le domaine de l'halieutique",
                "Scientifique (autre)", "Etudiant dans le domaine de l'halieutique", "Etudiant (autre)", "Autre"])
   # 2nd Form variables
   dynamicKnowledge = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord, ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord"])
   groupCooperation = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord, ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord"])
   leverageCooperation = models.CharField(
       choices=["Analyse du tableau des profits", "Analyse des propositions", "Analyse du niveau de biomasse",
                "Analyse du niveau de capture et de profit des autres participants"])
   suffConditionCooperation = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord, ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord"])
   biomassUncertainty = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord, ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord"])

   blimUncertainty = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord, ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord","Pas dans mon traitement"])

   ##-------------------------------
   ## players variables
   profit       = models.FloatField()
   predProfit = models.FloatField(initial=0)

   ## player etimation other harvesting level
   other_choice = models.PositiveIntegerField(
       choices=Constants.other_choice_catch,initial=0)

   ## player harvest choice
   catch_choice = models.PositiveIntegerField(
            choices=Constants.choice_catch,initial=0)

   ## player proposal harvest choice
   catch_pledge = models.PositiveIntegerField(
       choices=Constants.choice_catch,initial=0)
Example #14
0
class Player(otree.models.BasePlayer):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    group = models.ForeignKey(Group, null = True)
    # </built-in>

    def other_player(self):
        """Returns other player in group. Only valid for 2-player groups."""
        return self.get_others_in_group()[0]

    # example field
    my_field = models.PositiveIntegerField(
        min=0,
        max=(Constants.producer_budget/Constants.album_production_cost),
        doc="""
        Description of this field, for documentation
        """
    )

    consumer_purchase = models.PositiveIntegerField(
        min=0,
        max=(Constants.consumer_budget/Constants.album_own_cost),
        doc="""
        Description of this field, for documentation
        """
    )

    album_purchase = models.PositiveIntegerField(
        min = 0,
        max = 1,
        doc = """ Binary album purchase
        """
    )


    def role(self):
        # you can make this depend of self.id_in_group
        if self.id_in_group == 1:
            return 'producer'
        if self.id_in_group == 2:
            return 'consumer'
Example #15
0
class Player(BasePlayer):

    ##-------------------------------
    # treatment assigment variable
    TT = models.PositiveIntegerField()  # treatment player variable

    # test Form variables
    growthTest = models.PositiveIntegerField(min=0, max=3)
    profitTest = models.PositiveIntegerField(min=0, max=150)
    profitIndTest = models.FloatField()
    biomassTest = models.FloatField()

    ##-------------------------------
    ## players variables
    profit = models.FloatField(initial=0)
    predProfit = models.FloatField(initial=0)

    ## player etimation other harvesting level
    other_choice = models.PositiveIntegerField(
        choices=Constants.other_choice_catch, initial=0)

    ## player harvest choice
    catch_choice = models.PositiveIntegerField(choices=Constants.choice_catch,
                                               initial=0)

    ## player proposal harvest choice
    catch_pledge = models.PositiveIntegerField(choices=Constants.choice_catch,
                                               initial=0)
Example #16
0
class Player(otree.models.BasePlayer):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    group = models.ForeignKey(Group, null=True)

    # </built-in>
    def set_payoff(self):
        self.payoff = 0

    # example field
    q_race = models.CharField(
        initial=None,
        choices=RACE_CHOICES,
        verbose_name="Ethnicity origin (or Race): Please specify your ethnicity"
    )
    q_age = models.PositiveIntegerField(verbose_name="What is your age?",
                                        choices=range(13, 125),
                                        initial=None)
    q_gender = models.CharField(initial=None,
                                choices=['Female', 'Male'],
                                verbose_name="What is your gender?",
                                widget=widgets.RadioSelect())
    q_education = models.CharField(
        initial=None,
        choices=EDUCATION_CHOICES,
        verbose_name=
        "Education: What is the highest degree or level of school you have completed?",
    )
    q_household = models.CharField(
        initial=None,
        choices=HOUSEHOLD_CHOICES,
        verbose_name="Marital Status: What is your marital status",
    )
    q_gpa = models.CharField(
        blank=True, verbose_name="If you are a student, what is your gpa?")
    q_professional = models.CharField(
        initial=None,
        choices=PROFESSIONAL_CHOICES,
        verbose_name="Employment Status: Are you currenly...?",
    )
    q_decision = models.TextField(
        initial=None,
        verbose_name=
        "Can you explain in few words what guided your decision to invest or not invest in the Group Account?"
    )
    q_comments = models.TextField(
        blank=True,
        initial=None,
        verbose_name=
        "Do you have any comment, questions, or complains about today's experiment?"
    )
Example #17
0
class Player(otree.models.BasePlayer):

    # <built-in>
    group = models.ForeignKey(Group, null=True)
    subsession = models.ForeignKey(Subsession)
    # </built-in>

    decision = models.CharField(choices=['ACTIVE', 'INACTIVE'],
                                doc="""このプレイヤーの選択は""",
                                widget=widgets.RadioSelect())

    nghb = models.PositiveIntegerField()
    num_active = models.PositiveIntegerField()

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

    def role(self):
        return Constants.places[self.id_in_group - 1]

    def num_nghb(self):
        return len(Group.network_histry[self.subsession.round_number -
                                        1][1][self.role()])
Example #18
0
class Player(BasePlayer):

    extraction = models.DecimalField(
        max_digits=2,
        decimal_places=0,
        min=0,
        max=Constants.endowment,
        choices=[0, 1, 2, 3, 4, 5],
        doc="""The amount extracted by the player""",
    )

    partial_pay = models.CurrencyField()

    ranking = models.DecimalField(max_digits=2, decimal_places=0)

    auxiliar = models.PositiveIntegerField()

    aux_2_1 = models.DecimalField(max_digits=2, decimal_places=0)
    aux_2_2 = models.DecimalField(max_digits=2, decimal_places=0)
    aux_2_3 = models.DecimalField(max_digits=2, decimal_places=0)

    gp_ranking = models.DecimalField(max_digits=2, decimal_places=0)

    def the_ranking(self):
        self.auxiliar = self.participant_id
        if self.auxiliar == self.subsession.posit_1:
            self.ranking = self.subsession.rank_p_1
        elif self.auxiliar == self.subsession.posit_2:
            self.ranking = self.subsession.rank_p_2
        elif self.auxiliar == self.subsession.posit_3:
            self.ranking = self.subsession.rank_p_3
        elif self.auxiliar == self.subsession.posit_4:
            self.ranking = self.subsession.rank_p_4
        elif self.auxiliar == self.subsession.posit_5:
            self.ranking = self.subsession.rank_p_5
        elif self.auxiliar == self.subsession.posit_6:
            self.ranking = self.subsession.rank_p_6
        elif self.auxiliar == self.subsession.posit_7:
            self.ranking = self.subsession.rank_p_7
        elif self.auxiliar == self.subsession.posit_8:
            self.ranking = self.subsession.rank_p_8
        elif self.auxiliar == self.subsession.posit_9:
            self.ranking = self.subsession.rank_p_9
        elif self.auxiliar == self.subsession.posit_10:
            self.ranking = self.subsession.rank_p_10
        elif self.auxiliar == self.subsession.posit_11:
            self.ranking = self.subsession.rank_p_11
        elif self.auxiliar == self.subsession.posit_12:
            self.ranking = self.subsession.rank_p_12
Example #19
0
class Player(BasePlayer):

    iban = IBANField(verbose_name="IBAN")

    bic = BICField(verbose_name="BIC")

    bankname = models.CharField(verbose_name="Nachname:", max_length=50)

    bankvname = models.CharField(verbose_name="Vorname:", max_length=50)

    street = models.CharField(verbose_name="Straße / Hausnr.:", max_length=50)

    city = models.CharField(verbose_name="Stadt:", max_length=50)

    zipcode = models.IntegerField(verbose_name="PLZ:")

    user_agent = models.CharField()
    window_height = models.CharField()
    window_width = models.CharField()

    ibanmsgseen = models.PositiveIntegerField(default=0)
Example #20
0
class Player(BasePlayer):
    pain_1 = models.PositiveIntegerField()
    pain_2 = models.PositiveIntegerField()
    pain_3 = models.PositiveIntegerField()
    pain_4 = models.PositiveIntegerField()
    pain_5 = models.PositiveIntegerField()
    pain_6 = models.PositiveIntegerField()
    pain_7 = models.PositiveIntegerField()
    pain_8 = models.PositiveIntegerField()
    int_sens = models.FloatField()
    int_pain = models.FloatField()

    def compute_pain_levels(self):
        self.int_sens = 2
        self.int_pain = 7
        with open('pain_file_phase1_out.csv', 'a') as f:
            f.write("{},{},{},{},{},{},{}".format(
                self.participant.vars['firstname'],
                self.participant.vars['surname'], self.participant.vars['sex'],
                self.participant.vars['school'], self.int_sens, self.int_pain))

    def role(self):
        return {1: 'Experimenter', 2: 'Player'}[self.id_in_group]
Example #21
0
class Player(BasePlayer):

    debriefing_guess_which_group = models.CharField(
        max_length=255,
        widget=widgets.RadioSelect(),
        choices=[
            'Gruppe mit Anweisungen für alle zu positiver Kommunikation',
            'Gruppe mit Konfident mit positiver Kommunikation',
            'Gruppe mit Konfident mit negativer Kommunikation',
            'Kontrollgruppe ohne eigentliche Anweisungen', 'Weiss nicht'
        ])

    debriefing_sure_about_confidant_in_group = models.PositiveIntegerField(
        min=1, max=10, widget=widgets.SliderInput(show_value=False))

    debriefing_who_was_confidant = models.CharField(
        max_length=255, widget=widgets.RadioSelect(), choices=[])

    what_made_you_assume_confidant = models.TextField(default='n/a')
    debriefing_feedback = models.TextField()

    # confidant
    confidant_debriefing_feedback = models.TextField()
Example #22
0
class Player(BasePlayer):

    ##-------------------------------
    # treatment assigment variable
    TT = models.CharField()  # treatment player variable

    ##-------------------------------
    # 1st Form variables
    name = models.CharField()
    profession = models.CharField()
    age = models.PositiveIntegerField()
    playAs = models.CharField(choices=[
        "General audience", "Fisherman", "Manager",
        "Scientist in the field of fisheries", "Scientist (other)",
        "Student in the field of fisheries", "Student (other)"
    ])

    # test Form variables
    growthTest = models.PositiveIntegerField(min=0, max=3)
    profitTest = models.PositiveIntegerField(min=0, max=150)
    profitIndTest = models.FloatField()
    #biomassTest    = models.PositiveIntegerField(min=0, max=70)

    ##-------------------------------
    ## players variables
    profit = models.FloatField()

    ## player etimation other harvesting level
    other_choice = models.PositiveIntegerField(
        choices=Constants.other_choice_catch, initial=0)

    ## player harvest choice
    catch_choice = models.PositiveIntegerField(choices=Constants.choice_catch,
                                               initial=0)

    ## player proposal harvest choice
    catch_pledge = models.PositiveIntegerField(choices=Constants.choice_catch,
                                               initial=0)
Example #23
0
class Group(BaseGroup):
    groupoutput3 = models.PositiveIntegerField()
    groupoutput4 = models.PositiveIntegerField()
    groupoutput5 = models.PositiveIntegerField()
    groupoutput6 = models.PositiveIntegerField()
    groupoutput7 = models.PositiveIntegerField()
    groupoutput8 = models.PositiveIntegerField()

    def set_output3(self):
        self.groupoutput3 = sum([p.output3 for p in self.get_players()])
        for p in self.get_players():
            p.share3 = p.output3 / self.groupoutput3

    def set_output4(self):
        self.groupoutput4 = sum([p.output4 for p in self.get_players()])
        for p in self.get_players():
            p.share4 = p.output4 / self.groupoutput4

    def set_output5(self):
        self.groupoutput5 = sum([p.output5 for p in self.get_players()])
        for p in self.get_players():
            p.share5 = p.output5 / self.groupoutput5

    def set_output6(self):
        self.groupoutput6 = sum([p.output for p in self.get_players()])
        for p in self.get_players():
            p.share6 = p.output6 / self.groupoutput6

    def set_output7(self):
        self.groupoutput7 = sum([p.output7 for p in self.get_players()])
        for p in self.get_players():
            p.share7 = p.output7 / self.groupoutput7

    def set_output8(self):
        self.groupoutput8 = sum([p.output8 for p in self.get_players()])
        for p in self.get_players():
            p.share8 = p.output8 / self.groupoutput8
Example #24
0
class Player(otree.models.BasePlayer):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    group = models.ForeignKey(Group, null=True)
    # </built-in>

    # example field
    my_field = models.PositiveIntegerField(
        min=0,
        max=(Constants.producer_budget / Constants.album_production_cost),
        doc="""
        Description of this field, for documentation
        """)

    totalValue = models.PositiveIntegerField()

    album1BuyCount = models.PositiveIntegerField()
    album2BuyCount = models.PositiveIntegerField()
    album3BuyCount = models.PositiveIntegerField()
    album4BuyCount = models.PositiveIntegerField()
    album5BuyCount = models.PositiveIntegerField()
    album6BuyCount = models.PositiveIntegerField()
    album7BuyCount = models.PositiveIntegerField()
    album8BuyCount = models.PositiveIntegerField()
    album9BuyCount = models.PositiveIntegerField()
    album10BuyCount = models.PositiveIntegerField()

    album1ListenCount = models.PositiveIntegerField()
    album2ListenCount = models.PositiveIntegerField()
    album3ListenCount = models.PositiveIntegerField()
    album4ListenCount = models.PositiveIntegerField()
    album5ListenCount = models.PositiveIntegerField()
    album6ListenCount = models.PositiveIntegerField()
    album7ListenCount = models.PositiveIntegerField()
    album8ListenCount = models.PositiveIntegerField()
    album9ListenCount = models.PositiveIntegerField()
    album10ListenCount = models.PositiveIntegerField()

    album1PiracyCount = models.PositiveIntegerField()
    album2PiracyCount = models.PositiveIntegerField()
    album3PiracyCount = models.PositiveIntegerField()
    album4PiracyCount = models.PositiveIntegerField()
    album5PiracyCount = models.PositiveIntegerField()
    album6PiracyCount = models.PositiveIntegerField()
    album7PiracyCount = models.PositiveIntegerField()
    album8PiracyCount = models.PositiveIntegerField()
    album9PiracyCount = models.PositiveIntegerField()
    album10PiracyCount = models.PositiveIntegerField()

    subPurchaseCount = models.PositiveIntegerField()

    def get_num_bought(self):
        numB = 0
        numB += self.album1BuyCount
        numB += self.album2BuyCount
        numB += self.album3BuyCount
        numB += self.album4BuyCount
        numB += self.album5BuyCount
        numB += self.album6BuyCount
        numB += self.album7BuyCount
        numB += self.album8BuyCount
        numB += self.album9BuyCount
        numB += self.album10BuyCount
        return numB

    def get_num_pirate(self):
        numP = 0
        numP += self.album1PiracyCount
        numP += self.album2PiracyCount
        numP += self.album3PiracyCount
        numP += self.album4PiracyCount
        numP += self.album5PiracyCount
        numP += self.album6PiracyCount
        numP += self.album7PiracyCount
        numP += self.album8PiracyCount
        numP += self.album9PiracyCount
        numP += self.album10PiracyCount
        return numP

    def get_num_listen(self):
        numL = 0
        numL += self.album1ListenCount
        numL += self.album2ListenCount
        numL += self.album3ListenCount
        numL += self.album4ListenCount
        numL += self.album5ListenCount
        numL += self.album6ListenCount
        numL += self.album7ListenCount
        numL += self.album8ListenCount
        numL += self.album9ListenCount
        numL += self.album10ListenCount
        return numL

    def role(self):
        # you can make this depend of self.id_in_group
        if self.id_in_group == 1:
            return 'producer'
        if self.id_in_group == 2:
            return 'producer2'
        if self.id_in_group == 3:
            return 'consumer'
Example #25
0
class Subsession(BaseSubsession):

    multi_uno = models.DecimalField(max_digits=3, decimal_places=2)
    multi_dos = models.DecimalField(max_digits=3, decimal_places=2)
    multi_tres = models.DecimalField(max_digits=3, decimal_places=2)
    multi_cuatro = models.DecimalField(max_digits=3, decimal_places=2)
    multi_cinco = models.DecimalField(max_digits=3, decimal_places=2)

    rank_uno = models.DecimalField(max_digits=2, decimal_places=0)
    rank_dos = models.DecimalField(max_digits=2, decimal_places=0)
    rank_tres = models.DecimalField(max_digits=2, decimal_places=0)
    rank_cuatro = models.DecimalField(max_digits=2, decimal_places=0)
    rank_cinco = models.DecimalField(max_digits=2, decimal_places=0)

    rank_p_1 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_2 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_3 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_4 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_5 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_6 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_7 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_8 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_9 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_10 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_11 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_12 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_13 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_14 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_15 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_16 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_17 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_18 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_19 = models.DecimalField(max_digits=2, decimal_places=0)
    rank_p_20 = models.DecimalField(max_digits=2, decimal_places=0)

    posit_1 = models.PositiveIntegerField()
    posit_2 = models.PositiveIntegerField()
    posit_3 = models.PositiveIntegerField()
    posit_4 = models.PositiveIntegerField()
    posit_5 = models.PositiveIntegerField()
    posit_6 = models.PositiveIntegerField()
    posit_7 = models.PositiveIntegerField()
    posit_8 = models.PositiveIntegerField()
    posit_9 = models.PositiveIntegerField()
    posit_10 = models.PositiveIntegerField()
    posit_11 = models.PositiveIntegerField()
    posit_12 = models.PositiveIntegerField()
    posit_13 = models.PositiveIntegerField()
    posit_14 = models.PositiveIntegerField()
    posit_15 = models.PositiveIntegerField()
    posit_16 = models.PositiveIntegerField()
    posit_17 = models.PositiveIntegerField()
    posit_18 = models.PositiveIntegerField()
    posit_19 = models.PositiveIntegerField()
    posit_20 = models.PositiveIntegerField()

    max_pay = models.DecimalField(max_digits=3, decimal_places=1)
    min_pay = models.DecimalField(max_digits=3, decimal_places=1)

    max_fund = models.DecimalField(max_digits=3, decimal_places=1)
    min_fund = models.DecimalField(max_digits=3, decimal_places=1)

    def before_session_starts(self):
        if self.round_number == 1:
            players = self.get_players()
            random.shuffle(players)

            group_matrix = []

            ppg = Constants.players_per_group
            for i in range(0, len(players), ppg):
                group_matrix.append(players[i:i+ppg])
            self.set_groups(group_matrix)

        if self.round_number > 1:
            self.group_like_round(1)

    def set_ranking_g(self):
        self.max_fund = max([(Constants.endowment*Constants.players_per_group-p.total_extraction) for p in self.get_groups()])
        self.min_fund = min([(Constants.endowment*Constants.players_per_group-p.total_extraction) for p in self.get_groups()])
        vector_group = [(50-p.total_payment) for p in self.get_groups()]
        vector_ranked_g = ranking.rankdata(vector_group)
        coefficients = [1.10 - (a-1)*(0.05) for a in vector_ranked_g]
        self.multi_uno = coefficients[0]
        self.multi_dos = coefficients[1]
        self.multi_tres = coefficients[2]
        self.multi_cuatro = coefficients[3]
        self.multi_cinco = coefficients[4]
        zeq = sorted (vector_group)
        indez = [zeq.index(v) for v in vector_group]
        vector_indez = [w + 1 for w in indez]
        self.rank_uno = vector_indez[0]
        self.rank_dos = vector_indez[1]
        self.rank_tres = vector_indez[2]
        self.rank_cuatro = vector_indez[3]
        self.rank_cinco = vector_indez[4]
        for p in self.get_players():
            a1 = float(p.aux_2_1)
            a2 = float(p.aux_2_2)
            a3 = float(p.aux_2_3)
            a4 = float(p.aux_2_4)
            a5 = float(p.aux_2_5)
            p.payoff = p.payoff*self.multi_uno*p.aux_2_1 + p.payoff*self.multi_dos*p.aux_2_2 + p.payoff*self.multi_tres*p.aux_2_3 + + p.payoff*self.multi_cuatro*p.aux_2_4 + p.payoff*self.multi_cinco*p.aux_2_5
            p.gp_ranking = self.rank_uno*a1 + self.rank_dos*a2 + self.rank_tres*a3 + self.rank_cuatro*a4 + self.rank_cinco*a5
        self.max_pay = max([p.payoff for p in self.get_players()])
        self.min_pay = min([p.payoff for p in self.get_players()])
        vector_players = [(30-p.payoff) for p in self.get_players()]
        vector_positions = [p.participant_id for p in self.get_players()]
        seq = sorted(vector_players)
        index = [seq.index(v) for v in vector_players]
        vector_ranked_p = [w + 1 for w in index]
        self.rank_p_1 = vector_ranked_p[0]
        self.rank_p_2 = vector_ranked_p[1]
        self.rank_p_3 = vector_ranked_p[2]
        self.rank_p_4 = vector_ranked_p[3]
        self.rank_p_5 = vector_ranked_p[4]
        self.rank_p_6 = vector_ranked_p[5]
        self.rank_p_7 = vector_ranked_p[6]
        self.rank_p_8 = vector_ranked_p[7]
        self.rank_p_9 = vector_ranked_p[8]
        self.rank_p_10 = vector_ranked_p[9]
        self.rank_p_11 = vector_ranked_p[10]
        self.rank_p_12 = vector_ranked_p[11]
        self.rank_p_13 = vector_ranked_p[12]
        self.rank_p_14 = vector_ranked_p[13]
        self.rank_p_15 = vector_ranked_p[14]
        self.rank_p_16 = vector_ranked_p[15]
        self.rank_p_17 = vector_ranked_p[16]
        self.rank_p_18 = vector_ranked_p[17]
        self.rank_p_19 = vector_ranked_p[18]
        self.rank_p_20 = vector_ranked_p[19]
        self.posit_1 = vector_positions[0]
        self.posit_2 = vector_positions[1]
        self.posit_3 = vector_positions[2]
        self.posit_4 = vector_positions[3]
        self.posit_5 = vector_positions[4]
        self.posit_6 = vector_positions[5]
        self.posit_7 = vector_positions[6]
        self.posit_8 = vector_positions[7]
        self.posit_9 = vector_positions[8]
        self.posit_10 = vector_positions[9]
        self.posit_11 = vector_positions[10]
        self.posit_12 = vector_positions[11]
        self.posit_13 = vector_positions[12]
        self.posit_14 = vector_positions[13]
        self.posit_15 = vector_positions[14]
        self.posit_16 = vector_positions[15]
        self.posit_17 = vector_positions[16]
        self.posit_18 = vector_positions[17]
        self.posit_19 = vector_positions[18]
        self.posit_20 = vector_positions[19]
Example #26
0
class Player(BasePlayer):

    q2_communication_surprised = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_communication_satisfied = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_communication_upset = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_how_did_you_talk_about_the_cleaning = models.CharField(
        max_length=255,  widget=widgets.RadioSelect(),
        choices=["The group created strict rules when to clean.",
                 "More or less rules when to clean.",
                 "Several cleaning possibilities were mentioned without staying with one.",
                 "Without cleaning possibilites given by the group members, I found myself easier doing it next time better.",
                 "Cleaning behaviors were mentioned without helping me judge how to improve next time.",
                 "The issure 'Toilet cleaning' or behavior in game wasn't mentioned at all."])

    q2_recomendation_for_actions = models.TextField()
    q2_communication_helped_positive_and_negative = models.TextField()

    q2_opinion_recomendation_everyone = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_opinion_recomendation_fair = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_opinion_recomendation_max_resources = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_opinion_recomendation_understandable = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_pressure_behaving_like_settled_rules = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_would_it_disturb_you_behaving_differently = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_is_there_any_kind_of_social_pressure = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_i_will_follwow_the_recommendation_entirely = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_i_will_follwow_the_recommendation_maximizing_my_advantage = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_others_follow_the_recommendations_entirely = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_others_follow_the_recommendations_try_to_max_their_advantage = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))

    q2_how_much_cooperate_because_communication = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_team_spirit = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_importance_of_your_image = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_importance_maximum_resources_to_everyone = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_importance_other_members_trust_in_you = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_importance_maximum_resources_to_everyone_not_you = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_how_much_trust_do_you_have_into_other_members = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_how_much_do_you_like_the_other_team_members = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_how_good_you_understand_solving_problem_max_resources = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_afterc_others_understand_solving_problem_great_max_resources = models.PositiveIntegerField(min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q2_which_strategy_would_you_follow_and_why = models.TextField()
Example #27
0
class Player(BasePlayer):

    quiz_01 = models.PositiveIntegerField(verbose_name='Your earnings:',
                                          min=0,
                                          max=999,
                                          initial=None,
                                          doc='quiz answer')

    quiz_02 = models.PositiveIntegerField(verbose_name='Your earnings:',
                                          min=0,
                                          max=999,
                                          initial=None,
                                          doc='quiz answer')

    quiz_03 = models.PositiveIntegerField(verbose_name='Your earnings:',
                                          min=0,
                                          max=999,
                                          initial=None,
                                          doc='quiz answer')

    ret_score = models.IntegerField(
        doc=
        "player's real effort task score - correct number of RETs mapped to a number."
    )

    vcm_score = models.IntegerField(doc="score player received in vcm round.")

    vcm_ge_percent = models.IntegerField(
        doc="player's average group exchange contribution in vcm rounds")

    role = models.CharField(doc="player role, A or F")

    def set_payoff(self, A_GE, A_Endow, F_GE, F_Endow):
        """calc player payoffs"""

        for p in self.group.get_players():
            if p.participant.vars['Role'] == 'F':
                total_op_individual_exchange = A_Endow - A_GE
                total_op_group_exchange = A_GE

                p.round_payoff = (F_Endow - F_GE) - (
                    1 / 2 * total_op_individual_exchange) + (
                        1 / 2 * F_GE) + Constants.automatic_earnings

            elif p.participant.vars['Role'] == 'A':
                total_op_individual_exchange = F_Endow - F_GE
                total_op_group_exchange = F_GE

                p.round_payoff = (A_Endow - A_GE) - (
                    1 / 2 * total_op_individual_exchange) + (
                        1 / 2 * A_GE) + Constants.automatic_earnings

    round_payoff = models.FloatField(doc="this player's earnings this round")

    A_stage1 = models.CharField(
        initial=None,
        choices=['A1', 'A2'],
        verbose_name='Make your decision',
        doc='Player A decision between A1 and A2, Stage 1',
        widget=widgets.RadioSelect())

    F_stage2 = models.CharField(
        initial=None,
        choices=['F1', 'F2'],
        verbose_name='Make your decision',
        doc='Player F decision between F1 and F2, Stage 2',
        widget=widgets.RadioSelect())

    A_stage3 = models.CharField(
        initial=None,
        choices=['A3', 'A4'],
        verbose_name='Make your decision',
        doc='Player A decision between A3 and A4, Stage 3',
        widget=widgets.RadioSelect())

    Nature = models.CharField(
        doc="""'Should nature move, this is nature's move""",
        widget=widgets.RadioSelect())

    terminal_choice = models.CharField(
        doc="""'the terminal node reached by A and F""",
        widget=widgets.RadioSelect())

    def set_terminal_node(self):
        """explicitly define terminal node reached by A and F in this group"""
        A_tn = None
        F_tn = None
        N_tn = None  #nature
        for p in self.group.get_players():
            if p.participant.vars['Role'] == 'A':
                if p.A_stage1 == "A1": A_tn = "A1"
                elif p.A_stage3 == "A3": A_tn = "A3"
                elif p.A_stage3 == "A4": A_tn = "A4"
            elif p.participant.vars['Role'] == 'F':
                if p.F_stage2 == 'F1': F_tn = 'F1'
                elif p.F_stage2 == 'F2': F_tn = 'F2'

            if p.Nature == 'N1': N_tn = 'N1'
            elif p.Nature == 'N2': N_tn = 'N2'

        TN = None
        if A_tn == "A1": TN = A_tn
        elif F_tn == 'F1': TN = F_tn
        elif A_tn == "A3": TN = A_tn
        else: TN = N_tn

        for p in self.group.get_players():
            p.terminal_choice = TN
Example #28
0
class Player(BasePlayer):

    tails = models.PositiveIntegerField(verbose_name="Number of tails", max=4)

    def set_payoff(self):
        self.payoff = self.tails * Constants.euros_per_toss
Example #29
0
class Player(BasePlayer):

    # create a column for each constant
    num_rounds = models.PositiveIntegerField()
    treatment = models.BooleanField()
    tax_rate = models.FloatField()

    # give each player a letter for identification (Important for Feedback)
    def role(self):
        return string.ascii_uppercase[self.id_in_group - 1]

    # Beliefs Variables

    investment_belief_0 = models.FloatField()
    investment_belief_1 = models.FloatField()

    production_belief_0 = models.PositiveIntegerField()
    production_belief_1 = models.PositiveIntegerField()

    # Contest Variables
    is_winner = models.BooleanField(
        initial=False,
        doc=
        """Indicates whether the player is the winner of the Tullock Contest"""
    )

    prob = models.FloatField(
        doc="Probabilities of getting the Prize in the next round. Tullock")

    prob_percent = models.FloatField(
        doc=
        "Probabilities in percent of getting the prize in next round. Tullock")
    investment_amount = models.FloatField(default=0,
                                          doc="Amount bidden by the player")

    # Real Effort Task variables
    # Number of Tasks Solved
    production_strings = models.FloatField(default=0)
    income_in_switch = models.FloatField(default=0)
    total_production = models.FloatField(
        default=0
    )  # the sum in tokens of earnings from string solving (gross) and switch

    # available income after solving RET
    income_strings_gross = models.FloatField(default=0)
    income_strings_after_tax = models.FloatField(default=0)
    income_after_redistribution = models.FloatField(default=0)
    net_income = models.FloatField(default=0)
    available_income = models.FloatField(
        default=0)  # what players are allowed to invest
    earnings = models.FloatField(
        default=0)  # what players keep after redistribution *and* investment
    taxation = models.FloatField(
        default=0)  # amount taxed for given participant

    # Variable is 1 when entering switch
    switch1 = models.PositiveIntegerField(
        default=0)  # word "switch" cannot be used as a variable in javascript

    switch_time = models.PositiveIntegerField(default=0)

    time_in_switch = models.PositiveIntegerField(default=0)

    additional_time = models.PositiveIntegerField(default=0)

    # correct to allow a variable number of tasks
    # for now, created with:
    # for i in range(10, 46):
    # print('t1{} = models.PositiveIntegerField(default=0)'.format(i))

    # def set_time_fields(self):
    #     for i in range(31):
    #         self.participant.vars['t1{}'.format(i)] = models.PositiveIntegerField(default=0)
    #     print(self.participant.vars)

    # Time Needed to Solve Task i in Round j with tjxi
    t101 = models.PositiveIntegerField(default=0)
    t102 = models.PositiveIntegerField(default=0)
    t103 = models.PositiveIntegerField(default=0)
    t104 = models.PositiveIntegerField(default=0)
    t105 = models.PositiveIntegerField(default=0)
    t106 = models.PositiveIntegerField(default=0)
    t107 = models.PositiveIntegerField(default=0)
    t108 = models.PositiveIntegerField(default=0)
    t109 = models.PositiveIntegerField(default=0)
    t110 = models.PositiveIntegerField(default=0)
    t111 = models.PositiveIntegerField(default=0)
    t112 = models.PositiveIntegerField(default=0)
    t113 = models.PositiveIntegerField(default=0)
    t114 = models.PositiveIntegerField(default=0)
    t115 = models.PositiveIntegerField(default=0)
    t116 = models.PositiveIntegerField(default=0)
    t117 = models.PositiveIntegerField(default=0)
    t118 = models.PositiveIntegerField(default=0)
    t119 = models.PositiveIntegerField(default=0)
    t120 = models.PositiveIntegerField(default=0)
    t121 = models.PositiveIntegerField(default=0)
    t122 = models.PositiveIntegerField(default=0)
    t123 = models.PositiveIntegerField(default=0)
    t124 = models.PositiveIntegerField(default=0)
    t125 = models.PositiveIntegerField(default=0)
    t126 = models.PositiveIntegerField(default=0)
    t127 = models.PositiveIntegerField(default=0)
    t128 = models.PositiveIntegerField(default=0)
    t129 = models.PositiveIntegerField(default=0)
    t130 = models.PositiveIntegerField(default=0)
    t131 = models.PositiveIntegerField(default=0)
    t132 = models.PositiveIntegerField(default=0)
    t133 = models.PositiveIntegerField(default=0)
    t134 = models.PositiveIntegerField(default=0)
    t135 = models.PositiveIntegerField(default=0)
    t136 = models.PositiveIntegerField(default=0)
    t137 = models.PositiveIntegerField(default=0)
    t138 = models.PositiveIntegerField(default=0)
    t139 = models.PositiveIntegerField(default=0)
    t140 = models.PositiveIntegerField(default=0)
    t141 = models.PositiveIntegerField(default=0)
    t142 = models.PositiveIntegerField(default=0)
    t143 = models.PositiveIntegerField(default=0)
    t144 = models.PositiveIntegerField(default=0)
    t145 = models.PositiveIntegerField(default=0)

    def set_switch(self):
        # Time at which switch was entered
        self.switch_time = self.switch1 * (
            self.additional_time + self.t101 + self.t102 + self.t103 +
            self.t104 + self.t105 + self.t106 + self.t107 + self.t108 +
            self.t109 + self.t110 + self.t111 + self.t112 + self.t113 +
            self.t114 + self.t115 + self.t116 + self.t117 + self.t118 +
            self.t119 + self.t120 + self.t121 + self.t122 + self.t123 +
            self.t124 + self.t125 + self.t126 + self.t127 + self.t128 +
            self.t129 + self.t130 + self.t131 + self.t132 + self.t133 +
            self.t134 + self.t135 + self.t136 + self.t137 + self.t138 +
            self.t139 + self.t140 + self.t141 + self.t142 + self.t143 +
            self.t144 + self.t145)

        # This variable determines the total time spent in switch
        self.time_in_switch = self.switch1 * (Constants.t - self.switch_time)

        # This variable determines the tokens per string received
        self.income_in_switch = self.time_in_switch / Constants.secondsper_token

        # This is the sum of strings + production in switch
        self.total_production = self.production_strings + self.income_in_switch
Example #30
0
class Player(BasePlayer):

    player_role = models.CharField(doc="player role, A or F")

    quiz_01 = models.PositiveIntegerField(verbose_name='Your earnings:',
                                          min=0,
                                          max=999,
                                          initial=None,
                                          doc='quiz answer')

    quiz_02 = models.PositiveIntegerField(verbose_name='Your earnings:',
                                          min=0,
                                          max=999,
                                          initial=None,
                                          doc='quiz answer')

    ret_score = models.IntegerField(
        doc=
        "player's real effort task score - correct number of RETs mapped to a number."
    )

    vcm_score = models.FloatField(doc="score player received in vcm round.")

    vcm_ge_percent = models.FloatField(
        doc="player's average group exchange contribution in vcm rounds")

    op_ret_scores = models.CharField(
        doc='this subjects opposing player ret scores from task 1.')

    op_ge_overallavg = models.CharField(
        doc=
        'this subjects opposing player overall average group contribution from vcm.'
    )

    round_base_points = models.FloatField(
        doc=
        ''' player's base score. if no adjustments are made to own or counterpart GE contributions, player will earn this '''
    )

    def set_payoff(self, A_GE, A_Endow, F_GE, F_Endow):
        """calc player payoffs"""
        ''' called inside group functions, eg A1A2_update '''

        op_GE = self.participant.vars['group_exchange_other2p']
        op_IE = self.participant.vars['individual_exchange_other2p']

        for p in self.group.get_players():
            if p.participant.vars['Role'] == 'F':

                total_op_individual_exchange = (A_Endow - A_GE) + sum(op_IE)
                total_op_group_exchange = A_GE + sum(op_GE)

                p.round_payoff = (F_Endow - F_GE) - (
                    1 / 2 * total_op_individual_exchange) + (
                        1 / 2 * F_GE) + Constants.automatic_earnings

                #for debugging and results screen
                p.postStage_self_individual_exchange = F_Endow - F_GE
                p.postStage_self_ge = F_GE
                p.postStage_op_individual_exchange = str([(A_Endow - A_GE)] +
                                                         op_IE)
                p.postStage_op_group_exchange = str([A_GE] + op_GE)
                p.postStage_round_points = p.round_payoff

            elif p.participant.vars['Role'] == 'A':
                total_op_individual_exchange = (F_Endow - F_GE) + sum(op_IE)
                total_op_group_exchange = F_GE + sum(op_GE)

                p.round_payoff = (A_Endow - A_GE) - (
                    1 / 2 * total_op_individual_exchange) + (
                        1 / 2 * A_GE) + Constants.automatic_earnings

                #for debugging and results screen
                p.postStage_self_individual_exchange = A_Endow - A_GE
                p.postStage_self_ge = A_GE
                p.postStage_op_individual_exchange = str([(F_Endow - F_GE)] +
                                                         op_IE)
                p.postStage_op_group_exchange = str([F_GE] + op_GE)
                p.postStage_round_points = p.round_payoff

    round_payoff = models.FloatField(doc="this player's earnings this round")

    A_stage1 = models.CharField(
        initial=None,
        choices=['A1', 'A2'],
        verbose_name='Make your decision',
        doc='Player A decision between A1 and A2, Stage 1',
        widget=widgets.RadioSelect())

    F_stage2 = models.CharField(
        initial=None,
        choices=['F1', 'F2'],
        verbose_name='Make your decision',
        doc='Player F decision between F1 and F2, Stage 2',
        widget=widgets.RadioSelect())

    A_stage3 = models.CharField(
        initial=None,
        choices=['A3', 'A4'],
        verbose_name='Make your decision',
        doc='Player A decision between A3 and A4, Stage 3',
        widget=widgets.RadioSelect())

    Nature = models.CharField(
        doc="""'Should nature move, this is nature's move""",
        widget=widgets.RadioSelect())

    terminal_choice = models.CharField(
        doc="""'the terminal node reached by A and F""",
        widget=widgets.RadioSelect())

    def set_terminal_node(self):
        """explicitly define terminal node reached by A and F in this group"""
        A_tn = None
        F_tn = None
        N_tn = None  #nature
        for p in self.group.get_players():
            p.player_role = p.participant.vars['Role']
            if p.participant.vars['Role'] == 'A':
                if p.A_stage1 == "A1": A_tn = "A1"
                elif p.A_stage3 == "A3": A_tn = "A3"
                elif p.A_stage3 == "A4": A_tn = "A4"
            elif p.participant.vars['Role'] == 'F':
                if p.F_stage2 == 'F1': F_tn = 'F1'
                elif p.F_stage2 == 'F2': F_tn = 'F2'

            if p.Nature == 'N1': N_tn = 'N1'
            elif p.Nature == 'N2': N_tn = 'N2'

        TN = None
        if A_tn == "A1": TN = A_tn
        elif F_tn == 'F1': TN = F_tn
        elif A_tn == "A3": TN = A_tn
        else: TN = N_tn

        for p in self.group.get_players():
            p.terminal_choice = TN

    postStage_self_individual_exchange = models.FloatField(
        doc='''"player's individual exchange contribution after stage game"''')

    postStage_self_ge = models.FloatField(
        doc='''"player's group exchange contribution after stage game"''')

    postStage_op_individual_exchange = models.CharField(
        doc=
        '''"player's three other countryparty player's individual after stage game"'''
    )

    postStage_op_group_exchange = models.CharField(
        doc=
        '''"player's three other countryparty player's group exchange after stage game"'''
    )

    postStage_round_points = models.FloatField(
        doc='''"player's final score from stage game"''')