oTree Forum >

Random allocation of players into groups

#1 by Anwesha

Hi there,

Hope you are well. I have a group treatment in which I randomly allocate players into groups. I am a bit worried about the codes I have. Can I use itertools.cycle along with group_randomly()? Unfortunately, my Uni doesn't have a lab and I am unable to open multiple links in my laptop to check if the code works the way I want it to. My code is mentioned below:

class Subsession(BaseSubsession):
    def creating_session(self):
        import itertools
        pressures = itertools.cycle([True, False])
        for player in self.get_players():
            player.time_pressure = next(pressures)
        self.group_randomly()

#2 by Fanist

For test, you can just open other links in your phone or tablet, and make sure the devices are in the same wifi.

#3 by Anwesha

Thank you so much.

Write a reply

Set forum username