oTree Forum >

players stuck on waitpage using is_displayed()

#1 by Carmen (edited )

Hello everyone,

I have an experiment consisting of several rounds, and I am trying to deal with dropped out players
There are four people per group, and in each round the 4 participants interact with each other in pairs of 2. 
A new round can only start once all four players have finished the current round. 
To synchronize players between the rounds, I use is_displayed on a waitpage after each round. 
The logic is that I compare the number of players arrived on the waitpage to the number of people still active (not dropped out). The code goes like this, where player.has_arrived is set in the before_next_page function of the previous page. 

def is_displayed(player: Player): 
    all = player.group.get_players()
    arrived = [i for i in all if i.has_arrived == True]
    active = [i for i in all if i.is_dropout == False]
    if len(arrived) < len(active):
        return True
        return False
This approach works fine as long as 4 players are active. However, once one player drops out, and has is_dropout == True it does not work anymore. 
The first player finishing the round has len(arrived) = 1 and len(active) = 3, and is waiting.
The second player finishing the round has len(arrived) = 2 and len(active) = 3, and is waiting.
The third player finishing the round has len(arrived) = 3 and len(active) = 3 and advances to the next round. 
The first and second player, however, are stuck on the waitpage. Once I manually refresh the page, they advance.

I do not understand why the waitpage does not refresh for the first and second player when one player is dropped out. Does anyone have solution for this? Thanks in advance.

#2 by davidlucius

Hi Carmen,

The first two players are waiting until ALL players in their group have arrived. But since the fourth player never arrives, they get stuck on the waiting page. (The is_displayed method is only executed once for each player when they come to the waiting page. The page does not automatically reload for the waiting players when another player arrives.)

The best way I know to fix this problem is the following: Send the dropped players to the very end of your experiment so no one has to wait for them anymore. This can be done with the app_after_this_page method:

def app_after_this_page(player, upcoming_apps):
    if player.is_dropout:
        return upcoming_apps[-1] # Sending the player to the last app
Of course, if there is no upcoming app in your experiment, you still have to create one.

Write a reply

Set forum username