oTree Forum >

How to display cumulative payoffs

#1 by AngelVJimenez

I am programming an experiment with OTree Studio. 
In my experiment, participants have to the decision to produce an innovation or not over repeated rounds. 
If the decide to innovate, they incur in a payoff benefit of £0.20 but they pay the cost of £0.10 from their innovation too. 
I have defined innovation at the player’s field: 
INNOVATION = models.BooleanField(label="Do you want to innovate at this round?", choices=[[true,"Yes"],[false,"No"]])
And creater a function to calculate the payoff. 
def set_payoffs(player):
if player.INNOVATION:
       player.payoff += C.BENEFIT - C.COST
else:
        player.payoff += 0
I want to inform participants of their cumulative payoff at the end of each round. How can I do this? 
The Payments tab calculates the cumulative payoffs correctly, but I do not manage to have a working cumulative payoffs variable that works at each round. 
Could you help? 
Thank you

#2 by ccrabbe

Hi Angel -

In oTree, every Player object is an instance of a Participant in one round, i.e. every Participant has many associated Player objects, and likewise every Player is associated with one Participant.  

The cumulative payoffs for a Participant are kept in the participant.payoff variable.  So you can access those from any template with {{ participant.payoff }}

Thanks,
--Chris

#3 by AngelVJimenez

Thank you Chris. 

I have managed to solve it :)

Best, 

Angel

Write a reply

Set forum username