from otree.api import Bot, Submission from extdef import N_ROUNDS_PER_BLOCK from . import C, Instructions, BlockIntro, Decision, Results, FinalResults, _round_values class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield Instructions if (self.round_number - 1) % N_ROUNDS_PER_BLOCK == 0: yield BlockIntro _, _, _, ideal_point, policy_A, policy_B = _round_values(self.player) vote = 'A' if abs(policy_A - ideal_point) <= abs(policy_B - ideal_point) else 'B' yield Submission(Decision, dict(vote=vote)) yield Results if self.round_number == C.NUM_ROUNDS: yield FinalResults