oTree Forum >

Forced time on waitpage

#1 by ahallman

Hi! 

I want to make playing against bots as life-like as possible. Hence, the subjects should see a waitpage for a minimum time (say, 20 seconds) whenever they play against bots. I hence created the usual HTML5-page and made it look like a waitpage, and used timeout to make them progress to the next page after a certain amount of time. However, they never get to the next page. 

Time-outs work on the other pages with the same code. I tried including a 'next'-button on the page, but nothing happens if i click on it. Playing against bots (ghosts) works fine otherwise, I'm just trying to avoid the 'p1 makes a decision and is immediately forwarded to the results-page' as it's the obvious that it was against a bot. 

Code below: 

session config: 
SESSION_CONFIGS = [dict(name='my_session',
                        ... the usual .. 
                    slowbot_timeout_seconds = 30,
                    )]

init: 

class slowbots_page(Page):
    @staticmethod
    def get_timeout_seconds(player):
        return player.session.config["slowbot_timeout_seconds"]
    form_model = "player"
    @staticmethod
    def is_displayed(player: Player):
        if player.participant.dropout:
            return False
        return player.against_ghost == True
page_sequence = [
    Set_state_page,
    P1_pages,
    slowbots_page,
    P2_pages,
    ResultsWaitPage,
    Results,
]

HTML: slowbots_page.html
{{ extends 'otree/WaitPage.html' }}

{{ block title }}
Please wait
{{ endblock }}
{{ block content }}
    <script>
        setInterval(function () {
            window.location.reload();
        }, 10000);

    </script>

    <p>
        You are waiting for a player in your group to make their decisions. 
    </p> 
    
{{ endblock }}

#2 by Chris_oTree

Take a look at bots_vs_humans here: https://www.otreehub.com/projects/otree-more-demos/

A regular page cannot use the WaitPage template. That's probably why the next-button or timeout isn't working.

#3 by ahallman

Thank you!!!

Write a reply

Set forum username