Session X - Matching
IMPRS Be Smart Summer School
2023-08-09
class C(BaseConstants):
NAME_IN_URL = 'pgg'
PLAYERS_PER_GROUP = 3
NUM_ROUNDS = 1
ENDOWMENT = cu(1000)
MULTIPLIER = 2
player
, group
and subsession
will have the attribute round_number
.
player.round_number
For each round, there will be a separate player
object for each participant and a group
object for each group.
For each participant, participant
object connects players.
player.variable_name
written in the previous rounds will not be accessible
player.in_round(n)
brings the player object of a participant at a given round def vars_for_template(player):
if player.round_number > 1:
previous_player = player.in_round(player.round_number - 1)
previous_sent_amount = previous_player.group.sent_amount
previous_returned_amount = previous_player.group.returned_amount
return dict(prev_sent = previous_sent_amount,
prev_return = previous_returned_amount)
player.in_previous_rounds()
: Returns a list of all player objects of the same participant from the previous rounds
player.in_all_rounds()
: Returns a list of all player objects of the same participant from the previous round + the current round
player.in_rounds(m, n)
Returns a list of players of the same participants from rounds m to n.
subsession
class.subsession
function, creating_session
can be created to monitor/modify this process.subsession.get_group_matrix()
shows the matching as a list of list.
id_in_group
) are fixed, groups are fixed.# Shuffle only in round 1 and 3, keep the grouping otherwise
def creating_session(subsession):
if subsession.round_number in [1,3]:
subsession.group_randomly()
else:
subsession.group_like_round(subsession.round_number -1)
## GROUPS
# [[5, 2], [3, 6], [4, 1]]
# [[5, 2], [3, 6], [4, 1]]
# [[2, 4], [6, 5], [1, 3]]
# [[2, 4], [6, 5], [1, 3]]
group_by_arrival_time
is a built-in function that does this.WaitPage
class attribute.WaitPage
and it is the first page of the app.SESSION_CONFIGS = [
dict(
name='trust',
app_sequence=['consent', 'trust', 'timeout'],
num_demo_participants=2,
real_world_currency_per_point= 0.25,
participation_fee = 3,
),
]
before_next_page
is another special function defined in pages.player
object and timeout_happend
class Consent(Page):
timeout_seconds = 30
def before_next_page(player, timeout_happened):
if timeout_happened:
player.timed_out = True
def app_after_this_page(player, upcoming_apps):
if player.timed_out:
return "timeout"