oTree Forum >

Calculation of total payoffs excluding practice rounds

#1 by akram

Hi,

I have designed the app sequence and calculated the total_payoffs of the participants by summing individual payoffs of each round excluding the practice rounds. The total_payoffs variable stores the values and displays the values perfectly at the end of the game to the participants, however, when I see the admin side, the payment information and total payoff for all the rounds include the practice round payoffs as well. Is there a simple way through which I can simply use total_payoffs and otree calculates on admin side the payment information based on this variable?

Thanks,

#2 by BonnEconLab

I sounds as if (a) you are using oTree’s built-in field player.payoff, and (b) the practice rounds are also rounds in the oTree sense.

Under this assumption, including the following in the class for the last page that is shown during the practice rounds should work:

    @staticmethod
    def before_next_page(player, timeout_happened):
        if player.round_number <= [* INSERT YOUR NUMBER OF PRACTICE ROUNDS *]:
            player.payoff = 0
            
If your practice rounds are coded in a separate app, you can skip the condition that checks the round number:

    @staticmethod
    def before_next_page(player, timeout_happened):
        player.payoff = 0

#3 by akram

Thanks for the help. I still have an issue. Although the above code works, but in latter case, i.e. if I implement this code:

@staticmethod
    def before_next_page(player, timeout_happened):
        player.payoff = 0
        
it eliminates all the payoffs for both practice rounds successfully. However, I want participants to see their previous payoff of the round, but this makes them zero as well. 

On the other hand, If I use the former code:   

        @staticmethod
    def before_next_page(player, timeout_happened):
        if player.round_number <= [* INSERT YOUR NUMBER OF PRACTICE ROUNDS *]:
            player.payoff = 0
            
it works fine and shows the correct payoff of the first round to the participants, but it only eliminates the payoff of the second round and keeps the first round payoff on the admin side payment information. 

Is there a simple way around this? 

Thanks for the help again.

#4 by BonnEconLab

@akram wrote,

> However, I want participants to see their previous payoff of the round, but this makes them zero as well.

In this case, I would suggest that you set

    @staticmethod
    def before_next_page(player, timeout_happened):
        if player.round_number == [* INSERT YOUR NUMBER OF PRACTICE ROUNDS *]:
            for r in range(1, [* INSERT YOUR NUMBER OF PRACTICE ROUNDS *] + 1):
                player.in_round(r).payoff = 0

at a place so that it is executed only after participants have been informed of their (hypothetical) earnings for the practice rounds.

See https://otree.readthedocs.io/en/latest/rounds.html.

#5 by akram

Thanks for your help. It works perfectly now!!

Write a reply

Set forum username