oTree Forum >

Randomly Assigning Roles Each Round

#1 by HenryMorgan


Say I had a single group of six players, and six unique roles(_ROLE) in the constants section. Is there a way to reassign these roles randomly each round? 

Best and Thank You

#2 by coralio

If, as you say, there is a SINGLE group of n people in the session, with n unique roles, just shuffle session players in each round:

def creating_session(subsession):

#3 by HenryMorgan

Im still very new to oTree, where should this code be placed to shuffle players once they start the game. 

Again, thank you for the advice.

#4 by coralio ,

For instance, look at the sample matching pennies code here: https://github.com/oTree-org/oTree/blob/lite/matching_pennies/__init__.py
There are many other examples in the github repo.

Write a reply

Set forum username