from otree.api import Currency as c, currency_range, SubmissionMustFail, Submission from .pages import * from ._builtin import Bot from .models import Constants from string import ascii_letters import random from colorama import Fore, Back, Style class PlayerBot(Bot): def play_round(self): print(Back.BLUE + Fore.YELLOW + 'round:: ' + str(self.round_number)) yield Intro yield Consent yield Instructions yield CQ for i in self.player.tasks.filter(practice=True, answer__isnull=True): yield Practice, {'answer': i.correct_answer} reallocation_answer_keys = [f'reallocation_tax{i}' for i in range(1, 4)] reallocation_answer_choices = [random.choice([False, True]) for _ in range(1, 4)] print(reallocation_answer_choices) reallocation_answers = dict(zip(reallocation_answer_keys, reallocation_answer_choices)) yield Submission(Reallocation, reallocation_answers, check_html=False) for i in self.player.tasks.filter(practice=False, answer__isnull=True): yield Task, {'answer': i.correct_answer} yield Results