Hi everyone,
I'm trying to write bots for my app, but run into two issues:
* There are pages whose execution depends on a few constants. They work fine when I'm testing the app by myself, but when I try running bots with the same if statements, I get an error message that the bot expected to be on another page.
* How can I define dead-ends for bots? (e.g., some participants are screened out because of full quotas or wrong answers to attention checks, so I want bots simulating those participants to remain on pages that don't have a next button)
Best,
Inbal
Hi everyone,
I'm trying to write bots for my app, but run into two issues:
* There are pages whose execution depends on a few constants. They work fine when I'm testing the app by myself, but when I try running bots with the same if statements, I get an error message that the bot expected to be on another page.
* How can I define dead-ends for bots? (e.g., some participants are screened out because of full quotas or wrong answers to attention checks, so I want bots simulating those participants to remain on pages that don't have a next button)
Best,
Inbal
Thanks Chris!
Sure.
On pages I have:
So in tests I define accordingly:
# Policy Choice No Social Info
if self.player.is_policy_choice == 1
and (Constants.pre_survey
== True or self.player.is_control == True):
my_policy_choice = random.randint(0,1)
yield
Submission(pages.Policy_Choice_No_Social_Info,
dict(policy_choice=my_policy_choice),
check_html=False) # this disables the HTML check on the page, as there is a button
added dynamically with JavaScript
# Policy Choice:
if self.player.is_policy_choice == 1
and Constants.pre_survey
== False and self.player.is_control == False:
my_policy_choice = random.randint(0, 1)
yield
Submission(pages.Policy_Choice_No_Social_Info,
dict(policy_choice=my_policy_choice),
check_html=False) # this disables the HTML check on the page, as there is a button
added dynamically with JavaScript
Thank you!
Best,
Inbal
Thank you, Chris!!
Another question: I want to allow a bot to respond with None to a form field, so I tried:
if self.player.is_policy_choice == 0 and self.round_number == self.participant.vars['task_choice_round_indices'][0]:
my_attention_a = random.randint(0, 7)
my_attention_b = ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=3))
if self.player.id_in_group == 2:
# testing several cases of wrong answers to attention checks
attention_a = {
'wrong_random_number': my_attention_a,
'blank': None
}[self.case]
attention_b = {
'wrong_random_string': my_attention_b,
'blank': None
}[self.case]
yield pages.Part_B, dict(attention_check_a=attention_a, attention_check_b=attention_b)
elif self.player.id_in_group > 2:
yield pages.Part_B, dict(attention_check_a=None, attention_check_b="כן")
But that gives me a "KeyError None" message for the bot whose id_in_group is 2.
How can I solve this?
Best,
Inbal
--
You received this message because you are subscribed to a topic in the Google Groups "oTree help & discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otree/bKgNCGeocRI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/bef6127d-f09c-498a-9649-3647c1f9b8b2n%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/6429db96-2d38-4aa2-ab0e-3f96c56497fdn%40googlegroups.com.