예제 #1
0
class Player(BasePlayer):

    # whether bomb is collected or not
    # store as integer because it's easier for interop with JS
    bomb = models.IntegerField()

    # location of bomb
    bomb_row = models.PositiveIntegerField()
    bomb_col = models.PositiveIntegerField()

    # number of collected boxes
    boxes_collected = models.IntegerField()

    # --- set round results and player's payoff
    # ------------------------------------------------------------------------------------------------------------------
    pay_this_round = models.BooleanField()
    round_result = models.CurrencyField()

    gender = models.IntegerField(choices=[
        [0, 'Male'],
        [1, 'Female'],
    ])

    treatment = models.StringField()

    strategy = models.TextField(blank=True)
    feedback = models.TextField(blank=True)

    age = models.IntegerField()
    amazon_turk_id = models.StringField()

    def set_payoff(self):

        # determine round_result as (potential) payoff per round
        if self.bomb:
            self.round_result = c(0)
        else:
            self.round_result = self.boxes_collected * Constants.box_value

        # set payoffs if <random_payoff = True> to round_result of randomly chosen round
        # randomly determine round to pay on player level
        if self.subsession.round_number == 1:
            self.participant.vars['round_to_pay'] = random.randint(
                1, Constants.num_rounds)

        if Constants.random_payoff:
            if self.subsession.round_number == self.participant.vars[
                    'round_to_pay']:
                self.pay_this_round = True
                self.payoff = self.round_result
            else:
                self.pay_this_round = False
                self.payoff = c(0)

        # set payoffs to round_result if <random_payoff = False>
        else:
            self.payoff = self.round_result
예제 #2
0
class Player(BasePlayer):
    maxScreens = models.DecimalField(max_digits=5, decimal_places=2)
    screenTime = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMin = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMax = models.DecimalField(max_digits=5, decimal_places=2)

    task_reward = models.DecimalField(max_digits=5, decimal_places=2)
    target_income = models.DecimalField(max_digits=5, decimal_places=2)
    # add timestamps
    time_GameInstructions = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_PracticeTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_SearchTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
예제 #3
0
class Player(BasePlayer):

    time_emo_quest_pg1 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_emo_quest_pg2 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_DoneQuestionnaire = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    for i in range(len(Constants.emo_list)):
        temp = Constants.emo_list[i]
        locals()['{}'.format(temp)] = models.DecimalField(widget=widgets.HiddenInput(),
                                                          max_digits=3,
                                                          decimal_places=1,
                                                          min=1,
                                                          max=7)
예제 #4
0
class Player(BasePlayer):
    def get_partner(self):
        return self.get_others_in_group()[0]

    def set_partner_message_t(self):
        self.partner_message_t = self.get_partner().message_t

    cost = models.PositiveIntegerField(choices=[0, Constants.cbar])

    message_t = models.CharField(choices=[
        "Ich habe keine Kosten aus der Reform. Du kannst mir vertrauen.",
        "Die Reform kostet mich " + str(Constants.cbar) +
        " Taler. Du kannst mir vertrauen."
    ])

    message_c = models.CharField(choices=["ja", "nein"])

    message = models.PositiveIntegerField(choices=[0, Constants.cbar])

    controll_first = models.BooleanField()

    controll_now = models.BooleanField()

    kompensation_guess = models.CharField(choices=["ja", "nein"])

    guessing_payoff = models.CurrencyField()

    q1 = models.CharField(choices=["wahr", "falsch"])

    q2 = models.CharField(choices=["wahr", "falsch"])

    q3 = models.CharField(choices=["wahr", "falsch"])

    show = models.TextField()
    know_partner = models.CharField(choices=["ja", "nein"])

    partner_message_t = models.CharField(choices=[
        "Ich habe keine Kosten aus der Reform. Du kannst mir vertrauen.",
        "Die Reform kostet mich " + str(Constants.cbar) +
        " Taler. Du kannst mir vertrauen."
    ])
    payoff_prelim = models.CurrencyField()

    #variables in order to show table
    aa = models.PositiveIntegerField(initial=Constants.vhalf)
    ab = models.PositiveIntegerField(initial=Constants.vminuscbar)
    ba = models.PositiveIntegerField(initial=Constants.cbar)
    bb = models.PositiveIntegerField(initial=0)

    guess_prob = models.FloatField(min=0, max=1)
    message_about_message = models.TextField()
예제 #5
0
class Player(BasePlayer):
    for i in range(Constants.num_artifacts):
        locals()["rating_" + str(i)] = models.IntegerField(
            choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect(), blank=True)
    for i in range(Constants.num_artifacts):
        locals()["view_" + str(i)] = models.IntegerField(blank=True)
        locals()["download_" + str(i)] = models.IntegerField(blank=True)
        locals()["time_ms_" + str(i)] = models.IntegerField(blank=True)
        locals()["position_" + str(i)] = models.IntegerField()
    del i
    world = models.IntegerField(initial=0)
    rows = models.IntegerField()
    cols = models.IntegerField()
    direction = models.TextField()
    user_agent = models.TextField()
예제 #6
0
파일: models.py 프로젝트: ritdas/oTree
class Player(BasePlayer):
    judlink = models.StringField()
    caseid = models.StringField(blank=True)
    judge1 = models.StringField()
    judge2 = models.StringField(blank=True)
    judge3 = models.StringField(blank=True)
    petitioners = models.StringField()
    respondents = models.StringField()
    appeal = models.StringField(label="Appeal Case?", choices=["Yes", "No"])
    constitutional = models.StringField(label="Constitutional Case?",
                                        choices=["Yes", "No"])
    petn_advocate = models.StringField()
    resp_advocate = models.StringField()
    company = models.StringField(blank=True)
    state = models.StringField(blank=True)
    district = models.StringField(blank=True)
    # river = models.StringField(blank=True)
    govrole = models.StringField(
        label="Government's Role",
        choices=["Petitioner", "Respondent", "Both", "None"])
    socimp = models.StringField(
        label=
        "Is this judgment likely to have a positive impact on the environment?",
        choices=["Yes", "No"])
    reflection = models.TextField(
        label="What are your reflections on this case?", null=True, blank=True)
예제 #7
0
파일: models.py 프로젝트: FlovicG/SECU
class QuestionToExpert(Model):
    question_text = models.TextField()
    related_question = models.CharField(choices=Choices.questions,
                                        initial=Choices.questions[0])
    player = ForeignKey(
        Player
    )  # creates 1:m relation -> this question was asked by a certain player
예제 #8
0
class Player(BasePlayer):
    social_distance_text = models.TextField(max_length=400)

    def copy_text_toParticipant(self):
        self.participant.vars['text'] = self.social_distance_text

    pass
예제 #9
0
class Player(BasePlayer):
    type = models.CharField()
    belief_in_interval = models.IntegerField()

    #FIRM: elicited effort
    eleffort1 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort2 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort3 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort4 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort5 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort6 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort7 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort8 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort9 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort10 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort11 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort12 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort13 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort14 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort15 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")
    eleffort16 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}),verbose_name="")

    #WORKER: strategy method effort
    steffort1 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort2 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort3 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort4 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort5 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort6 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort7 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort8 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort9 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort10 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort11 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort12 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort13 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort14 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort15 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")
    steffort16 = models.FloatField(min=0, max=6, widget=widgets.SliderInput(attrs={'step': '0.25'}), verbose_name="")

    #WORKER: elicited wage
    wagebelief = models.IntegerField(min=1, verbose_name='')
    #payoff from questionnaire period chosen randomly
    payoff_questionnaire = models.FloatField(initial=0)
    #payoff from decisional period chosen randomly
    payoff_decisional = models.FloatField(initial=0)
    #Payment at the end of the experiment
    final_payoff = models.FloatField(initial=0)
    #gender
    gender = models.IntegerField(choices=[[1,'Male'], [2,'Female'], [3,'Other']], verbose_name='')
    #education
    undergrad = models.IntegerField(choices=[[1,'Yes'], [0,'No']],verbose_name='')
    #comments
    comments = models.TextField(
        blank=True,
        max_length=3000,
        verbose_name = 'Please, write here any comment concerning the experiment (for example: game length, instructions, game). We would love to hear your opinion about it.'

    )
예제 #10
0
class Player(BasePlayer):
    incentives = models.IntegerField()
    rpi = models.IntegerField()

    mturk_feedback = models.TextField(
        label=
        "Do you have any feedback for us or anything you would like to say to us?",
        blank=True)
예제 #11
0
파일: models.py 프로젝트: rizalap/docs
class Player(BasePlayer):
    transcribed_text = models.TextField()
    levenshtein_distance = models.PositiveIntegerField()

    def before_next_page(self):
        for player in self.get_players():
            payoff = len(prev_player.transcribed_text)
            player.participant.vars['payoff'] = payoff
예제 #12
0
class Player(BasePlayer):
    transcribed_text = models.TextField()
    levenshtein_distance = models.PositiveIntegerField()

    if levenshtein_distance == 0:
        payoff = 1
    else:
        payoff = c(0)
예제 #13
0
class Player(BasePlayer):

    time_eyes_instructions = models.TextField(widget=widgets.HiddenInput(
        attrs={'id': 'arrive_time'}))
    time_Question = models.TextField(widget=widgets.HiddenInput(
        attrs={'id': 'arrive_time'}))

    question_id = models.PositiveIntegerField()
    question = models.CharField()
    solution = models.CharField()
    submitted_answer = models.CharField(widget=widgets.RadioSelect())
    is_correct = models.BooleanField()

    def current_question(self):
        return self.session.vars['questions'][self.round_number - 1]

    def check_correct(self):
        self.is_correct = self.submitted_answer == self.solution
예제 #14
0
파일: models_dspt.py 프로젝트: mlzzr/cf_iia
class Player(BasePlayer):
    treatment = models.PositiveIntegerField()
    senior_name = models.CharField()
    junior_name = models.CharField()
    senior_prob = models.FloatField()
    senior_dice_num = models.PositiveIntegerField()
    junior_dice_num = models.PositiveIntegerField()
    dice_num = models.PositiveIntegerField()
    dice_roll = models.PositiveIntegerField()
    dice_win = models.BooleanField()
    acc = models.FloatField()
    good_prior = models.FloatField()
    senior = models.BooleanField()
    good = models.BooleanField()
    signal = models.BooleanField()
    posterior = models.FloatField()
    lottery_odds = models.PositiveIntegerField()
    lottery_win = models.BooleanField()
    investment = models.BooleanField(
        choices=[
            [1, 'The investment'],
            [0, 'The lottery'],
        ],
        widget=widgets.RadioSelect()
    )
    dice_count = models.BooleanField()


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

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


    def calculate_bonus(self):
        if self.dice_count:
            self.participant.payoff = self.dice_win * Constants.high_bonus + (1 - self.dice_win) * Constants.low_bonus
        else:
            if self.investment:
                self.participant.payoff = self.good * Constants.high_bonus + (1 - self.good) * Constants.low_bonus
            else:
                self.participant.payoff = self.lottery_win * Constants.high_bonus + (1 - self.lottery_win) * Constants.low_bonus
예제 #15
0
class Message(models.Model):
    content = models.TextField()
    timestamp = django_models.DateTimeField(auto_now=True)
    player = models.ForeignKey('Player', on_delete=models.CASCADE, null=True)
    chat_id = models.IntegerField()
    group = models.ForeignKey('Group', on_delete=models.CASCADE, null=True)
    player_name = models.StringField()

    @staticmethod
    def last_30_messages():
        last_30 = Message.objects.order_by('-timestamp')[:30]
        return reversed(last_30)
class Player(BasePlayer):
    Q1 = models.BooleanField(
        blank=True,
        choices=[[True, "Yes"], [False, "No"]],
        widget=widgets.RadioSelectHorizontal,
        label="Q1",
    )

    Q2 = models.IntegerField(
        blank=True,
        choices=[[1, "A"], 
                 [2, "B"], 
                 [3, "C"]],
        label="Q2",
        widget=widgets.RadioSelect,
    )

    Q3 = models.IntegerField(
        blank=True,
        choices=[[1, "A"],
                 [2, "B"],
                 [3, "C"],
                 [4, "D"]],
        label="Q3",
    )

    Q4 = models.FloatField(
        widget=widgets.Slider(show_value=True, attrs={'step': '1'}),
        max=100, min=0, blank=True, initial=random_initial(),
        label="Q4"
    )

    Q5 = models.IntegerField(label="Q5", max=100, min=0, blank=True)

    Q6 = models.FloatField(label="Q6", max=100, min=0, blank=True)

    Q7 = models.StringField(label="Q7", blank=True)

    Q8 = models.CurrencyField(
        label="Q8",
        blank=True
    )

    Q9 = models.LongStringField (
        label="Q9",
        blank=True,
    )

    Q10 = models.TextField(
        label="Q10",
        blank=True,
    )
예제 #17
0
class Player(BasePlayer):
    # #player's answer for each matrix
    # #answer = models.PositiveIntegerField(max=Constants.guess_max)
    # #checks if player's answer matches the solution
    # is_correct = models.BooleanField()
    # #matrix number of zeros solution - will use for Results page
    # solution = models.PositiveIntegerField()
    # question_correct = models.BooleanField()
    # average = models.FloatField()
    # total = models.FloatField()
    seqdict = models.TextField()
    seq = models.TextField()
    seqcounter = models.IntegerField(initial=0)
    sumcorrect = models.IntegerField(initial=0)
    contribution = models.CurrencyField()
    total_payoff = models.CurrencyField()
    payoff = models.CurrencyField()
    # indiv_payoff = models.CurrencyField()
    totalearnings = models.CurrencyField()
    treat = models.CharField()
    avgearnings = models.CurrencyField()
    totalwages = models.CurrencyField()
    avgwages = models.CurrencyField()
예제 #18
0
class Group(BaseGroup):
    # define vars
    treatment = models.TextField()
    value_type = models.TextField()
    elicitation_method = models.TextField()
    BDM_type = models.TextField()
    BDM_lolimit = models.TextField()
    BDM_uplimit = models.TextField()
    BDM_list_step = models.DecimalField(max_digits=5, decimal_places=2)
예제 #19
0
class AdminChatMessage(models.Model):
    class Meta:
        index_together = ['channel', 'timestamp']

    # the name "channel" here is unrelated to Django channels
    channel = models.CharField(max_length=255)
    # related_name necessary to disambiguate with otreechat add on
    participant = models.ForeignKey('otree.Participant',
                                    related_name='admin_chat_messages',
                                    on_delete=models.CASCADE)
    nickname = models.CharField(max_length=255)

    # call it 'body' instead of 'message' or 'content' because those terms
    # are already used by channels
    body = models.TextField()
    timestamp = models.FloatField(default=time.time)

    is_seen = models.BooleanField(default=False)
예제 #20
0
class Player(BasePlayer):
    ### Here is the part where you define the options available for the participant.
    ###
    # Randomly generate items
    styleColor = {}
    styleColor[0] = "#009EA0"
    styleColor[1] = "#FB3640"
    styleColor[2] = "#605F5E"
    styleColor[3] = "#F46036"
    styleColor[4] = "#FFBA49"
    choicesButtons = []
    for i in range(40):
        colorNum = random.choice([0, 1, 2, 3, 4])
        choicesButtons.append((i, 'Object ' + str(i), styleColor[colorNum]))
    objectChoicesParams = {'itemsToChoose': choicesButtons, 'maxNumOptions': 5}

    preference = models.TextField(widget=school_choice_widgets.OrderedChoice(
        choices=objectChoicesParams))
class Player(BasePlayer):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female'),
    )
    gender = models.CharField(max_length=1,
                              choices=GENDER_CHOICES,
                              blank=False)
    age = models.IntegerField(min=18, max=100, blank=False)
    major = models.CharField(max_length=255, blank=False)
    q1 = models.TextField(blank=False)
    q2 = models.TextField(blank=False)
    q3 = models.TextField(blank=False)
    q4 = models.TextField(blank=False)
    q5 = models.TextField(blank=False)
    q6 = models.TextField(blank=False)
예제 #22
0
class Player(BasePlayer):
    def role(self):
        if self.id_in_group == 1:
            return 'Manager'
        else:
            return 'Employee'

    def chat_nickname(self):
        return '{} {}'.format(self.role(), self.id_in_group - 1)

    transcribed_text = models.TextField(blank=True)
    levenshtein_distance = models.PositiveIntegerField()
    emp_price = models.CurrencyField()
    man_emp1_price = models.CurrencyField()
    man_emp1_accpt = models.BooleanField()
    man_emp2_price = models.CurrencyField()
    man_emp2_accpt = models.BooleanField()
    man_emp3_price = models.CurrencyField()
    man_emp3_accpt = models.BooleanField()
    startwp_timer_set = models.BooleanField(default=False)
    startwp_time = models.PositiveIntegerField()
    outofthegame = models.BooleanField()
예제 #23
0
class Player(BasePlayer):
    def setOption(self):
        if self.placed_in_group == False:
            if self.remove_option_own == True:
                self.option_available = False
            else:
                self.option_available = True
        elif self.placed_in_group == True:
            if self.leave_group_choice == True:
                self.option_available = True
            elif self.subsession.group_voted_remove == True:
                self.option_available = False
            elif self.subsession.group_voted_remove == False:
                self.option_available = True

    def setPayoff(self):
        self.payoff = c(int(self.tasks_completed) * Constants.points_per_task)

    placed_in_group = models.BooleanField()
    option_available = models.BooleanField(initial=True)

    leave_group_choice = models.BooleanField()
    remove_option_own = models.BooleanField()
    vote_to_remove = models.BooleanField()
    commit_choice_first = models.BooleanField()

    tasks_completed = models.CharField(initial="0")
    play_choice1 = models.CharField()
    play_choice2 = models.CharField()
    play_choice3 = models.CharField()
    play_choice4 = models.CharField()
    play_choice5 = models.CharField()
    play_choice6 = models.CharField()
    group_decision_belief = models.IntegerField(
        choices=[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
        widget=widgets.RadioSelectHorizontal)
    text_feedback = models.TextField()
    restrospective_preference = models.BooleanField()
예제 #24
0
class Player(BasePlayer):

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

    gender = models.StringField(
        choices=[[a] * 2 for a in Constants.gender_options],
        label='What is your gender?',
        widget=widgets.RadioSelect,
    )

    income = models.StringField(choices=[[a] * 2
                                         for a in Constants.income_options],
                                label='What is your household income?',
                                widget=widgets.RadioSelect)

    education = models.StringField(
        choices=[[a] * 2 for a in Constants.education_options],
        label='What is your highest level of education?',
        widget=widgets.RadioSelect)

    pd_familiarity = models.StringField(
        choices=[[a] * 2 for a in Constants.pd_familiarity_options],
        label=
        'How familiar were you with the Prisoner\'s Dilemma game before this experiment?',
        widget=widgets.RadioSelect)

    english_native_language = models.StringField(
        choices=[[a] * 2 for a in Constants.english_native_language_options],
        label='Is English your native language?',
        widget=widgets.RadioSelect)

    feedback = models.TextField(
        label='''This is your chance to submit feedback to us.
        Was there anything you found confusing?''',
        blank=True)
    """
예제 #25
0
class Player(BasePlayer):
    endowment = models.CurrencyField(initial=Constants.endowment)
    city = djmodels.ForeignKey(to='City',
                               related_name='players',
                               null=True,
                               blank=True,
                               on_delete=djmodels.SET_NULL)
    _role = models.StringField()
    stage1payoff = models.CurrencyField(initial=0)
    stage2payoff = models.CurrencyField(initial=0)
    city_order = models.BooleanField()
    calculable = models.BooleanField(initial=False)
    cq1_counter = models.FloatField()
    cq2_counter = models.FloatField()
    comment = models.TextField(label=_(
        'Все ли было понятно в инструкциях? С какими сложностями вы столкнулись?'
    ))

    def get_instructions(self, part):

        if part == 1:
            page_numbers = list(Constants.num_instructions_blocks['part1'])
        if part == 2:
            page_numbers = list(
                Constants.num_instructions_blocks[f'part{part}{self.role()}'])
        return (self.instructions.filter(page_number__in=page_numbers))

    def _injecting_imgs(self, q):
        res = [
            dict(page_number=i.page_number, img_path=i.get_absolute_url())
            for i in q
        ]
        return res

    def get_instructions_part1(self):
        return self._injecting_imgs(self.get_instructions(part=1))

    def get_instructions_part2(self):
        return self._injecting_imgs(self.get_instructions(part=2))

    def set_params(self):
        """create some params and decision sets that we can create before role assignment. Which are:
        averages, and order in which cities are shown."""
        p = self
        # randomize city order
        p.participant.vars['city_order'] = random.choice([True, False])
        p.city_order = p.participant.vars['city_order']

    def assign_role(self):
        """Assign a role, and create decisions and beliefs questions based on that role.
        We correct to the fact that new groups start forming from 2 (1 is first large group for all).
        and taking into account the fact that we now get groups of single players, we just cycle over roles
        in formed group"""
        roles = list(Constants.roles.keys())
        self._role = roles[
            (self.group.id_in_subsession - 2) %
            2]  # odd numbers become Senders, even numbers become Receivers

    @property
    def role_desc(self):
        """Returns a friendly description of a players' role """
        return Constants.roles.get(self.role())

    def get_city_obj(self):
        return self.city

    @property
    def guess_desc(self):
        if self.role() == 'sender':
            return c(self.guess)
        else:
            return 'не передать свою начальную сумму' if self.guess == 0 else 'передать свою начальную сумму'

    @property
    def decision_desc(self):
        if self.role() == 'sender':
            return 'не передать свою начальную сумму' if self.decision == 0 else 'передать свою начальную сумму'
        else:
            return f'вернуть {c(self.decision)}'

    @property
    def other_role_desc(self):
        """Returns a friendly description of a role of another player"""
        other_role = 'receiver' if self.role() == 'sender' else 'sender'
        return Constants.roles.get(other_role)

    def role(self):
        return self._role

    def _decision_getter(self, decision_type):
        return self.decisions.filter(decision_type=decision_type)

    @property
    def senderdecisions(self):
        return self._decision_getter('sender_decision')

    @property
    def returndecisions(self):
        return self._decision_getter('return_decision')

    @property
    def senderbeliefs(self):
        return self._decision_getter('sender_belief')

    @property
    def returnerbeliefs(self):
        return self._decision_getter('receiver_belief')

    @property
    def averageonsendbeliefs(self):
        return self._decision_getter('average_on_send_belief')

    @property
    def averageonreturnbeliefs(self):
        return self._decision_getter('average_on_return_belief')
예제 #26
0
class Player(BasePlayer):

    q1 = models.IntegerField(
        choices=[[1, '5'], [2, '-5'], [3, '20'], [4, '0'], [5, '10']],
        widget=widgets.RadioSelect,
        verbose_name=
        "Question 1. If you were to choose GREEN as the color of the hat, how many tokens would you get?"
    )

    q2 = models.IntegerField(
        choices=[[1, '5'], [2, '-5'], [3, '20'], [4, '0'], [5, '10']],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 2. If you were to choose RED as the color of the hat, how many tokens would you get?'
    )

    q3 = models.IntegerField(
        choices=[[
            1,
            'Player E and Player D have two hints each regarding the right colors.'
        ], [2, 'Player E and Player D can chat together.'], [3, 'Nothing.'],
                 [4, 'Player E or Player D already know about the hat.']],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 3. From the hint concerning the network structure, you see that you are assigned to position C. This means that you will be able to chat with Player D and Player E. Moreover, you can see from the picture that Player D and Player E are connected. What does this imply?'
    )

    q4 = models.IntegerField(
        choices=[
            [
                1,
                'No, Player D does not have any information that you may need.'
            ],
            [
                2,
                'Yes, Player D has certainly received information about a piece of clothing that’s not the hat.'
            ],
            [
                3,
                'Maybe, if Player D has received information about a piece of clothing that’s not the hat.'
            ],
        ],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 4. Do you think that Player D could have useful information regarding the color combination?'
    )

    q5 = models.IntegerField(
        choices=[[1, '40 and 0'], [2, '50 and 33'], [3, '50 and 20'],
                 [4, '50 and 100'], [5, '40 and 33']],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 5. Suppose that by the end of the round you have collected five hints concerning the colors. Suppose also that you are certain that these five hints are correct, and that all the other four players of the group have these same hints. What is the preliminary score that you expect to receive? What is the bonus score that you expect to receive?'
    )

    q6 = models.IntegerField(
        choices=[[1, '40 and 100'], [2, '30 and 100'], [3, '40 and 25'],
                 [4, '40 and 0'], [5, '50 and 20']],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 6. Suppose that by the end of the round you have collected four hints concerning the colors. Suppose also that you are certain that these four hints are correct, and that none of the other players has as many hints as you have. What is the preliminary score that you expect to receive? What is the bonus score that you expect to receive?'
    )

    q7 = models.IntegerField(
        choices=[
            [1, 'It will be not higher than 40 and no lower than -20.'],
            [2, 'It will be not higher than 30 and no lower than -20.'],
            [3, 'It will be not higher than 40 and no lower than 0.'],
            [4, 'It will be not higher than 30 and no lower than 0.'],
        ],
        widget=widgets.RadioSelect,
        verbose_name=
        'Question 7. Suppose that by the end of the round you have collected four hints concerning the colors. Suppose also that you are not sure whether these hints are correct. What is the preliminary score you expect to receive?'
    )

    name = models.CharField(verbose_name="Please enter your First Name:")

    surname = models.CharField(verbose_name="Please enter your Last Name:")

    mail = models.CharField(
        verbose_name=
        "Please enter the email adress where you want to receive the payment")
    role = models.CharField()
    hint = models.CharField()

    tshirt = models.CharField(blank=True)
    hat = models.CharField(blank=True)
    pants = models.CharField(blank=True)
    gloves = models.CharField(blank=True)
    shoes = models.CharField(blank=True)
    hist = models.TextField(blank=True)

    timestamp = models.TextField(blank=True)

    def right_col(self):
        n = 0

        if self.tshirt == self.group.tshirt_col:
            n = n + 1

        if self.hat == self.group.hat_col:
            n = n + 1

        if self.pants == self.group.pants_col:
            n = n + 1

        if self.gloves == self.group.gloves_col:
            n = n + 1

        if self.shoes == self.group.shoes_col:
            n = n + 1

        return n

    def no_col(self):
        n = 0

        if self.tshirt == '' or self.tshirt == 'grey':
            n = n + 1

        if self.hat == '' or self.hat == 'grey':
            n = n + 1

        if self.pants == '' or self.pants == 'grey':
            n = n + 1

        if self.gloves == '' or self.gloves == 'grey':
            n = n + 1

        if self.shoes == '' or self.shoes == 'grey':
            n = n + 1

        return n

    def wrong_col(self):
        n = 5 - self.right_col() - self.no_col()
        return n

    def partial_pay(self):
        pp = 10 * self.right_col() - 5 * (5 - self.right_col() - self.no_col())
        return pp

    def chat_nickname(self):
        return 'Player {}'.format(self.role)

    def chat_configs(self):

        if self.group.network == 1:
            configs = []
            for other in self.get_others_in_group():
                if other.id_in_group < self.id_in_group:
                    lower_id, higher_id = other.role, self.role
                else:
                    lower_id, higher_id = self.role, other.role

                if (lower_id == 'A'
                        and higher_id == 'B') or (lower_id == 'B'
                                                  and higher_id == 'A'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'D') or (lower_id == 'D'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'D'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'D'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'B'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'B'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

            return configs

        if self.group.network == 2:
            configs = []
            for other in self.get_others_in_group():
                if other.id_in_group < self.id_in_group:
                    lower_id, higher_id = other.role, self.role
                else:
                    lower_id, higher_id = self.role, other.role

                if (lower_id == 'A'
                        and higher_id == 'B') or (lower_id == 'B'
                                                  and higher_id == 'A'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'A'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'A'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'B'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'B'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'D'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'D'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'D') or (lower_id == 'D'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

            return configs

        if self.group.network == 3:
            configs = []
            for other in self.get_others_in_group():
                if other.id_in_group < self.id_in_group:
                    lower_id, higher_id = other.role, self.role
                else:
                    lower_id, higher_id = self.role, other.role

                if (lower_id == 'A'
                        and higher_id == 'B') or (lower_id == 'B'
                                                  and higher_id == 'A'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'B'
                        and higher_id == 'C') or (lower_id == 'C'
                                                  and higher_id == 'B'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'B'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'B'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'D'
                        and higher_id == 'E') or (lower_id == 'E'
                                                  and higher_id == 'D'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

                if (lower_id == 'C'
                        and higher_id == 'D') or (lower_id == 'D'
                                                  and higher_id == 'C'):
                    configs.append({
                        'channel':
                        '{}-{}-{}'.format(self.group.id, lower_id, higher_id),
                        'label':
                        'Chat with {}'.format(other.chat_nickname())
                    })

            return configs

    pass
예제 #27
0
class Player(BasePlayer):
    transcribed_text = models.TextField()
    levenshtein_distance = models.PositiveIntegerField()
예제 #28
0
class Group(BaseGroup):
    buyer = models.TextField()
    seller = models.TextField()
예제 #29
0
class Player(BasePlayer):

    feature_ind = models.TextField()

    answers0 = models.TextField()
    answers1 = models.TextField()
    answers2 = models.TextField()
    answers3 = models.TextField()
    answers4 = models.TextField()

    def get_feature_names(self, indices):
        return [
            Constants.feature_names[i] for i, t in enumerate(indices) if t == 1
        ]

    def update_pareto(self, data_key):
        # Historic dataset
        data = self.session.vars[data_key]

        # Gather old responses
        prev_response = self.participant.vars[data_key]

        # Gathering objectives data
        tem1 = np.array([data.get(key)
                         for key in ['obj1', 'obj2']]).T  #dictionary
        n_data = tem1.shape[0]
        tem2 = np.array([prev_response.get(key)
                         for key in ['obj1', 'obj2']]).T  #dictionary
        n_response = tem2.shape[0]

        costs = np.vstack([tem1, tem2]) * np.array(
            [[-1, 1]])  #Maximize stiffness and minimize volume fraction
        # Constraint Feasibility=1 should be satisfied
        if_constr1 = np.array([v == 1 for v in data['constr1']] +
                              [v == 1 for v in prev_response['constr1']])
        # Find new pareto and update databse
        ret = self.subsession.is_pareto_efficient(costs[if_constr1])
        is_pareto = np.zeros((n_data + n_response, )).astype(bool)
        is_pareto[if_constr1] = ret

        # self.session.vars['is_pareto_new'] = ret[0:n_data].tolist()
        prev_response['is_pareto'] = is_pareto[n_data:].tolist()
        data['is_pareto_response' +
             str(self.id_in_subsession)] = is_pareto[0:n_data].tolist()

        return is_pareto[0:n_data].tolist()

    def update_response_database(self, response, data_key):
        # Gather old responses
        if data_key not in self.participant.vars.keys():
            self.participant.vars[data_key] = dict()

        prev_response = self.participant.vars[data_key]
        for key in response.keys():
            if key not in prev_response:
                prev_response[key] = []
            prev_response[key].append(response[key])

    def live_method(self, data):

        if data['message'] == 'clean image':
            #For cleaning data
            x = np.array(data['x'])
            x[x > 0.25] = 1
            x[x < 0.25] = 0
            x_img = self.subsession.convert_to_img(x)
            image = x_img.tolist()

            return {self.id_in_group: dict(message='clean image', image=image)}

        elif data['message'] == 'test design':
            #Load data even if it may be empty
            # x is a bitstring design vector
            # z is a feature vector
            x = np.array(data['x'])
            x[x > 0.25] = 1
            x[x < 0.25] = 0

            # z = np.array([data['z']])
            # if ~np.any(np.isin(z, ['', None, 'nan'])):
            # 	x_img = self.subsession.decoder(z)
            # 	x = self.subsession.encoder_bitstring(x_img).numpy()[0]
            # 	x[x>0.25]=1
            # 	x[x<0.25]=0

            if np.any(np.isin(x, ['', None, 'nan'])):
                x = np.ones(Constants.edgelist.shape[0])

            # Running the design evaluator and creating a response
            # Repeat the edges in a 2d place
            x = truss_model.repeatable_des(x)
            obj1, obj2 = truss_model.multiobjectives(x, Constants.nucFac,
                                                     Constants.sel,
                                                     Constants.E, Constants.r,
                                                     Constants.edgelist, 1)
            edges_des = Constants.edgelist[x.astype(bool)]
            constr1 = truss_model.feasibility(Constants.pos, edges_des)
            constr2 = 0  #truss_model.stability(Constants.sidenum, edges_des, Constants.pos)
            x_img = self.subsession.convert_to_img(x)
            image = json.dumps(x_img.tolist())
            design = json.dumps(x.tolist())

            response = dict(design_bitstring=design,
                            obj1=obj1,
                            obj2=obj2,
                            constr1=constr1,
                            constr2=constr2,
                            image=image,
                            is_pareto=None)
            response.update(data)
            # Check if any element is int32
            for k, v in response.items():
                if isinstance(v, np.int32) or isinstance(v, np.int64):
                    response[k] = int(v)

            # Update databse and Check if pareto
            data_key = data['data_key']
            self.update_response_database(response, data_key)

            # Update pareto information; Returns pareto infroamtion for historic data
            is_pareto_response = self.update_pareto(data_key)

            # Retrive updated data rom database
            response_data = self.participant.vars[data_key]

            return {
                self.id_in_group:
                dict(message='test design',
                     response_data=response_data,
                     is_pareto_response=is_pareto_response)
            }
예제 #30
0
class Player(BasePlayer):

    time_batson1 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_batson2 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    '''