Example #1
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 #2
0
class Player(BasePlayer):

    question_1 = models.CharField(
        choices=[
            ('1.0', '1.0'),
            ('4.0', '4.0'),
            ('6.5', '6.5'),
            ('7.2', '7.2'),
            ('12.0', '12.0'),
        ]
    )

    question_2 = models.CharField(
        choices=[
            ('1.0', '1.0'),
            ('4.0', '4.0'),
            ('6.5', '6.5'),
            ('7.2', '7.2'),
            ('12.0', '12.0'),
        ]
    )

    def question_correct_1(self):
        return self.question_1 == Constants.question_correct_1

    def question_correct_2(self):
        return self.question_2 == Constants.question_correct_2
Example #3
0
class Player(BasePlayer):

    decision1 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision2 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision3 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision4 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision5 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision6 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision7 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision8 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision9 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())
    decision10 = models.CharField(max_length=50, choices=sorted(Constants.options), widget=widgets.RadioSelectHorizontal())

    selected_decision = models.IntegerField()

    def get_decision(self):
        option = getattr(self, "decision{}".format(self.selected_decision))
        return option, Constants.options[option], Constants.decisions[self.selected_decision-1]

    def set_payoff(self):
        self.selected_decision = random.randint(1, 10)
        option, option_desc, decision = self.get_decision()
        self.payoff = decision[option]

    def fields_iterator(self):
        for idx in range(1, 11):
            yield getattr(self, "decision{}".format(idx))
Example #4
0
class Player(BasePlayer):
    ethnic_in = models.CharField(
        initial=None,
        choices=[Constants.ethnicity_dai, Constants.ethnicity_han],
        widget=widgets.RadioSelect())
    # Input variable to ask the participants' religion
    religion_in = models.CharField(initial=None,
                                   choices=[
                                       Constants.religion_buddhist,
                                       Constants.religion_christian,
                                       Constants.religion_none
                                   ],
                                   widget=widgets.RadioSelect())

    # Function defined to get the ethnicity of the other participant in the group in the trust game
    def other_eth(self):
        return self.get_others_in_group()[0].participant.vars['ethnic']

    # Function defined to get the religion of the other participant in the group in the trust game
    def other_relig(self):
        return self.get_others_in_group()[0].participant.vars['religion']

    def get_ethnicity(self):
        return self.in_all_rounds()[0].participant.vars['ethnic']

    def get_religion(self):
        return self.in_all_rounds()[0].participant.vars['religion']

    payoff_block1 = models.CurrencyField()
Example #5
0
class Player(BasePlayer):
    contribution = models.CurrencyField(choices=currency_range(0, Constants.endowment, 1),)

    # payoff_s1 is the payment each round before the punishment stage
    payoff_s1 = models.CurrencyField()
    # prepayoff is the payment each round after the punishment stage
    prepayoff = models.CurrencyField()
    # payoff_block2 is the cumulative payoff of all the rounds in the public goods game
    payoff_block2 = models.CurrencyField()

    # Allocation of punishment points to each subject
    punish_p1 = models.CurrencyField(min=0, max=Constants.endowment, null = True)
    punish_p2 = models.CurrencyField(min=0, max=Constants.endowment, null = True)
    punish_p3 = models.CurrencyField(min=0, max=Constants.endowment, null = True)
    punish_p4 = models.CurrencyField(min=0, max=Constants.endowment, null = True)

    # Variables to store the responses to the understanding questions
    question_pg1 = models.CurrencyField()
    question_pg2 = models.CurrencyField()

    ethnicity = models.CharField()
    religion = models.CharField()

    def get_ethnicity(self):
        return self.in_all_rounds()[0].participant.vars['ethnic']

    def get_religion(self):
        return self.in_all_rounds()[0].participant.vars['religion']
Example #6
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=["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"])

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

   # 2nd Form variables
   dynamicKnowledge = models.CharField(
       choices=["Complètement d'accord", "D'accord", "Ni d'accord,n 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,n 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,n 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,n 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,n ni pas d'accord",
                "pas d'accord", "Complètement pas d'accord", "Pas dans mon traitement"])

   ##-------------------------------
   ## 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 #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):
    decision_choices = (
            ("Coin 1", "Coin 1: KSH 80 if heads and KSH 80 if tails"),
            ("Coin 2", "Coin 2: KSH 70 if heads and KSH 110 if tails"),
            ("Coin 3", "Coin 3: KSH 60 if heads and KSH 140 if tails"),
            ("Coin 4", "Coin 4: KSH 50 if heads and KSH 170 if tails"),
            ("Coin 5", "Coin 5: KSH 40 if heads and KSH 200 if tails"),
            ("Coin 6", "Coin 6: KSH 30 if heads and KSH 210 if tails"),
        )
    decision = models.CharField(choices=decision_choices, widget=widgets.RadioSelect())
    random_coin_toss = models.CharField()
Example #9
0
class Player(BasePlayer):
    decision_choices = (
        ("Coin 1", "Coin 1: 0 Tokens if heads and 2880 Tokens if tails"),
        ("Coin 2", "Coin 2: 240 Tokens if heads and 2400 Tokens if tails"),
        ("Coin 3", "Coin 3: 480 Tokens if heads and 1920 Tokens if tails"),
        ("Coin 4", "Coin 4: 720 Tokens if heads and 1440 Tokens if tails"),
        ("Coin 5", "Coin 5: 840 Tokens if heads and 1200 Tokens if tails"),
        ("Coin 6", "Coin 6: 960 Tokens if heads and 960 Tokens if tails"),
        ("Coin 7", "Coin 6: 1080 Tokens if heads and 720 Tokens if tails"),
    )
    decision = models.CharField(choices=decision_choices,
                                widget=widgets.RadioSelect())
    random_coin_toss = models.CharField()
Example #10
0
class Player(BasePlayer):

    riskchoice1 = models.CharField(max_length=50,
                                   choices=sorted(Constants.loteries1),
                                   widget=widgets.RadioSelectHorizontal())
    riskchoice2 = models.CharField(max_length=50,
                                   choices=sorted(Constants.loteries2),
                                   widget=widgets.RadioSelectHorizontal())
    riskchoice3 = models.CharField(max_length=50,
                                   choices=sorted(Constants.loteries3),
                                   widget=widgets.RadioSelectHorizontal())
    riskchoice4 = models.CharField(max_length=50,
                                   choices=sorted(Constants.loteries4),
                                   widget=widgets.RadioSelectHorizontal())

    selected_puzzle = models.IntegerField(choices=[1, 2, 3, 4])
    wining_range = models.JSONField(default=None)
    roll = models.IntegerField()

    def get_wining_range(self):
        if not self.wining_range:
            if self.selected_puzzle in (1, 2):
                self.wining_range = [1, 5]
            elif self.selected_puzzle in (3, 4):
                self.wining_range = random.choice(Constants.random_ranges)
        return self.wining_range

    def get_selected_puzzle(self):
        initial_payoff = 0 if self.selected_puzzle in (1, 3) else 10
        if self.selected_puzzle == 1:
            return 1, self.riskchoice1, Constants.loteries1, self.get_wining_range(
            ), initial_payoff
        if self.selected_puzzle == 2:
            return 2, self.riskchoice2, Constants.loteries2, self.get_wining_range(
            ), initial_payoff
        if self.selected_puzzle == 3:
            return 3, self.riskchoice3, Constants.loteries3, self.get_wining_range(
            ), initial_payoff
        return 4, self.riskchoice4, Constants.loteries4, self.get_wining_range(
        ), initial_payoff

    def set_payoff(self):
        self.selected_puzzle = random.randint(1, 4)
        sp, choice, loteries, wrange, initial_payoff = self.get_selected_puzzle(
        )
        lotery = loteries[choice]
        self.roll = random.randint(1, 10)
        if self.roll <= wrange[-1]:
            self.payoff = initial_payoff + lotery[0]
        else:
            self.payoff = initial_payoff + lotery[1]
Example #11
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 #12
0
class Player(BasePlayer):

    mpcr = models.FloatField(doc='''marginal per capital reutrn ''')

    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_text = models.CharField(doc="quiz question")
    quiz_sol = models.IntegerField(doc="solution")
    quiz_user_answer = models.FloatField(verbose_name='Your answer:',
                                         min=0,
                                         max=999,
                                         initial=None,
                                         doc='quiz answer')
    quiz_sol_text = models.CharField(doc="solution text")
Example #13
0
class Player(BasePlayer):
    contribution = models.CurrencyField(choices=currency_range(0, Constants.endowment, 1),)

    # prepayoff is the payment each round after the punishment stage
    prepayoff = models.CurrencyField()
    # payoff_block2 is the cumulative payoff of all the rounds in the public goods game
    payoff_block2 = models.CurrencyField()

    ethnicity = models.CharField()
    religion = models.CharField()

    def get_ethnicity(self):
        return self.in_all_rounds()[0].participant.vars['ethnic']

    def get_religion(self):
        return self.in_all_rounds()[0].participant.vars['religion']
Example #14
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 #15
0
class Player(otree.models.BasePlayer):

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

    training_question_1_husband = models.CurrencyField(
        bounds=[0, Constants.training_1_maximum_offered_points])

    training_question_1_wife = models.CurrencyField(
        bounds=[0, Constants.training_1_maximum_offered_points])

    decision = models.CharField(choices=['Football', 'Opera'],
                                doc="""Either football or the opera""",
                                widget=widgets.RadioSelect())

    def is_training_question_1_husband_correct(self):
        return (self.training_question_1_husband ==
                Constants.training_1_husband_correct)

    def is_training_question_1_wife_correct(self):
        return (
            self.training_question_1_wife == Constants.training_1_wife_correct)

    def other_player(self):
        """Returns other player in group"""
        return self.get_others_in_group()[0]

    def role(self):
        if self.id_in_group == 1:
            return 'husband'
        if self.id_in_group == 2:
            return 'wife'
Example #16
0
class Group(BaseGroup):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    # </built-in>

    type = models.CharField(choices=['SIM', 'SEQ'],
                            doc="""今回のゲームのタイプは""",
                            widget=widgets.RadioSelect())

    def place(self):
        place = [[0, 0], [0, 0]]
        players = self.get_players()
        i = 0
        for p in players:
            place[i][0] = p.x_place
            place[i][1] = p.y_place
            i += 1
        return place

    def place2(self):
        o_place = [0, 0]
        p = self.get_player_by_id(1)
        o_place[0] = p.x_place
        o_place[1] = p.y_place
        return o_place

    def game_type(self):
        self.type = self.in_previous_rounds()[0].type

    def set_payoffs(self):
        p1 = self.get_player_by_id(1)
        p2 = self.get_player_by_id(2)
        Fx = 0.0
        for i in range(50):
            for j in range(20):
                mytotalcomsumer = (p1.x_place - i)**2 + (p1.y_place - j)**2
                othertotalcomsumer = (p2.x_place - i)**2 + (p2.y_place - j)**2
                if mytotalcomsumer < othertotalcomsumer:
                    Fx += 1.0
                elif mytotalcomsumer == othertotalcomsumer:
                    Fx += 0.5
        mycomsumer = 0.0
        othercomsumer = 0.0
        for i in range(50):
            for j in range(20):
                mytotalprice = 100 + (p1.x_place - i)**2 + (p1.y_place - j)**2
                othertotalprice = ((1000 - Fx) / Fx * 100) + (
                    p2.x_place - i)**2 + (p2.y_place - j)**2
                if mytotalprice < othertotalprice:
                    mycomsumer += 1.0
                elif mytotalprice == othertotalprice:
                    mycomsumer += 0.5
                    othercomsumer += 0.5
                else:
                    othercomsumer += 1.0
        p1.payoff = 100 * mycomsumer
        p2.payoff = ((1000 - Fx) / Fx * 100) * othercomsumer
Example #17
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 #18
0
class Player(BasePlayer):

    ethnic = models.CharField(
    )  # Variable to store the participants' ethnicity
    religion = models.CharField(
    )  # Variable to store the participants' religion
    # Input variable to ask the participants' ethnicity
    ethnic_in = models.CharField(
        initial=None,
        choices=[Constants.ethnicity_dai, Constants.ethnicity_han],
        widget=widgets.RadioSelect())
    # Input variable to ask the participants' religion
    religion_in = models.CharField(initial=None,
                                   choices=[
                                       Constants.religion_buddhist,
                                       Constants.religion_christian,
                                       Constants.religion_none
                                   ],
                                   widget=widgets.RadioSelect())

    # Function defined to get the ethnicity of the other participant in the group in the trust game
    def other_eth(self):
        return self.get_others_in_group()[0].participant.vars['ethnic']

    # Function defined to get the religion of the other participant in the group in the trust game
    def other_relig(self):
        return self.get_others_in_group()[0].participant.vars['religion']

    def get_ethnicity(self):
        return self.in_all_rounds()[0].participant.vars['ethnic']

    def get_religion(self):
        return self.in_all_rounds()[0].participant.vars['religion']

    # Prepayoff is the payment of each round
    prepayoff = models.CurrencyField()
    # Payoff_block1 is the payment of the round selected to be paid
    # Block 1 refers to the trust game
    # Block 2 refers to the public goods game with punishment
    payoff_block1 = models.CurrencyField()

    # Variables to store the responses to the understanding questions
    question_trustA = models.CurrencyField()
    question_trustB = models.CurrencyField()
Example #19
0
class Group(BaseGroup):
    # <built-in>
    subsession = models.ForeignKey(Subsession)
    # </built-in>
    networktype = models.CharField()

    def network_type(self):
        network_type_group = ['Blue network', 'Red network', 'Brown network']
        network_type = random.choice(network_type_group, p=Constants.weight)
        return network_type

    def network(self):
        network_type = str(self.network_tp)
        if network_type == 'Blue network':
            network = {
                'A': ['B'],
                'B': ['A', 'C', 'E'],
                'C': ['B', 'D', 'E'],
                'D': ['C', 'E'],
                'E': ['B', 'C', 'D']
            }
        elif network_type == 'Red network':
            network = {
                'A': ['B'],
                'B': ['A', 'C'],
                'C': ['B', 'D', 'E'],
                'D': ['C', 'E'],
                'E': ['C', 'D']
            }
        else:
            network = {
                'A': ['B'],
                'B': ['A', 'C', 'E'],
                'C': ['B', 'D'],
                'D': ['C', 'E'],
                'E': ['B', 'D']
            }
        network_group = [network_type, network]
        return network_group

    def set_payoffs(self):
        network_group = self.network_histry[self.subsession.round_number - 1]
        self.network_type = network_group[0]
        self.network = network_group[1]
        player = [0 for i in range(Constants.players_per_group)]
        active = [0 for i in range(Constants.players_per_group)]
        i = 0
        for role in Constants.places:
            player[i] = self.get_player_by_role(role)
            assign_nghb = self.network[role]
            for other_role in assign_nghb:
                if self.get_player_by_role(other_role).decision == 'ACTIVE':
                    active[i] += 1
            player[i].payoff = float(100 * active[i] / 3)
            player[i].num_active = active[i]
            i += 1
Example #20
0
class Player(BasePlayer):

    ethnic_in = models.CharField(initial=None,
                                 choices=['Dai', 'Han'],
                                 widget=widgets.RadioSelect())
    religion_in = models.CharField(
        initial=None,
        choices=['Buddhist', 'Christian', 'None (atheist)'],
        widget=widgets.RadioSelect())

    def other_eth(self):
        return self.get_others_in_group()[0].participant.vars['ethnic']

    def other_relig(self):
        return self.get_others_in_group()[0].participant.vars['religion']

    prepayoff = models.CurrencyField()

    question_trustA = models.CurrencyField()
    question_trustB = models.CurrencyField()
Example #21
0
class Player(BasePlayer):

    question = models.CharField(choices=[
        ('3.0', '3.0'),
        ('6.0', '6.0'),
        ('6.5', '6.5'),
        ('9.5', '9.5'),
        ('13.0', '13.0'),
    ])

    def question_correct(self):
        return self.question == Constants.question_correct
Example #22
0
class Group(BaseGroup):
    total_contribution = models.CurrencyField()
    individual_share = models.CurrencyField()
    group_advice = models.CharField(choices=(Constants.c_advice[0],
                                             Constants.c_advice[1]))

    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
Example #23
0
class Player(BasePlayer):
    firstname = models.CharField(initial=None,
                                 verbose_name='Prénom')
    surname = models.CharField(initial=None,
                               verbose_name='Nom')
    sex = models.CharField(initial=None,
                           choices=[('Masculin'), ('Féminin')],
                           verbose_name='Sexe',
                           widget=widgets.RadioSelectHorizontal())
    school = models.CharField(initial=None,
                              verbose_name='Etablissement')


    def save_data_in_dictionary(self):
        self.participant.vars['firstname'] = self.firstname
        self.participant.vars['surname'] = self.surname
        self.participant.vars['sex'] = self.sex
        self.participant.vars['school'] = self.school


    def role(self):
        return {1: 'Experimenter', 2: 'Player'}[self.id_in_group]
Example #24
0
class Player(BasePlayer):
    penny_side = models.CharField(
    choices=['Heads','Tails'],
    widget=widgets.RadioSelect()
    )
    
    is_winner = models.BooleanField()
    
    def role(self):
        if self.id_in_group == 1:
            return 'Mismatcher'
        if self.id_in_group == 2:
            return 'Matcher'
Example #25
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 #26
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 #27
0
class Player(BasePlayer):

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

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

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

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

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

    q3_second_game_different_and_is_it_because_of_the_communication = models.TextField(
    )
    q3_the_best_strategy_to_optimize_everyones_resources = models.TextField()

    q3_gender = models.CharField(choices=["Male", "Female"],
                                 widget=widgets.RadioSelectHorizontal())
    q3_birthday = models.DateField(widget=widgets.Input())

    q3_main_subject_in_university = models.TextField()
    q3_already_take_part_in_a_problem_solving = models.BooleanField(
        widget=widgets.RadioSelectHorizontal())

    q3_experiment_itself_was_interessting = models.PositiveIntegerField(
        min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q3_were_you_personally_engaged_achieving_good_results = models.PositiveIntegerField(
        min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q3_dificult_understanding_and_solving_the_problem = models.PositiveIntegerField(
        min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q3_was_it_obvious_what_to_do = models.PositiveIntegerField(
        min=1, max=5, widget=widgets.SliderInput(show_value=False))
    q3_short_feedback = models.TextField()
Example #28
0
class Player(BasePlayer):

    skewchoice1 = models.CharField(max_length=50,
                                   choices=sorted(Constants.skewchoices1),
                                   widget=widgets.RadioSelectHorizontal())
    skewchoice2 = models.CharField(max_length=50,
                                   choices=sorted(Constants.skewchoices2),
                                   widget=widgets.RadioSelectHorizontal(),
                                   null=True,
                                   blank=True)
    skewchoice3 = models.CharField(max_length=50,
                                   choices=sorted(Constants.skewchoices3),
                                   widget=widgets.RadioSelectHorizontal(),
                                   null=True,
                                   blank=True)

    winning_choice = models.IntegerField()

    def selected_skew(self):
        if self.skewchoice3:
            return 3, self.skewchoice3, Constants.skewchoices3[
                self.skewchoice3]
        if self.skewchoice2:
            return 2, self.skewchoice2, Constants.skewchoices2[
                self.skewchoice2]
        return 1, self.skewchoice1, Constants.skewchoices1[self.skewchoice1]

    def set_payoff(self):
        snum, soption, choices = self.selected_skew()

        sample = []
        for idx, e in enumerate(Constants.pie_data):
            sample.extend([idx] * e)

        self.winning_choice = random.choice(sample)
        self.payoff = choices[self.winning_choice]
Example #29
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 #30
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?"
    )