oTree Forum >

How to assign two roles to a 8-player group? And, how to shuffle the roles within the group?

#1 by llinfeng

Does the number of `_ROLE` constants needs to match with the number of players per group? Per [this attempt](https://github.com/UMBEE/modified-otree-snippets/blob/master/AssignRole/__init__.py), in groups of 8, only 2 players has `player.role`. All others were missing.

Also, a pointer to a working example of `subsession.group_randomly()` is much appreciated!

#2 by Chris_oTree

_ROLE is for simple role assignments where each person has a different role. If you want something more complex, make your own field called my_role etc.

#3 by llinfeng

Thanks a lot for the clarification!

Quickly, is there a searchable archive of code, say, from the Public projects? Or, one should self-serve and build a searchable code archive by downloading all attachments using the Download link?

Write a reply

Set forum username