I'm working on my first otree project and I'm pretty overwelmed by everything that goes beyond the easy survey stuff..
I have one input page where the player has to decide on how much points he would like to invest. The amount of points he invests is supposed to influence the probability to get a payoff. My input variable:
points = models.IntegerField(
label="<b>How many points would you like to invest?</b>",
choices=[
[0, "None"],
[1, "1 point"],
[2, "2 points"],
[3, "3 points"]])
What I need now is a payoff page where a random generator decides if the player has won or not. Probability distribution is supposed to be as follows:
- If the player invested 0, he has a chance of (1+0)/10 to win
- If the player invested 1, he has a chance of (1+1)/10 to win
- If the player invested 2, he has a chance of (1+2)/10 to win
- If the player invested 3, he has a chance of (1+3)/10 to win
On this payoff page it is supposed to say "You have rolled the number [x]. That means you have [won, lost]."
The only thing I could find online was this python-related information: https://www.kite.com/python/answers/how-to-sample-a-random-number-from-a-probability-distribution-in-python but I didn't get it to work with otree..
What code do I have to put where to get this to work?
Aucun commentaire:
Enregistrer un commentaire