oTree Forum >

matching -- conditions, roles, apps

#1 by anna_s

Hi team, 

I came up with quite a confusing experiment and am now not sure how to match everyone. 

It is a multiplayer interactive sender receiver game, where the participants are randomly assigned one of the roles -- sender and receiver. They play 10 one-shot rounds, where they're randomly rematched with a different participant from the group. There are 6 treatment groups.

My issue is that I need the participants to 1) first be sorted into a treatment group 2) then get their role assignment 3) then only interact with the participants who are in the same treatment group.

I thought the easiest way (not the most elegant, of course) would be to create 6 apps for each treatment, assign participants to their treatment group, and then use app_after_this_page to sort them, like this:


def creating_session(subsession):
    import itertools
    conditions = itertools.cycle(['Treat1', 'Treat2','Treat3','Treat4','Treat5', 'Treat6'])
    for player in subsession.get_players():
        player.treatment = next(conditions)
        print('set treatment to', player.treatment)

class ProlificID(Page):
    form_model = 'player'
    form_fields = ['P_ID']

    def is_displayed(player: Player):
        return player.consent_accepted == 1

    def app_after_this_page(player: Player, upcoming_apps):
        if player.treatment == 'Treat1':
            return 'Treat1'
        if player.treatment == 'Treat2':
            return 'Treat2'
        if player.treatment == 'Treat3':
            return 'Treat3'
        if player.treatment == 'Treat4':
            return 'Treat4'
        if player.treatment == 'Treat5':
            return 'Treat5'
        if player.treatment == 'Treat6':
            return 'Treat6'

and then in each treatment app I define:
def creating_session(subsession:Subsession):
    subsession.group_randomly(fixed_id_in_group=True)

However, when I create a session with say 12 participants, they still interact with participants from other treatments -- I'm not sure how this is happening, but is there any way to ensure that I can a) assign treatments to different participants and make sure that they interact only with people who have the same treatment?

Thanks a ton!
Anna

#2 by Chris_oTree

I don’t see the need for 6 apps. Just split the players into 6 groups using set_group_matrix. And then do a for loop through the groups to assign a different treatment parameter.

Write a reply

Set forum username