from . import pages from ._builtin import Bot from otree.api import Submission import random from .models import Constants class PlayerBot(Bot): def play_round(self): if self.subsession.round_number == 1: yield (pages.Welcome) yield (pages.Consent) yield (pages.Instructions) yield (pages.Machine) yield (pages.Example) yield Submission(pages.WaitExample, check_html=False) if self.player.set_type() == 'baseline': yield (pages.BallsUrns, { 'answer': random.randint(1, 100), 'wtp': round(random.uniform(0, 3), 2), 'difficulty': random.randint(1, 7) }) if self.player.set_type() == 'sequential': yield (pages.BallsUrnsSequential, { 'answer': random.randint(1, 100), 'answer2': random.randint(1, 100), 'wtp': round(random.uniform(0, 3), 2), 'difficulty': random.randint(1, 7) }) yield Submission(pages.Wait, check_html=False) if self.subsession.round_number == Constants.num_rounds: yield (pages.Goodbye)