Setting payoff without WaitPage

385 views
Skip to first unread message

Max R. P. Grossmann

unread,
Jun 4, 2021, 3:08:42 AM6/4/21
to ot...@googlegroups.com
Hi all,

What is the preferred method to set payoffs without a WaitPage? (E.g., in completely individual experiments without interactions that could necessitate a WaitPage.)

I tried calling my set_payoff function using after_all_players_arrive in a "phantom" WaitPage with players_per_group = 1. However, this is not allowed…

Optimally, I would like to set payoffs "on" my results page --- this is because I have a consent app which essentially all pages in the main app if a subject opts out except for the results page. But I still want to pay people who opt out, so the results page should sort of calculate the payoffs.

Thanks,

Max

Chris @ oTree

unread,
Jun 4, 2021, 3:09:39 AM6/4/21
to oTree help & discussion
before_next_page

Oguzhan Okumus

unread,
Aug 18, 2021, 6:15:32 AM8/18/21
to oTree help & discussion
Hey, I have a follow-up question: How can I run an already defined function at a group level under before_next_page?

My code is as follows:

def set_payoffs(group: Group):
players = group.get_players()
for p in players:
p.payoff = Constants.showup + p.participant.firstpayoff + p.participant.secondpayoff

class Payoffs(Page):
def before_next_page(player:Player, timeout_happened):
player.set_payoffs()

But it does not work. I appreciate your help, thank you!
Oguzhan

Chris @ oTree

unread,
Aug 18, 2021, 6:25:35 AM8/18/21
to oTree help & discussion
def before_next_page(player, timeout_happened):
  set_payoffs(player)

But set_payoffs needs to be a player function. Here you have defined it as  a group function.

Peter Cock

unread,
Aug 18, 2021, 6:26:17 AM8/18/21
to oTree help & discussion
I'm not quite sure what you are trying to do, but believe oTree will automatically keep track of the player's payoffs and give you the running total as participant.payoff, so this may not be necessary:

https://otree.readthedocs.io/en/latest/currency.html#payoffs

Also, I think the built in participation_fee under settings may cover your usage of Constants.showup? See:
  • participant.payoff_in_real_world_currency
  • participant.payoff_plus_participation_fee
  • session.config.participation_fee
Reply all
Reply to author
Forward
0 new messages