from . import pages from ._builtin import Bot import random from otree.api import Submission from .models import Constants class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield (pages.WelcomeTime) if self.round_number <= Constants.intertemporal_rounds: yield (pages.Intertemporal, {'choice_time': random.choice(['A', 'B'])}) if self.round_number == Constants.intertemporal_rounds + Constants.cons_choice_rounds + 1: yield (pages.WelcomeRisk) if self.round_number > Constants.intertemporal_rounds + Constants.cons_choice_rounds: yield (pages.Risk, {'choice_risk': random.choice(['A', 'B'])}) if Constants.intertemporal_rounds < self.round_number <= Constants.intertemporal_rounds + Constants.cons_choice_rounds: yield (pages.Wine, {'choice_wine': random.choice(['A', 'B'])}) yield Submission(pages.Wait, check_html=False) if self.round_number == Constants.num_rounds: yield (pages.Control, { 'control_time': random.randint(0, 100), 'control_probability': random.randint(0, 100), 'control_variable': random.randint(0, 100) })