oTree Forum >

accessing player method from group class

#1 by wlucy


I am computing group payoffs on the wait page:

class ResultsWaitPage(WaitPage):
    def is_displayed(self):
        return self.round_number == Constants.num_rounds

    def after_all_players_arrive(self):
In the set_payoffs() function I can only use methods of the group object. I would like to access a player object (namely, get_others_in_group()) through the set_payoffs function. Using the get_others_in_group() method allows me to compute payoffs of the players. 

Can you please help? Thank you in advance.

#2 by Daniel_Frey

You can get all players of the group in your set_payoffs() function with:

all_players = group.get_players() # returns a list of all players in the group. There maybe is a 'self' missing, I use the latest no-self oTree-format

for player in all_players:
    # your player-functions go here, this will be executed for each player in the group
Hope that helps!

Write a reply

Set forum username