oTree Forum >

How to assign treatments to different groups in a game with multiple rounds

#1 by yogu

Hello Otree-Community,

According to the documents, when I would like to assign treatments to different players in a game with multiple rounds, this code will work:
https://otree.readthedocs.io/en/latest/treatments.html
``` 
def creating_session(subsession):
    if subsession.round_number == 1:
        for player in subsession.get_players():
            participant = player.participant
            participant.time_pressure = random.choice([True, False])
```
However, when I would like to assign treatments to different groups, How can I modify the code? When I simply replaced "player" with "group" in the above code, it returned an error: "AttributeError: 'Group' object has no attribute 'participant'".
I would appreciate any information you could give me to help shed some light on the matter.

Write a reply

Set forum username