"""Bots: team sessions yield Chat and Wait3; S1 (or is_single) skip those. Manual smoke: run devserver with session config name `ai_and_team_single` or set `treatment='S1'` and `num_demo_participants=1` in settings. """ from otree.api import Bot from intro import treatment_is_single from . import * def _bot_is_single(player): if player.participant.vars.get('is_single'): return True return treatment_is_single(player.participant.treatment or '') class PlayerBot(Bot): def get_accurate_prediction(self): return int(get_current_round_data(self.player)['x2txmthPCT']) def play_round(self): total_error = 40 error = total_error // C.NUM_ROUNDS prediction = self.get_accurate_prediction() if prediction + error > 100: prediction = prediction - error elif prediction - error < 0: prediction = prediction + error else: prediction = prediction + error yield Private, dict(private_prediction=prediction) yield Disclosure, dict(shared_prediction=prediction) if not _bot_is_single(self.player): yield Chat yield Team, dict(team_prediction=prediction) if not _bot_is_single(self.player): yield Wait3 yield Result