#1 by GregorFHSU
Hello everybody,
I tried to implement bots in my survey but I failed and don´t know how. I have another survey with the same tests.py code and it´s working fine.
My Bot-code:
class PlayerBot(Bot):
def play_round(self):
yield EXP
if self.player.group.treatment:
yield UnitsMix, dict(units=random.choice([0, 10])
)
else:
yield UnitsStraight, dict(units=random.choice([0, 10])
)
def app_after_this_page(self, upcoming_apps):
return 'INFO'
My init.py Code
class EXP(Page):
form_model = 'player'
@staticmethod
def before_next_page(player: Player, timeout_happened):
#if (player.id_in_group % 2) == 0:
if (player.group.id_in_subsession % 2) == 0:
player.group.treatment = True
else:
player.group.treatment = False
My warning if I try it:
TypeError: group.treatment is None. Accessing a null field is generally considered an error. Or, if this is intentional, use field_maybe_none()
There are no problems if I try it myself but I need the bots to test my app in a proper way.
Thank you all in advance,
Gregor