from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants import random class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield (pages.Instructions0) yield (pages.Instructions1) yield (pages.Instructions2) yield (pages.Instructions3) yield (pages.Instructions4) yield (pages.ControlQuestions, {'cq1': 0, 'cq2': 3, 'cq3': 2, 'cq4': 3}) yield (pages.Introduction) if self.round_number >= 1: submitted_answer = random.choice(['Yes','No']) yield (pages.Question, {'submitted_answer': submitted_answer}) if self.round_number == Constants.num_rounds: yield (pages.WaitPage1) yield (pages.Results) yield pages.Questions1, {'demand': 'no idea', 'difficulty': random.randint(1, 4), 'problems': random.randint(0, 1), 'problems2': 'none', 'explain': 'out of hand'} yield pages.Questions2, {'fairness1': random.randint(0, 1), 'fairness2': random.randint(0, 1), 'fairness3': random.randint(0, 1), 'legitimacy': random.randint(0, 1), 'fair_payment': random.randint(0, 1), 'closeness': random.randint(1, 4), 'closeness1': random.randint(0, 1), 'closeness2': random.randint(0, 1)} if self.participant.vars['game_to_pay'] == 1 and self.round_number == Constants.num_rounds: yield pages.LotteryResults if self.participant.vars['game_to_pay'] == 2 and self.round_number == Constants.num_rounds: yield pages.IneqResults if self.participant.vars['game_to_pay'] == 3 and self.round_number == Constants.num_rounds: yield pages.LotteryResults2 if self.round_number == Constants.num_rounds: yield pages.Results0