#
from otree.api import Currency as c
from otree.constants import BaseConstants
#
# ******************************************************************************************************************** #
# *** CLASS CONSTANTS *** #
# ******************************************************************************************************************** #
class Constants(BaseConstants):
# ---------------------------------------------------------------------------------------------------------------- #
# --- Task-specific Settings --- #
# ---------------------------------------------------------------------------------------------------------------- #
# number of binary choices between "lottery A" and "lottery B"
# note that the number of choices determines the probabilities of high and low outcomes of lotteries "A" and "B"
# for , the probability of outcome "high" is 1/X for the first choice, 2/X for the second, etc.
num_choices = 4
# ---------------------------------------------------------------------------------------------------------------- #
# --- Overall Settings and Appearance --- #
# ---------------------------------------------------------------------------------------------------------------- #
# depict probabilities as percentage numbers
# if , the probability of outcome "high" will be displayed as percentage number
# if , the probabilities will be displayed as fractions, i.e. "1/X", "2/X", etc.
percentage = True
# include 'certain' choice (** only applies if **)
# if , the binary choice with probability of the outcome "high" being equal to 1 is included
# if , the list only contains ( - 1) binary decision pairs
# note, however, that the probability of outcome "high" is set by , not ( - 1), though
# i.e., if , the last choice implies a probability of (X - 1)/X (given )
certain_choice = True
# show instructions page
# if , a separate template "Results_New.html" is rendered prior to the task
# if , the task starts immediately (e.g. in case of printed instructions)
instructions = True
# show results page summarizing the task's outcome including payoff information
# if , a separate page containing all relevant information is displayed after finishing the task
# if , the template "Decision.html" will not be rendered
results = True
# ---------------------------------------------------------------------------------------------------------------- #
# --- oTree Settings (Don't Modify) --- #
# ---------------------------------------------------------------------------------------------------------------- #
name_in_url = 'Multiple_Price_List'
players_per_group = None
num_rounds = 4
# ---------------------------------------------------------------------------------------------------------------- #
# --- Own Adjustments --- #
# ---------------------------------------------------------------------------------------------------------------- #
# lottery payoffs
# "high" and "low" outcomes (in currency units set in settings.py) of "lottery A" and "lottery B"
# note that payoffs are identical for all choices and only probabilities of "high" and "low" outcomes change
# create index for all 20 mpl lists
mpl_index = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
# create list with all high probability values for all 20 lists
mpl_prob_hi = [.1, .5, .9, .05, .25, .5, .75, .95, .05, .1, .25, .5, .75, .95, .05, .5, .5, .05, .95, .25]
# create list with all high outcome values (x1) for all 20 lists
mpl_lottery_hi = [20, 20, 20, 40, 40, 40, 40, 40, 50, 150, 50, 50, 50, 50, 150, 10, 20, 40, 50, 40]
# create list with all low outcome values (x2) for all 20 lists
mpl_lottery_lo = [10, 10, 10, 10, 10, 10, 10, 10, 20, 0, 20, 20, 20, 20, 50, 0, 0, 0, 0, 0]
# create 20 mpls
mpl = []
for (i, p, h, l) in zip(mpl_index, mpl_prob_hi, mpl_lottery_hi, mpl_lottery_lo): #the zipping ensures, that that we are looping over every xth item from each list at the same time
mpl_list = (i, p, h, l)
mpl.append(mpl_list)
lottery_a_hi = 10
lottery_a_lo = 2
cert_equi = 10
#for option B outcomes see below
#lotteryvars_for_template = 3
#lottery_b_lo = 1
probability_hi = .75
probability_lo = 1-probability_hi
#Create Optopn B values
#1. create index
step = (lottery_a_hi - lottery_a_lo) / num_choices #calculates step interval for option b alternatives such that
# the whole outcome range from the highest to the lowest outcome is covered.
indices = [j for j in range(1, num_choices)]
indices.append(num_choices) if certain_choice else None
#2. create values
option_b = []
for k in indices:
value = cert_equi - step * (k - 1)
option_b.append(value)
option_b = [c(i) for i in option_b] # turns every item in the list into a currency variable
# ---------------------------------------------------------------------------------------------------------------- #
# Irrelevant variables
# show each lottery pair on a separate page
# if , each single binary choice between lottery "A" and "B" is shown on a separate page
# if , all choices are displayed in a table on one page
one_choice_per_page = False
# order choices between lottery pairs randomly
# if , the ordering of binary decisions is randomized for display
# if , binary choices are listed in ascending order of the probability of the "high" outcome
random_order = False
# enforce consistency, i.e. only allow for a single switching point
# if , all options "A" above a selected option "A" are automatically selected
# similarly, all options "B" below a selected option "B" are automatically checked, implying consistent choices
# note that is only implemented if and
enforce_consistency = False
# show small pie charts for each lottery
# if , a pie chart depicting the probabilities of outcomes is rendered next to each lottery
# if , no graphical representation of probabilities is displayed
small_pies = False
# display lotteries in terms of large pie charts
# if , lotteries are depicted as pie charts; if lotteries are list items
# note that only affects the task's appearance if
large_pies = True
# show progress bar
# if and , a progress bar is rendered
# if , no information with respect to the advance within the task is displayed
# the progress bar graphically depicts the advance within the task in terms of how many decision have been made
# further, information in terms of "page x out of " (with x denoting the current choice) is provided
progress_bar = True