#1 by boma
I program an experiment in oTree studio. My experiment has 30 subjects in one session. At the beginning of this session, these 30 subjects have to be matched into 5 groups (so 6 subjects per group). Subjects stay in their respective group for the whole session. After some introduction slides, they play a game for 60 rounds. This game is a competition between 2 subjects. Meaning that 2 subjects within their matching group of 6 subjects play against each other. It has to be randomly determined which subjects pair together. In every round, the pairing of subjects is randomly done again. This question was asked in a similar way before, but I still did not figure it out how to do it for my case. So thank you very much for your help!
#2 by woodsd42
I don't know what you have access to in studio, but perhaps something like this would work: def creating_session(subsession: Subsession): # set matching group if subsession.round_number == 1: subsession.group_randomly() else: subsession.group_like_round(1) # set pairs within matching group import random for group in subsession.get_groups(): subject_ids = group.get_players() random.shuffle(subject_ids) group.set_players(subject_ids) Then I would set pairs based on player.id_in_group - so id_in_group 1 is paired with id_in_group 2, 3 with 4 and so on (if id_in_group % 2 == 0 then their partner is id_in_group-1, else id_in_group + 1). This should work as you randomly shuffle who has what id_in_group every period with get_ and set_players(). However, I haven't tested this at all, nor have I ever used get_ and set_players(), so they may not function as I think they do. I also don't know where this should go in studio, and can't provide further support on the above code. It should be enough to get you started though.