Exemple #1
0
class SliderPlayer(BasePlayer):
    class Meta:
        abstract = True

    centered_sliders = models.PositiveIntegerField()
    num_sliders = models.PositiveIntegerField()
    slider_min = models.IntegerField()
    slider_max = models.IntegerField()

    def prepare_sliders(self, num=50, min=0, max=100):
        self.num_sliders = num
        self.slider_min = min
        self.slider_max = max
        for _ in range(self.num_sliders):
            slider = self.slider_set.create()
            slider.minimum = self.slider_min
            slider.maximum = self.slider_max
            slider.set_starting_pos()
            slider.save()

    def count_centered_sliders(self):
        sum_of_centered = 0
        for s in self.slider_set.all():
            if s.touched and s.centered:
                sum_of_centered += 1
        self.centered_sliders = sum_of_centered
Exemple #2
0
class Player(BasePlayer):

    role = models.StringField(doc="""Role in group""")

    wine_sell_price = models.PositiveIntegerField(min=0, max=Constants.max_price,doc="""Price seller chooses to sell wine at""")

    wine_buy_price = models.PositiveIntegerField(
        choices=Constants.prices,
        doc="""Price buyer will buy the wine at""")

    number_of_bottles = models.PositiveIntegerField(
        min=0, max=Constants.max_bottles,
        doc="""Number of bottles""")

    def get_role(self):
        if self.id_in_group == 1:
            self.role = 'Seller'
        elif self.id_in_group == 2:
            self.role = 'Buyer 1'
            self.wine_buy_price = Constants.prices[0]
        elif self.id_in_group == 3:
            self.role = 'Buyer 2'
            self.wine_buy_price = Constants.prices[1]
        elif self.id_in_group == 4:
            self.role = 'Buyer 3'
            self.wine_buy_price = Constants.prices[2]
        elif self.id_in_group == 5:
            self.role = 'Buyer 4'
            self.wine_buy_price = Constants.prices[3]
        elif self.id_in_group == 6:
            self.role = 'Buyer 5'
            self.wine_buy_price = Constants.prices[4]
Exemple #3
0
class Player(BasePlayer):

    prolificcode = models.CharField()
    starttime = models.FloatField()
    endtime = models.FloatField()
    jsdectime_start = models.FloatField()
    jsdectime_end = models.FloatField()
    q = models.IntegerField()
    d = models.IntegerField()
    revenue = models.IntegerField()
    cost = models.IntegerField()
    fakeround_number = models.IntegerField()
    pecu = models.PositiveIntegerField(choices=[[1, '1 = Not at all'],
                                                [2, '2'], [3, '3'], [4, '4'],
                                                [5, '5'], [6, '6'], [7, '7'],
                                                [8, '8'],
                                                [9,
                                                 '9 = As much as possible']],
                                       widget=widgets.RadioSelect())
    nonpecu = models.PositiveIntegerField(
        choices=[[1, '1 = Not at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'],
                 [6, '6'], [7, '7'], [8, '8'], [9, '9 = As much as possible']],
        widget=widgets.RadioSelect())
    conflict = models.PositiveIntegerField(
        choices=[[1, '1 = Least conflicted'], [2, '2'], [3, '3'], [4, '4'],
                 [5, '5'], [6, '6'], [7, '7'], [8, '8'],
                 [9, '9 = Most conflicted']],
        widget=widgets.RadioSelect())
Exemple #4
0
class Player(BasePlayer):
    def set_payoff(self):
        """Calculate payoff, which is zero for the survey"""
        self.payoff = 0

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

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

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

    crt_lake = models.PositiveIntegerField(verbose_name='''
        In a lake, there is a patch of lily pads.
        Every day, the patch doubles in size.
        If it takes 48 days for the patch to cover the entire lake,
        how many days would it take for the patch to cover half of the lake?
        ''')
class Player(BasePlayer):
    n_right_guesses = models.PositiveIntegerField()
    gender = models.CharField(
        choices = [
            "weiblich",
            "männlich",
            "keine Angabe"
        ])
    degree = models.CharField(
        choices = [
            "Abitur",
            "Bachelor",
            "Master",
            "Promotion"
        ])
    econ = models.CharField(
        choices = [
            "Ja",
            "Nein"
        ])
    age =  models.PositiveIntegerField(min = 15, max = 40)
    money = models.PositiveIntegerField()

    #I use the grave mistaes variable in order to aks players whether they intentionally played a dominated action
    grave_mistake = models.BooleanField()
    grave_mistake_on_purpose = models.CharField(
        choices = [
            "Ja",
            "Nein"
        ])
    def set_grave_mistake(self):
        self.grave_mistake = False
        for p in self.in_previous_rounds():
            if p.costs == Constants.cbar and p.message == 0:
                self.grave_mistake = True
class Player(BasePlayer):

    computer = models.CharField(
        max_length=10, verbose_name="What computer are you sitting at?")
    gender = models.CharField(max_length=6,
                              choices=["Male", "Female"],
                              widget=widgets.RadioSelectHorizontal,
                              verbose_name="What is your gender?")

    is_talkative = models.PositiveIntegerField(
        choices=Constants.agree_levels,
        verbose_name="Extraverted, enthusiastic")
    has_an_active_imagination = models.PositiveIntegerField(
        choices=Constants.agree_levels, verbose_name="Critical, quarrelsome")
    tends_to_find_fault_with_others = models.PositiveIntegerField(
        choices=Constants.agree_levels,
        verbose_name="Dependable, self-disciplined")
    tends_to_be_quiet = models.PositiveIntegerField(
        choices=Constants.agree_levels, verbose_name="Anxious, easily upset")
    does_a_thorough_job = models.PositiveIntegerField(
        choices=Constants.agree_levels,
        verbose_name="Open to new experiences, complex")
    is_generally_trusting = models.PositiveIntegerField(
        choices=Constants.agree_levels, verbose_name="Reserved, quiet")
    is_depressed_blue = models.PositiveIntegerField(
        choices=Constants.agree_levels, verbose_name="Sympathetic, warm")
    tends_to_be_lazy = models.PositiveIntegerField(
        choices=Constants.agree_levels, verbose_name="Disorganized, careless")
    is_original_comes_up_with_new_ideas = models.PositiveIntegerField(
        choices=Constants.agree_levels,
        verbose_name="Calm, emotionally stable")
    is_emotionally_stable_not_easily_upset = models.PositiveIntegerField(
        choices=Constants.agree_levels,
        verbose_name="Conventional, uncreative")
Exemple #7
0
class Player(BasePlayer):

    blank = models.CharField(blank=True)

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

    even_int = models.PositiveIntegerField()

    dynamic_choices = models.CharField()

    blank_dynamic_choices = models.IntegerField(blank=True)

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

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

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

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

    equals_one = models.IntegerField(initial=1)
Exemple #8
0
class Player(BasePlayer):
    hit_bomb = models.PositiveIntegerField()
    group_adapt = models.PositiveIntegerField(
        choices=[[1, 'Yes'],
                 [0, 'No']
                 ],
        widget=widgets.RadioSelect()
    )

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

    risk = models.PositiveIntegerField()

    def set_payoff(self):
        if self.group_adapt:
            self.payoff = 400
        else:
            if self.adapt==1:
                self.payoff = 300
            else:
                if self.hit_bomb==1:
                    self.payoff = 50
                else:
                    self.payoff = Constants.stakes
class Group(BaseGroup):
    two_thirds_avg = models.FloatField()
    average = models.FloatField(initial=0)
    best_guess = models.PositiveIntegerField()
    num_winners = models.PositiveIntegerField()



    def set_payoffs(self):
        players = self.get_players()
        guesses = [p.guess for p in players]
        self.average = sum(guesses) / len(players)
        two_thirds_avg = (2 / 3) * self.average
        self.two_thirds_avg = round(two_thirds_avg, 2)

        self.best_guess = min(guesses,
            key=lambda guess: abs(guess - self.two_thirds_avg))

        winners = [p for p in players if p.guess == self.best_guess]
        self.num_winners = len(winners)

        for p in winners:
            p.is_winner = True
            p.payoff = Constants.jackpot / self.num_winners

    def two_thirds_avg_history(self):
        return [g.two_thirds_avg for g in self.in_previous_rounds()]
Exemple #10
0
class Player(BasePlayer):
    age = models.PositiveIntegerField(
        min = 16,
        max = 120,
        verbose_name = "How old are you?",
        doc = "collect age data between 16 and 120",
    )

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

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

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

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

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

    bmi = models.FloatField()

    bmi_eval = models.CharField()

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

    def bmi_evaluation(self):
        if self.bmi < 18.5:
            self.bmi_eval = "You are underweight. Get help!"
        elif self.bmi > 25:
            self.bmi_eval =  "You are overweight, you fat f**k!"
        else:
            self.bmi_eval = "Your weight is normal, good job!"
Exemple #11
0
class Player(BasePlayer):
	def set_payoffs(self):
		# get applicable value of time series:
		# self.dictator_offer = Constants.timeseries(Constants.return_num_rounds(self))[self.round_number - 1]
		self.dictator_offer = self.group.bot_offer()
		self.payoff = self.dictator_offer
		self.played_against = self.group.active_bot_id()

	predicted = models.CurrencyField(
		doc="""Amount receiver predicted they would receive from allocator""",
		min=0, max=Constants.endowment,
		verbose_name="I will most likely receive (from 0 to {})".format(Constants.endowment)
	)

	rating = models.PositiveIntegerField(
	choices=[
		[1, 'Fair'],
		[0, 'Unfair'],
		]
	)
	# test var, see if this shows up in data as well:
	played_against = models.PositiveIntegerField(
		doc="""id of bot that player was paired off with in current round""",
		# this is set in set_payoffs method right now
		)

	def role(self):
		return "receiver" 
Exemple #12
0
class Player(BasePlayer):
    # This part is for the default django widget. The blank option is necessary to have empty boxes
    checkbox_option_1 = models.BooleanField(widget=widgets.CheckboxInput,
                                            blank=True)
    checkbox_option_2 = models.BooleanField(widget=widgets.CheckboxInput,
                                            blank=True)
    checkbox_option_3 = models.BooleanField(widget=widgets.CheckboxInput,
                                            blank=True)
    # The following part is just the basis for the following html code
    html_checkbox_1 = models.LongStringField()
    html_checkbox_2 = models.LongStringField()
    html_checkbox_3 = models.LongStringField()

    # This part is for the default django widget.
    # Define input variables (in this case as characters)
    radio = models.StringField(
        choices=['A', 'B', 'C'],
        widget=widgets.RadioSelect,
    )

    html_radio = models.StringField()

    slider = models.IntegerField(min=0, max=100, widget=widgets.Slider)

    html_slider_vertical = models.PositiveIntegerField()
    html_slider_horizontal = models.PositiveIntegerField()

    choice = models.StringField(choices=['A', 'B', 'C'])
    html_choice = models.StringField(choices=['A', 'B', 'C'],
                                     widget=widgets.RadioSelect)
Exemple #13
0
class Player(BasePlayer):
    def role(self):
        if self.id_in_group == 1:
            return 'Politician'
        if self.id_in_group == 2:
            return 'Bureaucrat'
        if self.id_in_group == 3:
            return 'Citizen'
        else:
            return "Waiting"

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

    def elections(self):
        self.participant.vars['new_election'] = 0
Exemple #14
0
class Group(BaseGroup):
    winner = models.PositiveIntegerField()
    winning_bid = models.PositiveIntegerField()
    mult_win = models.BooleanField()
    second_highest = models.PositiveIntegerField()

    def set_payoff(self):
        highest = 0
        second_highest = 0
        winner_collection = []
        for p in self.get_players():
            if p.bid > highest:
                second_highest = highest
                highest = p.bid
            if highest > p.bid > second_highest:
                second_highest = p.bid
        for p in self.get_players():
            if p.bid == highest:
                p.winner = True
                winner_collection.append(p.id_in_group)
        if len(winner_collection) > 1:
            self.mult_win = True
            second_highest = highest
        random_win = random.choice(winner_collection)
        for p in self.get_players():
            if p.winner and p.id_in_group == random_win:
                p.payoff = p.cert_price - second_highest
                self.second_highest = second_highest
                self.winner = p.id_in_group
                self.winning_bid = p.bid
            else:
                p.payoff = c(0)

    pass
Exemple #15
0
class WPTimeRecord(Model):
    augmented_participant = ForeignKey(AugmentedParticipant, on_delete=models.CASCADE)
    app = models.CharField()
    page_index = models.IntegerField()
    startwp_timer_set = models.BooleanField(default=False)
    startwp_time = models.PositiveIntegerField()
    endwp_time = models.PositiveIntegerField()
Exemple #16
0
class Group(BaseGroup):
    p1_share = models.PositiveIntegerField(
        max=Constants.pie_size, widget=widgets.Slider(attrs={'step': '1'}))
    p2_share = models.PositiveIntegerField(max=Constants.pie_size)

    def set_p2_share(self):
        self.p2_share = Constants.pie_size - self.p1_share
Exemple #17
0
class Player(BasePlayer):

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

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

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

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

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

    #Accept the conditions to participate
    accept_conditions = models.BooleanField(blank=False,
                                            widget=widgets.CheckboxInput)

    # 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.FloatField()
    payoff_for_results = models.FloatField()
    payoff_for_results_eur = models.FloatField()

    def set_payoff(self):

        # determine round_result as (potential) payoff per round
        if self.bomb:
            self.round_result = 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 = c(self.round_result)
                self.payoff_for_results = round(self.round_result, 2)
                self.payoff_for_results_eur = round(
                    self.round_result * settings.
                    SESSION_CONFIG_DEFAULTS['real_world_currency_per_point'],
                    2)
            else:
                self.pay_this_round = False
                self.payoff = c(0)
                self.payoff_for_results = 0
                self.payoff_for_results_eur = 0

        # set payoffs to round_result if <random_payoff = False>
        else:
            self.payoff = c(self.round_result)
            self.payoff_for_results = round(self.round_result, 2)
            self.payoff_for_results_eur = round(
                self.round_result * Constants.box_value_eur, 2)
Exemple #19
0
class Player(BasePlayer):

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

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

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

    def set_payoff(self):

        q = self.units
        d = self.demand

        if (q < d):
            self.payoff = Constants.price * q - Constants.cost * q
        else:
            self.payoff = Constants.price * d - Constants.cost * q
Exemple #20
0
class Player(BasePlayer):
    my_id = models.PositiveIntegerField()
    interaction_number = models.PositiveIntegerField()
    round_in_interaction = models.PositiveIntegerField()

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

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

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

    cum_payoff = models.CurrencyField()

    def get_partner(self):
        return self.get_others_in_group()[0]
Exemple #21
0
class Group(BaseGroup):
    special_number = models.IntegerField(initial=0, )

    bump_number = models.IntegerField(initial=0, )

    demand = models.PositiveIntegerField(
        choices=(1, 2, 3, 4, 5, 6, 7), widget=widgets.RadioSelectHorizontal())

    demandArray = models.CharField()

    effort = models.PositiveIntegerField(
        choices=(1, 2, 3), widget=widgets.RadioSelectHorizontal())

    effortArray = models.CharField()

    choice = models.IntegerField(choices=[
        (0, 'Special Number Higher'),
        (1, 'Effort Higher'),
    ],
                                 widget=widgets.RadioSelectHorizontal())

    choice_outcome = models.IntegerField()

    increased_choice_outcome = models.IntegerField()

    bonus = models.IntegerField(choices=[
        (0, 'No Bonus'),
        (1, 'Bonus'),
    ],
                                widget=widgets.RadioSelectHorizontal())

    gender_p1 = models.CharField()

    gender_p2 = models.CharField()
Exemple #22
0
class Player(BasePlayer):
    my_id = models.PositiveIntegerField()
    treatment = models.StringField()
    condition = models.StringField()
    A = models.IntegerField()
    interaction_number = models.PositiveIntegerField()
    round_in_interaction = models.PositiveIntegerField()
    ## role for asymmetric treatment. role=1 means endowment = 10 (B player), role=2 means endowment = 20 (A player)
    role = models.StringField()

    endowment = models.IntegerField()
    a1 = models.IntegerField(min=0, max=20)
    a2 = models.IntegerField(min=0, max=20)
    a3 = models.IntegerField(min=0, max=20)
    pie = models.FloatField()
    pie_share = models.FloatField(min=0, max=1)
    ## here we use potential_payoff to record the payoff, the real payoff will be set to 0 if a time_out happened.
    potential_payoff = models.CurrencyField()
    timed_out = models.BooleanField()
    cum_payoff = models.CurrencyField()

    partner_id = models.PositiveIntegerField()
    other_endowment = models.IntegerField()
    other_a1 = models.IntegerField(min=0, max=20)
    other_a2 = models.IntegerField(min=0, max=20)
    other_a3 = models.IntegerField(min=0, max=20)
    other_share = models.FloatField(min=0, max=1)
    other_payoff = models.CurrencyField()
    other_cum_payoff = models.CurrencyField()
    rand_num = models.PositiveIntegerField(max=200)
    successful = models.BooleanField()

    def get_partner(self):
        return self.get_others_in_group()[0]
Exemple #23
0
class Player(BasePlayer):
    def other_player(self):
        """Returns other player in group. Only valid for 2-player groups."""
        return self.get_others_in_group()[0]

    blank = models.CharField(blank=True)

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

    even_int = models.PositiveIntegerField()

    after_next_button_field = models.BooleanField()

    dynamic_choices = models.CharField()

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

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

    dynamic_min_max = models.CurrencyField()

    in_before_session_starts = models.CurrencyField()

    def role(self):
        # you can make this depend of self.id_in_group
        return ''
class Player(BasePlayer):
    startwp_timer_set = models.BooleanField(default=False)
    startwp_time = models.PositiveIntegerField()
    current_wp = models.IntegerField()
    outofthegame = models.BooleanField()
    last_correct_answer = models.IntegerField()
    tasks_attempted = models.PositiveIntegerField(initial=0)
    tasks_correct = models.PositiveIntegerField(initial=0)
Exemple #25
0
class Bid(Model):  # inherits from Django's base "Model"
    BID_CHOICES = currency_range(c(Constants.reserve_price), c(Constants.maximum_bid), c(Constants.bid_price_increment))
    round = models.PositiveIntegerField()
    bid = models.CurrencyField(choices=BID_CHOICES)
    accepted = models.PositiveIntegerField()
    pid_in_group = models.PositiveIntegerField()
    subsession_id = models.PositiveIntegerField()
    player = ForeignKey(Player)    # creates 1:m relation -> this bid was made by a certain player
Exemple #26
0
class Player(BasePlayer):
    wrong_attempts = models.PositiveIntegerField(
    )  # number of wrong attempts on understanding questions page
    treatment = models.StringField()
    condition = models.StringField()
    interaction_length = models.PositiveIntegerField()
    A = models.IntegerField()
    workerid = models.StringField()
Exemple #27
0
class Player(BasePlayer):
    interaction_number = models.PositiveIntegerField()
    round_in_interaction = models.PositiveIntegerField()
    treatment = models.StringField()
    x = models.IntegerField(min=1, max=100)
    y = models.IntegerField(min=1, max=100)
    value = models.IntegerField()
    cum_value = models.IntegerField()
    info = models.IntegerField()
Exemple #28
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
Exemple #29
0
class Player(BasePlayer):

    ## method to get questoin from CSV file questions
    def current_question(self):
        return self.session.vars['questions'][self.round_number - 1]

    def role(self):
        if self.id_in_group % 3 == 0:
            return 'roomB'
        else:
            return 'roomA'

    ## player timer. The task timer is called and initiated when the task starts
    task_timer = models.PositiveIntegerField()

    ## used to store name that is entered by the player
    name = models.StringField()

    ## Excel file with nametags - entire file : this file has a unique set of names for each letter in the alphabet
    loc = 'complex_math/nametags.xlsx'
    nametagBook = xlrd.open_workbook(loc)

    ## this variable is the nametag that the player selects. The nametag choices for this variable are determined during the game
    nametag = models.StringField()

    ## variable that stores the name that the 'chooser' selected during the team selection page
    sentNames = models.StringField()

    ## these variables store data relating to the player and selector task
    int1 = models.PositiveIntegerField()
    int2 = models.PositiveIntegerField()
    solution = models.PositiveIntegerField()
    user_total = models.PositiveIntegerField(
        min=1,
        max=9999,
        widget=widgets.TextInput(attrs={'autocomplete': 'off'}))

    task1payoff_score = models.FloatField()
    task2payoff_score = models.FloatField()
    '''
    the score_task methods are called to update a players taskpayoff score.
    there are two methods and are used for the seperate task1 and task2
    '''

    def score_task1(self):
        if self.solution == self.user_total:
            self.task1payoff_score = 1.0
        else:
            self.task1payoff_score = 0.0

    def score_task2(self):
        if self.solution == self.user_total:
            self.task2payoff_score = 1.0
        else:
            self.task2payoff_score = 0.0
Exemple #30
0
class Player(BasePlayer):
    q_stuID = models.PositiveIntegerField(
        verbose_name='What is your student ID?')

    q_age = models.PositiveIntegerField(verbose_name='What is your age?',
                                        choices=range(15, 41),
                                        initial=None)

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