import random from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants class PlayerBot(Bot): def play_round(self): if self.round_number == 1 or self.round_number == 7: yield pages.Situation choices = { 'QuestionA': { 'Act3': random.choice(Constants.likely_choices)[0], 'Act4': random.choice(Constants.safe_choices)[0], }, 'QuestionB': { 'Act1': random.choice(Constants.likely_choices)[0], 'Act2': random.choice(Constants.safe_choices)[0], }, 'QuestionC': { 'Act5': random.choice(Constants.safe_choices)[0], 'Act6': random.choice(Constants.safe_choices)[0], 'Act7': random.choice(Constants.safe_choices)[0], 'Act8': random.choice(Constants.safe_choices)[0], }, 'QuestionD': { 'Act9': random.choice(Constants.effective_choices)[0], 'Act10': random.choice(Constants.effective_choices)[0], }, } for page_name, form_fields in choices.items(): yield getattr(pages, page_name), form_fields if self.round_number == 1 and self.participant.vars['f_news']: yield pages.HeadLine1, { 'Plausibility': random.choice(Constants.likely_choices)[0], 'Familiarity': random.choice(Constants.familiarity_choices)[0], } elif self.participant.vars['f_news']: headline_pages = [ None, pages.HeadLine2, pages.HeadLine3, pages.HeadLine4, pages.HeadLine5, pages.HeadLine6, ] if self.round_number <= len(headline_pages): yield headline_pages[self.round_number-1], { 'Plausibility': random.choice(Constants.likely_choices)[0], 'Familiarity': random.choice(Constants.familiarity_choices)[0], } # headline_pages = [ # # pages.HeadLine2, # pages.HeadLine3, # pages.HeadLine4, # pages.HeadLine5, # pages.HeadLine6, # ] # round_number = self.round_number # if 2 <= round_number <= len(headline_pages) + 1: # yield headline_pages[round_number - 2], { # 'Plausibility': random.choice(Constants.likely_choices)[0], # 'Familiarity': random.choice(Constants.familiarity_choices)[0], # }