from otree.api import Bot, Submission from . import * import random class PlayerBot(Bot): def play_round(self): round_info = self.participant.vars['RoundDict'][self.round_number] # Round 1 if self.round_number == 1: yield Introduction yield Submission( InstructionsChoice, dict( test_1=1, test_2=1, test_3=1, ), check_html=False, ) yield Submission( InstructionsMenu, dict( test_4=1, ), check_html=False, ) if self.player.field_maybe_none("test_tries") is not None and self.player.test_tries >= 2: yield kicked return yield StartTask # Block transition page if self.round_number != 1 and self.round_number != C.NUM_ROUNDS: prev_round_info = self.participant.vars['RoundDict'][self.round_number - 1] if round_info['type'] == 'main' and prev_round_info['type'] == 'practice': yield PayoffRelevant # Main task pages if self.round_number != C.NUM_ROUNDS: yield Submission( Menu, dict(menu=random.choice(['negative', 'positive'])), check_html=False, ) yield Submission( Choice, dict(choice=random.choice(['A', 'B'])), check_html=False, ) if round_info['feedback'] == 1: yield Feedback # Final-round questionnaire pages if self.round_number == C.NUM_ROUNDS: yield StartSurvey yield Submission( Cognitive2, dict( Crt_barrel=24, Crt_student=5, Crt_pig=9, Crt_simon=1, Know2=0, ), check_html=False, ) yield Submission( Demographics, dict( age=30, gender='Male', education='Master’s degree', country='Austria', employment='Student', income='Prefer not to say', ), check_html=False, ) if round_info['feedback'] == 1: yield Feedback # yield End