Earlier this week I posted a question regarding the random mechanism, it hasn't got fixed yet. Here is the updated idea:
* I need ONE leader and FOUR followers per group.
1. on the player page:
def roles (player):
import random
random_value = random.sample(range(0,5), 5)
if player.random_value == 1:
return 'Leader'
else:
return 'follower'
roles = models.StringField()
random_value = models.IntergerField()
But it doesn't work, I tried to get player.random_value, it is none, so I think at the first step, the "random value" is not given to the "players". So where should I "import random"?
Or anyone have any better idea to assign the role by random mechanism? I think the built in function assign by id, which is not that random as I wanted.
Thank you so much!
Shaorong